Commits

Maciej Fijalkowski committed 0152866

Variable support

Comments (0)

Files changed (2)

kermit/grammar.txt

 IGNORE: "[ \t\n]";
 DECIMAL: "-?0|[1-9][0-9]*";
 ADD_SYMBOL: "[-+]";
+VARIABLE: "[a-zA-Z_][a-zA-Z0-9_]*";
 
 main: statement* [EOF];
 
 
 expr: atom ADD_SYMBOL expr | atom;
 
-atom: DECIMAL;
+atom: DECIMAL | VARIABLE;

kermit/sourceparser.py

         chnode = node.children[0]
         if chnode.symbol == 'DECIMAL':
             return ConstantInt(int(chnode.additional_info))
-        xxx
+        if chnode.symbol == 'VARIABLE':
+            return Variable(chnode.additional_info)
+        raise NotImplementedError
 
 transformer = Transformer()