Added dot syntax for lists, and proper quote syntax. LQuoted is now unused
This commit is contained in:
@@ -11,7 +11,6 @@ let number_sign = '-' | '+'
|
||||
let int = number_sign? digit+
|
||||
let double = digit* '.' digit+ | digit+ '.' digit*
|
||||
|
||||
|
||||
let white = [' ' '\t']+
|
||||
let newline = '\r' | '\n' | "\r\n"
|
||||
|
||||
@@ -31,5 +30,6 @@ rule read =
|
||||
| '(' { LPAREN }
|
||||
| ')' { RPAREN }
|
||||
| '\'' { QUOTE }
|
||||
| '.' { DOT }
|
||||
| _ { raise (SyntaxError ("Unexpected char: " ^ Lexing.lexeme lexbuf))}
|
||||
| eof { EOF }
|
||||
|
@@ -9,6 +9,7 @@
|
||||
%token LPAREN
|
||||
%token RPAREN
|
||||
%token QUOTE
|
||||
%token DOT
|
||||
%token EOF
|
||||
|
||||
%start <Ast.lisp_val option> prog
|
||||
@@ -25,10 +26,11 @@ expr:
|
||||
| s = SYM { LSymbol s }
|
||||
| s = STR { LString (String.uppercase_ascii s) }
|
||||
| LPAREN; l = lisp_list_rest { l }
|
||||
| QUOTE; e = expr { LQuoted e}
|
||||
| QUOTE; e = expr { LCons (LSymbol "quote", LCons (e, LNil)) }
|
||||
;
|
||||
|
||||
lisp_list_rest:
|
||||
| RPAREN { LNil }
|
||||
| DOT; e = expr; RPAREN { e }
|
||||
| e = expr; lr = lisp_list_rest { LCons (e, lr) }
|
||||
;
|
||||
|
Reference in New Issue
Block a user