From 51f22055d1369bbf5bd855c240beb7e23ff4e91a Mon Sep 17 00:00:00 2001 From: "chris.double" Date: Fri, 15 Dec 2006 08:03:13 +0000 Subject: [PATCH] fjsc: add \ word functionality --- libs/fjsc/fjsc.factor | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libs/fjsc/fjsc.factor b/libs/fjsc/fjsc.factor index ccb28425ac..3eff68104e 100644 --- a/libs/fjsc/fjsc.factor +++ b/libs/fjsc/fjsc.factor @@ -11,6 +11,7 @@ TUPLE: ast-quotation expression ; TUPLE: ast-array elements ; TUPLE: ast-define name expression ; TUPLE: ast-expression values ; +TUPLE: ast-word value ; TUPLE: ast-alien return method args ; LAZY: 'digit' ( -- parser ) @@ -78,6 +79,10 @@ LAZY: 'array' ( -- parser ) 'expression' &> "}" token sp <& [ ] <@ ; +LAZY: 'word' ( -- parser ) + "\\" token sp + 'identifier' sp &> [ ast-identifier-value ] <@ ; + LAZY: 'atom' ( -- parser ) 'identifier' 'number' <|> 'string' <|> ; @@ -89,6 +94,7 @@ LAZY: 'alien' ( -- parser ) LAZY: 'expression' ( -- parser ) 'define' sp + 'word' sp <|> 'alien' sp <|> 'atom' sp <|> 'quotation' sp <|> @@ -172,6 +178,16 @@ M: ast-alien (compile) ast-alien-return empty? not [ ")" , ] when ; + +M: ast-word (literal) + "factor.words[\"" , + ast-word-value , + "\"]" , ; + +M: ast-word (compile) + "factor.data_stack.push(" , + (literal) + ")" , ; : fjsc-compile ( ast -- string ) [