| 24 |
GLOBAL: prog expr pat regexp const; |
GLOBAL: prog expr pat regexp const; |
| 25 |
|
|
| 26 |
prog: [ |
prog: [ |
| 27 |
[ l = LIST0 [ e = expr; ";;" -> mk loc (EvalStatement e) ] -> l ] |
[ l = LIST0 [ p = phrase; ";;" -> mk loc p ]; ";;" -> l ] |
| 28 |
|
]; |
| 29 |
|
|
| 30 |
|
phrase: [ |
| 31 |
|
[ e = expr -> EvalStatement e |
| 32 |
|
| "type"; x = UIDENT; "="; t = pat -> TypeDecl (x,t) ] |
| 33 |
]; |
]; |
| 34 |
|
|
| 35 |
expr: [ |
expr: [ |
| 119 |
| i = INT ; "--"; j = INT -> |
| i = INT ; "--"; j = INT -> |
| 120 |
let i = int_of_string i and j = int_of_string j in |
let i = int_of_string i and j = int_of_string j in |
| 121 |
mk loc (Internal (Types.interval i j)) |
mk loc (Internal (Types.interval i j)) |
| 122 |
|
| i = char ; "--"; j = char -> |
| 123 |
|
mk loc (Internal (Types.char_class i j)) |
| 124 |
| c = const -> mk loc (Internal (Types.constant c)) |
| c = const -> mk loc (Internal (Types.constant c)) |
| 125 |
| "("; l = LIST1 pat SEP ","; ")" -> multi_prod loc l |
| "("; l = LIST1 pat SEP ","; ")" -> multi_prod loc l |
| 126 |
| "["; r = [ r = regexp -> r | -> Epsilon ]; |
| "["; r = [ r = regexp -> r | -> Epsilon ]; |
| 144 |
| h::t -> List.fold_left (fun t1 t2 -> mk loc (And (t1,t2))) h t |
| h::t -> List.fold_left (fun t1 t2 -> mk loc (And (t1,t2))) h t |
| 145 |
] ]; |
] ]; |
| 146 |
|
|
| 147 |
|
char: |
| 148 |
|
[ |
| 149 |
|
[ c = CHAR -> Chars.Unichar.from_char (Token.eval_char c) |
| 150 |
|
| "!"; i = INT -> Chars.Unichar.from_int (int_of_string i) ] |
| 151 |
|
]; |
| 152 |
|
|
| 153 |
|
|
| 154 |
const: |
const: |
| 155 |
[ |
[ |
| 156 |
[ i = INT -> Types.Integer (int_of_string i) |
[ i = INT -> Types.Integer (int_of_string i) |
| 157 |
| x = STRING -> Types.String (Token.eval_string x) |
| x = STRING -> Types.String (Token.eval_string x) |
| 158 |
| "`"; a = [LIDENT | UIDENT] -> Types.Atom (Types.mk_atom a) ] |
| "`"; a = [LIDENT | UIDENT] -> Types.Atom (Types.mk_atom a) |
| 159 |
|
| c = char -> Types.Char c ] |
| 160 |
]; |
]; |
| 161 |
|
|
| 162 |
tag_spec: |
tag_spec: |