support dotted list
This commit is contained in:
parent
87aae8dd8f
commit
458ac6b9ab
12
src/parse.y
12
src/parse.y
|
@ -24,7 +24,7 @@ struct parser_control {
|
|||
%token <datum> tSYMBOL tNUMBER tBOOLEAN
|
||||
|
||||
%type <datum> datum simple_datum symbol compound_datum
|
||||
%type <datum> number list list_tail
|
||||
%type <datum> number list list_data
|
||||
|
||||
%%
|
||||
|
||||
|
@ -70,22 +70,22 @@ compound_datum
|
|||
;
|
||||
|
||||
list
|
||||
: tLPAREN list_tail
|
||||
: tLPAREN list_data tRPAREN
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
||||
list_tail
|
||||
: tRPAREN
|
||||
list_data
|
||||
: /* none */
|
||||
{
|
||||
$$ = pic_nil_value();
|
||||
}
|
||||
| datum tDOT datum tRPAREN
|
||||
| datum tDOT datum
|
||||
{
|
||||
$$ = pic_cons(p->pic, $1, $3);
|
||||
}
|
||||
| datum list_tail
|
||||
| datum list_data
|
||||
{
|
||||
$$ = pic_cons(p->pic, $1, $2);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ struct parser_control {
|
|||
boolean #t|#f|#true|#false
|
||||
|
||||
/* symbol */
|
||||
identifier [a-z0-9A-Z+-/*?<=>_]+
|
||||
identifier [a-z0-9A-Z+-/*?<=>_.]+
|
||||
|
||||
/* number */
|
||||
digit [0-9]
|
||||
|
@ -30,6 +30,7 @@ infnan "+inf.0"|"-inf.0"|"+nan.0"|"-nan.0"
|
|||
%%
|
||||
|
||||
[ \t\n\r] /* skip whitespace */
|
||||
"." return tDOT;
|
||||
"(" return tLPAREN;
|
||||
")" return tRPAREN;
|
||||
{boolean} { yylval.datum = pic_bool_value(strcmp(yytext, "#t") == 0 || strcmp(yytext, "#true") == 0); return tBOOLEAN; }
|
||||
|
|
Loading…
Reference in New Issue