feat: ignore shebang lines starting with #! on first line of source
Add special handling in the lexer's nextToken function to detect a '#' character followed by '!' on the first line (currentLine == 1) and skip the entire line as a comment. If the shebang appears on any other line, or if a '#' is not followed by '!', emit a lex error for invalid character. Include test cases for valid shebang execution, shebang at EOF, shebang on a non-first line (expected error), and an invalid shebang pattern (expected error).
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
#!/bin/wren
|
||||
IO.print("ok") // expect: ok
|
||||
@@ -0,0 +1 @@
|
||||
#!/bin/wren
|
||||
@@ -0,0 +1,3 @@
|
||||
// expect error line 3
|
||||
IO.print("nope")
|
||||
#!/bin/wren
|
||||
@@ -0,0 +1,3 @@
|
||||
#/invalid/shebang
|
||||
// expect error line 1
|
||||
IO.print("nope")
|
||||
Reference in New Issue
Block a user