Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
65 lines (54 sloc) 1.66 KB
# After changing this file `make grammar' is required to update `grammar.c'.
%{
void
ell_parser_add_sym(char *chars);
void
ell_parser_add_str(char *chars);
void
ell_parser_add_num(char *chars);
void
ell_parser_push();
void
ell_parser_pop();
void
ell_parser_push_special(struct ell_obj *sym);
%}
unit = exprs eof
exprs = spc? (expr spc?)*
expr = quote | syntax | quasisyntax | unsyntax | unsyntax-splicing |
num | str | sym | lst | inline-c
num = < "-"? [0-9]+ >
{ ell_parser_add_num(yytext); }
str-esc = "\\" [\"]
str-char = [^\"] | str-esc
str = "\"" < str-char* > "\""
{ ell_parser_add_str(yytext); }
inline-c = "$" < [^$]* > "$"
{ ell_parser_add_str(yytext); }
# Needs to be kept in sync with ellc_mangle_char in 'ellc.c'.
sym-char = [a-z0-9&_#/] | "-" | "<" | ">" | "*" | "+" | "?"
sym = < sym-char+ >
{ ell_parser_add_sym(yytext); }
lst = OPEN exprs CLOSE
| OPEN spc? CLOSE
OPEN = "(" { ell_parser_push(); }
CLOSE = ")" { ell_parser_pop(); }
quote =
"\'" { ell_parser_push_special(ELL_SYM(core_quote)); }
expr { ell_parser_pop(); }
syntax =
"#'" { ell_parser_push_special(ELL_SYM(core_syntax)); }
expr { ell_parser_pop(); }
quasisyntax = "#`"
{ ell_parser_push_special(ELL_SYM(core_quasisyntax)); }
expr { ell_parser_pop(); }
unsyntax = ","
{ ell_parser_push_special(ELL_SYM(core_unsyntax)); }
expr { ell_parser_pop(); }
unsyntax-splicing =
",@" { ell_parser_push_special(ELL_SYM(core_unsyntax_splicing)); }
expr { ell_parser_pop(); }
spc-char = [ \t] | eol
spc = spc-char+
eol = [\r\n]
eof = !.