Commit f7de4bd3c70b39bf410402e8e6feac74805865f4

Authored by Salvador Abreu
1 parent e2445a00
Exists in master

var decl fix

fzn-parser/examples/a.ast
... ... @@ -17,7 +17,7 @@ _T > [_:id('output_var')|_T].
17 17 _T > [[]|_T].
18 18 [H,T|_T] > [[H|T]|_T].
19 19 _T > [[]|_T].
20   -[VAL,AN,T|_T] > [var(T, VAL, AN)|_T].
  20 +[VAL,AN,ID,T|_T] > [var(ID, T, VAL, AN)|_T].
21 21 [H,T|_T] > [[H|T]|_T].
22 22 _T > [int(1,3)|_T].
23 23 _T > ['nt'|_T].
... ... @@ -25,7 +25,7 @@ _T > [_:id('output_var')|_T].
25 25 _T > [[]|_T].
26 26 [H,T|_T] > [[H|T]|_T].
27 27 _T > [[]|_T].
28   -[VAL,AN,T|_T] > [var(T, VAL, AN)|_T].
  28 +[VAL,AN,ID,T|_T] > [var(ID, T, VAL, AN)|_T].
29 29 [H,T|_T] > [[H|T]|_T].
30 30 [X|_T] > [vars(X)|_T].
31 31 _T > [[]|_T].
... ...
fzn-parser/flatzinc.y
... ... @@ -51,18 +51,9 @@
51 51 // pop an item and a list, push new list (CONS)
52 52 #define CONS() AST ("H,T", ("[H|T]"))
53 53  
54   - // pop one thing, push it as a 1-element list
55   -#define TAIL() AST ("T", ("[T]"))
56   -
57 54 // push the empty list
58 55 #define NIL() PUSH (("[]"))
59 56  
60   - // pop one thing, push an open-ended list headed with that thing
61   -#define TAIL_OPEN() AST ("T", ("[T|_]"))
62   -
63   - // push an unbound variable
64   -#define NIL_OPEN() PUSH (("_"))
65   -
66 57 #define BINARY(op) AST ("B,A", ("op(A,B)"))
67 58 #define UNARY(op) AST ("X", ("op(X)"))
68 59  
... ... @@ -117,11 +108,11 @@ model_end : solve_item ';'
117 108 pred_decl_item:
118 109 PREDICATE IDENT '(' pred_decl_args ')'
119 110  
120   -var_decl_item:
  111 +var_decl_item: /* -> [ var(ID,TYPE,INIT,ANNOT) | _ ] */
121 112 VAR non_array_ti_expr_tail ':' ident_anns var_decl_item2
122   - { AST ("VAL,AN,T", ("var(T, VAL, AN)")); }
  113 + { AST ("VAL,AN,ID,T", ("var(ID, T, VAL, AN)")); }
123 114 | non_array_ti_expr_tail ':' ident_anns '=' expr
124   - { AST ("VAL,AN,T", ("var(T, VAL, AN)")); }
  115 + { AST ("VAL,AN,ID,T", ("var(ID, T, VAL, AN)")); }
125 116 | ARRAY '[' INT_LITERAL DOTDOT INT_LITERAL ']' OF array_decl_tail
126 117 { AST ("VAL,AN,T", ("var(array(T,%d,%d), VAL, AN)", $3, $5)); }
127 118  
... ...