mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-12 06:38:45 +01:00
Merge branch 'feature-shebang-support' of git://github.com/mauvm/wren into mauvm-feature-shebang-support
This commit is contained in:
@ -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))
|
||||
{
|
||||
|
||||
2
test/shebang/shebang.wren
Normal file
2
test/shebang/shebang.wren
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/wren
|
||||
IO.print("ok") // expect: ok
|
||||
1
test/shebang/shebang_at_eof.wren
Normal file
1
test/shebang/shebang_at_eof.wren
Normal file
@ -0,0 +1 @@
|
||||
#!/bin/wren
|
||||
3
test/shebang/shebang_at_other_line.wren
Normal file
3
test/shebang/shebang_at_other_line.wren
Normal file
@ -0,0 +1,3 @@
|
||||
// expect error line 3
|
||||
IO.print("nope")
|
||||
#!/bin/wren
|
||||
3
test/shebang/shebang_invalid.wren
Normal file
3
test/shebang/shebang_invalid.wren
Normal file
@ -0,0 +1,3 @@
|
||||
#/invalid/shebang
|
||||
// expect error line 1
|
||||
IO.print("nope")
|
||||
Reference in New Issue
Block a user