Merge branch 'feature-shebang-support' of git://github.com/mauvm/wren into mauvm-feature-shebang-support

This commit is contained in:
Bob Nystrom
2015-01-04 13:02:42 -08:00
5 changed files with 20 additions and 0 deletions

View File

@ -796,6 +796,17 @@ static void nextToken(Parser* parser)
peekChar(parser) == '_' ? TOKEN_STATIC_FIELD : TOKEN_FIELD);
return;
case '#':
// Ignore shebang on the first line.
if (peekChar(parser) == '!' && parser->currentLine == 1)
{
skipLineComment(parser);
break;
}
lexError(parser, "Invalid character '%c'.", c);
return;
default:
if (isName(c))
{

View File

@ -0,0 +1,2 @@
#!/bin/wren
IO.print("ok") // expect: ok

View File

@ -0,0 +1 @@
#!/bin/wren

View File

@ -0,0 +1,3 @@
// expect error line 3
IO.print("nope")
#!/bin/wren

View File

@ -0,0 +1,3 @@
#/invalid/shebang
// expect error line 1
IO.print("nope")