lexer: change shebang handling to be in skip-blank.
It previously required "#!" to be defined like "!", now it doesn't.db4
parent
59caf874a3
commit
eaa65bc66f
|
@ -63,33 +63,29 @@ ERROR: unexpected want got ;
|
|||
|
||||
GENERIC: skip-blank ( lexer -- )
|
||||
|
||||
M: lexer skip-blank
|
||||
[ t skip ] change-lexer-column ;
|
||||
|
||||
GENERIC: skip-word ( lexer -- )
|
||||
|
||||
<PRIVATE
|
||||
|
||||
: quote? ( column text -- ? )
|
||||
{ fixnum string } declare nth CHAR: " eq? ;
|
||||
|
||||
: shebang? ( column text -- ? )
|
||||
{ fixnum string } declare swap zero? [
|
||||
dup length 1 > [
|
||||
dup first-unsafe CHAR: # =
|
||||
[ second-unsafe CHAR: ! = ] [ drop f ] if
|
||||
] [ drop f ] if
|
||||
] [ drop f ] if ;
|
||||
: shebang? ( lexer -- lexer ? )
|
||||
dup line>> 1 = [
|
||||
dup column>> zero? [
|
||||
dup line-text>> "#!" head?
|
||||
] [ f ] if
|
||||
] [ f ] if ; inline
|
||||
|
||||
PRIVATE>
|
||||
|
||||
M: lexer skip-blank
|
||||
shebang? [
|
||||
[ nip length ] change-lexer-column
|
||||
] [
|
||||
[ t skip ] change-lexer-column
|
||||
] if ;
|
||||
|
||||
GENERIC: skip-word ( lexer -- )
|
||||
|
||||
M: lexer skip-word
|
||||
[
|
||||
{
|
||||
{ [ 2dup quote? ] [ drop 1 + ] }
|
||||
{ [ 2dup shebang? ] [ drop 2 + ] }
|
||||
[ f skip ]
|
||||
} cond
|
||||
2dup nth CHAR: " eq? [ drop 1 + ] [ f skip ] if
|
||||
] change-lexer-column ;
|
||||
|
||||
: still-parsing? ( lexer -- ? )
|
||||
|
|
Loading…
Reference in New Issue