From dcab546b97f8d7e7b2b55f9f18ae339456a59dd2 Mon Sep 17 00:00:00 2001 From: James Cash Date: Wed, 30 Apr 2008 17:00:20 -0400 Subject: [PATCH] Adding negative numbers to the parser, other minor changes --- extra/lisp/parser/parser.factor | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/extra/lisp/parser/parser.factor b/extra/lisp/parser/parser.factor index 7f03846044..83f0278129 100644 --- a/extra/lisp/parser/parser.factor +++ b/extra/lisp/parser/parser.factor @@ -18,21 +18,22 @@ RPAREN = ")" dquote = '"' squote = "'" digit = [0-9] -integer = (digit)+ => [[ string>number ]] -float = (digit)+ "." (digit)* => [[ first3 >string [ >string ] dipd 3append string>number ]] +integer = ("-")? (digit)+ => [[ string>number ]] +float = ("-")? (digit)+ "." (digit)* => [[ first3 >string [ >string ] dipd 3append string>number ]] number = float | integer id-specials = "!" | "$" | "%" | "&" | "*" | "/" | ":" | "<" | " =" | ">" | "?" | "^" | "_" | "~" | "+" | "-" | "." | "@" -letters = [a-zA-Z] => [[ 1array >string ]] +letters = [a-zA-Z] => [[ 1array >string ]] initials = letters | id-specials -numbers = [0-9] => [[ 1array >string ]] +numbers = [0-9] => [[ 1array >string ]] subsequents = initials | numbers -identifier = initials (subsequents)* => [[ first2 concat append ]] -string = dquote ("\" . | !(dquote) . )* dquote => [[ second >string ]] +identifier = initials (subsequents)* => [[ first2 concat append ]] +escaped = "\" . => [[ second ]] +string = dquote ( escaped | !(dquote) . )* dquote => [[ second >string ]] atom = number | identifier | string -list-item = _ (atom|s-expression) _ => [[ second ]] -s-expression = LPAREN (list-item)* RPAREN => [[ second ]] +list-item = _ (atom|s-expression) _ => [[ second ]] +s-expression = LPAREN (list-item)* RPAREN => [[ second ]] ;EBNF \ No newline at end of file