fjsc: allow comments with ! and #!
parent
51f22055d1
commit
bf1da849a9
|
@ -13,6 +13,7 @@ TUPLE: ast-define name expression ;
|
||||||
TUPLE: ast-expression values ;
|
TUPLE: ast-expression values ;
|
||||||
TUPLE: ast-word value ;
|
TUPLE: ast-word value ;
|
||||||
TUPLE: ast-alien return method args ;
|
TUPLE: ast-alien return method args ;
|
||||||
|
TUPLE: ast-comment ;
|
||||||
|
|
||||||
LAZY: 'digit' ( -- parser )
|
LAZY: 'digit' ( -- parser )
|
||||||
[ digit? ] satisfy [ digit> ] <@ ;
|
[ digit? ] satisfy [ digit> ] <@ ;
|
||||||
|
@ -92,8 +93,15 @@ LAZY: 'alien' ( -- parser )
|
||||||
'array' [ ast-array-elements ast-expression-values [ ast-string-value ] map ] <@ <:&>
|
'array' [ ast-array-elements ast-expression-values [ ast-string-value ] map ] <@ <:&>
|
||||||
"alien-invoke" token sp <& [ first3 <ast-alien> ] <@ ;
|
"alien-invoke" token sp <& [ first3 <ast-alien> ] <@ ;
|
||||||
|
|
||||||
|
LAZY: 'comment' ( -- parser )
|
||||||
|
"#!" token sp
|
||||||
|
"!" token sp <|> [
|
||||||
|
dup CHAR: \n = swap CHAR: \r = or not
|
||||||
|
] satisfy <*> <&> [ drop <ast-comment> ] <@ ;
|
||||||
|
|
||||||
LAZY: 'expression' ( -- parser )
|
LAZY: 'expression' ( -- parser )
|
||||||
'define' sp
|
'comment'
|
||||||
|
'define' sp <|>
|
||||||
'word' sp <|>
|
'word' sp <|>
|
||||||
'alien' sp <|>
|
'alien' sp <|>
|
||||||
'atom' sp <|>
|
'atom' sp <|>
|
||||||
|
@ -189,6 +197,9 @@ M: ast-word (compile)
|
||||||
(literal)
|
(literal)
|
||||||
")" , ;
|
")" , ;
|
||||||
|
|
||||||
|
M: ast-comment (compile)
|
||||||
|
drop "/* */" , ;
|
||||||
|
|
||||||
: fjsc-compile ( ast -- string )
|
: fjsc-compile ( ast -- string )
|
||||||
[
|
[
|
||||||
[ (compile) ] { } make [ write ] each
|
[ (compile) ] { } make [ write ] each
|
||||||
|
|
Loading…
Reference in New Issue