1 #########################################################################
2 # AI script compiler configuration file
3 # -------------------------------------
5 # Each line has the following form:
6 # <type>: <name>=<content>
7 # type is either token or rule
8 # name is any name without '=' character
9 # content for token is a regular expression
10 # content for rule has the following form:
11 # <matching_rule>,<byte_code>
12 # matching_rule is a combination of rules and/or tokens seperated with spaces
13 # byte_code is a set of bytecode mnemonics seperated with commas (',')
14 # Lines beginning with # and empty lines are skipped.
15 # /!\ - lines exceeding 255 characters will be misinterpreted
16 # /!\ - following tokens and rules are used by the system, so don't change
18 # NAME, params, tuple, expeclose, case
19 # There may be others. This can be considered as a bug.
21 #########################################################################
27 token: NUMBER=(\-)?[0-9]+(\.[0-9]+)?
32 token: WHILE=\w\h\i\l\e
35 token: SWITCH=\s\w\i\t\c\h
38 token: ONCHILDREN=\o\n\c\h\i\l\d\r\e\n
40 token: PRINT=\p\r\i\n\t
43 #token: CHAIN=\"[-a-zA-Z0-9_ .,]*\"
44 token: CHAIN=\"[-a-zA-Z0-9_ .:,;()*/+='!?éèùêàç#&|%<>]*\"
46 token: NAME=[a-zA-Z_][a-zA-Z0-9_]*
47 token: STRNAME=\$[a-zA-Z_][a-zA-Z0-9_]*
53 token: SUPEQ=(\>\=)|(\=\>)
54 token: INFEQ=(\<\=)|(\=\<)
55 token: NEQ=(\!\=)|(\<\>)|(\>\<)
65 token: MINUSMINUS=\-\-
82 #########################################################################
85 rule: logic=AND, AND|OR, OR
87 rule: comp=EQU, EQ|SUPEQ, SUPEQ|INFEQ, INFEQ|NEQ, NEQ|SUP, SUP|INF, INF
89 rule: expression=expression logic expression, Code 1, Code 3, Code 2
90 rule: expression=LP expression RP, Code 2
91 rule: expression=value comp value, Code 1, Code 3, Code 2
93 #not used rule: stringType=CHAIN, Code 1|STRNAME, String 1
94 #not used rule: expression=stringType comp stringType, Code 1, Code 3, Code 2
96 rule: value=somme, Code 1|produitoufacteur, Code 1|expprio, Code 1
98 rule: oper1=PLUS, ADD|MINUS, SUB
100 rule: somme=somme oper1 produitoufacteur, Code 1, Code 3, Code 2
101 rule: somme=produitoufacteur oper1 produitoufacteur, Code 1, Code 3, Code 2
103 rule: oper2=SLASH, DIV|STAR, MUL
105 rule: produit=produitoufacteur oper2 facteur, Code 1, Code 3, Code 2
106 rule: produitoufacteur=produit, Code 1|facteur, Code 1
108 rule: facteur=expprio, Code 1
109 rule: facteur=expressMemb, Code 1
111 rule: expprio=LP somme RP, Code 2|LP produit RP, Code 2|LP expressMemb RP, Code 2
112 rule: expressMemb=readVar, Code 1
113 #rule: expressMemb=readVar, Code 1|exp, Code 1
115 rule: if=IF LP expression RP lineOrClose, Code 3, JE 3, Code 5
116 rule: ifelse=IF LP expression RP lineOrClose ELSE lineOrClose, Code 3, JE 4, Code 5, JUMP 5, Code 7
118 rule: while=WHILE LP expression RP lineOrClose, Code 3, JE 4, Code 5, JUMP 0
120 rule: groupRef=NAME POINT, PUSH_GROUP, String 1
122 rule: setFunction=NAME LP RP expeclose, FUNCTION, String 1, JUMP 5, Code 4, EOP
123 rule: setFunction=NAME LP RP LA RA, FUNCTION, String 1, JUMP 4, EOP
124 rule: callOn=NAME LP RP, CALL, String 1
126 rule: function=setFunction, PUSH_THIS, Code 1|groupRef setFunction, Code 1, Code 2
127 rule: call=callOn, PUSH_THIS, Code 1|groupRef callOn, Code 1, Code 2
130 rule: nativeFunc=tuple NAME params, Code 3, PUSH_THIS, NativeCall, Code 1
131 rule: nativeOtherFunc=tuple groupRef NAME params, Code 4, Code 2, NativeCall, Code 1
133 # used to make this: foo1()=toto.foo2(); toto.foo1()=foo2(); toto.foo1()=tutu.foo2(); or foo1()=foo2();
134 rule: setFromFuncGet=NAME LP RP, PUSH_THIS, PUSH_STRING, String 1|groupRef NAME LP RP, Code 1, PUSH_STRING, String 2
135 rule: setFromFuncSet=NAME LP RP, PUSH_THIS, PUSH_STRING, String 1|groupRef NAME LP RP, Code 1, PUSH_STRING, String 2
136 rule: setFromFunction=setFromFuncSet ASSIGNATOR setFromFuncGet, Code 1, Code 3, ASSIGN_FUNC_FROM
138 # first Name -> Group, second Name -> EventName
140 rule: tupleElem=tupleElem SEPARATOR writeVar, Code 1, Code 3|writeVar, Code 1
141 rule: tuple=LP tupleElem RP, Code 2|LP RP
143 rule: lValue=writeVar, Code 1|tuple, Code 1
144 rule: rValue=readVar, Code 1|somme, Code 1|produit, Code 1|expprio, Code 1
145 #rule: rValue=readVar, Code 1|exp, Code 1|somme, Code 1|produit, Code 1|expprio, Code 1
147 rule: readConstVar=CHAIN, PUSH_STRING, String 1
148 rule: readConstVar=NUMBER, PUSH_ON_STACK, Atof 1
150 rule: readVar=NAME, PUSHVAR_VAL, String 1|NAME POINT NAME, PUSHOTHERVAR_VAL, String 1, String 3
151 rule: readVar=STRNAME, PUSHSTRVAR_VAL, String 1|NAME POINT STRNAME, PUSHOTHERSTRVAR_VAL, String 1, String 3
152 rule: readVar=readConstVar, Code 1
154 rule: writeVar=NAME, SETVAR_VAL, String 1|NAME POINT NAME, SETOTHERVAR_VAL, String 1, String 3
155 rule: writeVar=STRNAME, SETSTRVAR_VAL, String 1|NAME POINT STRNAME, SETOTHERSTRVAR_VAL, String 1, String 3
158 rule: rValueList=rValueList SEPARATOR rValue, Code 1, Code 3|rValue, Code 1
159 rule: params=LP rValueList RP, Code 2|LP RP
161 #rule: exp=lValue ASSIGNATOR rValue, Code 3, Code 1|functCall, Code 1
162 rule: exp=lValue ASSIGNATOR rValue, Code 3, Code 1
164 rule: printContent=printContent SEPARATOR CHAIN, Code 1, PUSH_PRINT_STRING, String 3|CHAIN, PUSH_PRINT_STRING, String 1
165 rule: printContent=printContent SEPARATOR NAME, Code 1, PUSH_PRINT_VAR, String 3|NAME, PUSH_PRINT_VAR, String 1
166 rule: printContent=printContent SEPARATOR STRNAME, Code 1, PUSH_PRINT_STRVAR, String 3|STRNAME, PUSH_PRINT_STRVAR, String 1
167 rule: printString=PRINT LP printContent RP, Code 3, PRINT_STRING
168 rule: logString=LOG LP printContent RP, Code 3, LOG_STRING
171 rule: line=ifelse, Code 1
172 rule: line=if, Code 1
173 rule: line=exp PV, Code 1
174 rule: line=while, Code 1
175 rule: line=printString PV, Code 1
176 rule: line=logString PV, Code 1
177 rule: line=function, Code 1|call PV, Code 1
178 rule: line=setFromFunction PV, Code 1
179 rule: line=nativeFunc PV, Code 1
180 rule: line=nativeOtherFunc PV, Code 1
181 rule: line=randEx, Code 1
182 rule: line=onChildren, Code 1
183 rule: line=switch, Code 1
186 rule: line=NAME PLUSPLUS PV, PUSHVAR_VAL, String 1, INCR, SETVAR_VAL, String 1
187 rule: line=PLUSPLUS NAME PV, PUSHVAR_VAL, String 2, INCR, SETVAR_VAL, String 2
188 rule: line=NAME MINUSMINUS PV, PUSHVAR_VAL, String 1, DECR, SETVAR_VAL, String 1
189 rule: line=MINUSMINUS NAME PV, PUSHVAR_VAL, String 2, DECR, SETVAR_VAL, String 2
190 rule: line=NAME POINT NAME PLUSPLUS PV, PUSHOTHERVAR_VAL, String 1, String 3, INCR, SETOTHERVAR_VAL, String 1, String 3
191 rule: line=PLUSPLUS NAME POINT NAME PV, PUSHOTHERVAR_VAL, String 2, String 4, INCR, SETOTHERVAR_VAL, String 2, String 4
192 rule: line=NAME POINT NAME MINUSMINUS PV, PUSHOTHERVAR_VAL, String 1, String 3, DECR, SETOTHERVAR_VAL, String 1, String 3
193 rule: line=MINUSMINUS NAME POINT NAME PV, PUSHOTHERVAR_VAL, String 2, String 4, DECR, SETOTHERVAR_VAL, String 2, String 4
196 rule: line=NAME ADDASSIGN rValue PV, PUSHVAR_VAL, String 1, Code 3, ADD, SETVAR_VAL, String 1
197 rule: line=NAME POINT NAME ADDASSIGN rValue PV, PUSHOTHERVAR_VAL, String 1, String 3, Code 5, ADD, SETOTHERVAR_VAL, String 1, String 3
199 rule: line=NAME SUBASSIGN rValue PV, PUSHVAR_VAL, String 1, Code 3, SUB, SETVAR_VAL, String 1
200 rule: line=NAME POINT NAME SUBASSIGN rValue PV, PUSHOTHERVAR_VAL, String 1, String 3, Code 5, SUB, SETOTHERVAR_VAL, String 1, String 3
202 rule: line=NAME MULASSIGN rValue PV, PUSHVAR_VAL, String 1, Code 3, MUL, SETVAR_VAL, String 1
203 rule: line=NAME POINT NAME MULASSIGN rValue PV, PUSHOTHERVAR_VAL, String 1, String 3, Code 5, MUL, SETOTHERVAR_VAL, String 1, String 3
205 rule: line=NAME DIVASSIGN rValue PV, PUSHVAR_VAL, String 1, Code 3, DIV, SETVAR_VAL, String 1
206 rule: line=NAME POINT NAME DIVASSIGN rValue PV, PUSHOTHERVAR_VAL, String 1, String 3, Code 5, DIV, SETOTHERVAR_VAL, String 1, String 3
208 # when CONCAT is supported add string +=
210 #rule: line=STRNAME ADDASSIGN rValue PV, PUSHSTRVAR_VAL, String 1, Code 3, CONCAT, SETSTRVAR_VAL, String 1
211 #rule: line=NAME POINT STRNAME ADDASSIGN rValue PV, PUSHOTHERSTRVAR_VAL, String 1, String 3, Code 5, CONCAT, SETOTHERSTRVAR_VAL, String 1, String 3
213 rule: lineOrClose=line, Code 1|expeclose, Code 1
215 rule: randEx=RAND expeclose, RandomSeq
217 rule: case=CASE readConstVar PP lineOrClose
218 rule: switch=SWITCH LP rValue RP LA +case RA, Code 3,SwitchSeq
220 rule: expeclose=LA +lineOrClose RA, CodeAllExceptFirstAndLast
222 rule: onChildren=ONCHILDREN LP RP expeclose, ONCHILDREN, JUMP 4, Code 4, EOP