oclisp.opp.exp 739 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
Note: the nonterminal symbol list (from oclisp.mly) is renamed oclisp_list.
File "oclisp.mly", line 2, characters 25-28:
Warning: the token EOF is unused.
%start main
%token RBRACKET
%token QUOTE
%token <string> NAME
%token LBRACKET
%token EOF
%token DOT

%type <Types.sexp> main
%%

main:
| sexp
    { $1 }

sexp:
| oclisp_list
    { $1 }
| atom
    { $1 }
| QUOTE sexp
    { Types.Cons (Types.Atom "quote", Types.Cons($2, Types.Atom "nil")) }

oclisp_list:
| LBRACKET RBRACKET
    { Types.Atom "nil" }
| LBRACKET inside_list RBRACKET
    { $2 }

inside_list:
| sexp DOT sexp
    { Types.Cons ($1,$3) }
| sexp
    { Types.Cons ($1, Types.Atom "nil") }
| sexp inside_list
    {Types.Cons($1,$2)}

atom:
| NAME
    { Types.Atom $1 }

%%