Add simple KINETIC block parsing (#71)
Targets issue #62. New tokens added: keywords tok::kinetic, tok::conserve; symbols tok::tilde, tok::arrow; split tok::number into tok::real and tok::integer (stoichiometric expressions may have only integer coefficients). New expression sub-types added, together with parsing: IntegerExpression (derives from NumberExpression); ReactionExpression — represents a line of the form "~ a + b <-> c (f, r)"; StoichTermExpression — represents a single term in the lhs or rhs of a reaction as an integral coefficient and identifier, for example "3c" or "-2 sp2"; StoichExpression — represents a possibly empty series of StoichTermExpressions, corresponding to the lhs or rhs of a reaction, or the lhs of a CONSERVE declaration; ConserveExpression (derives from BinaryExpression) — represents a line of the form "CONSERVE a + 2b - c = expr". Unit tests added for parsing and lexing of the above, with some clean up of the testing code: verbose testing selectable at run time with -v, instead of being a compile time decision; code duplication reduced in test_parser.cpp through the use of helper functions check_parse and check_parse_fail; handle verbose output from lexer tests by subclassing the lexer; additionally, emit tokens from Lexer::parse() in verbose output.
No related branches found
No related tags found
Showing
- modcc/expression.cpp 120 additions, 10 deletionsmodcc/expression.cpp
- modcc/expression.hpp 159 additions, 4 deletionsmodcc/expression.hpp
- modcc/lexer.cpp 40 additions, 18 deletionsmodcc/lexer.cpp
- modcc/lexer.hpp 1 addition, 1 deletionmodcc/lexer.hpp
- modcc/parser.cpp 175 additions, 8 deletionsmodcc/parser.cpp
- modcc/parser.hpp 6 additions, 1 deletionmodcc/parser.hpp
- modcc/token.cpp 7 additions, 1 deletionmodcc/token.cpp
- modcc/token.hpp 10 additions, 4 deletionsmodcc/token.hpp
- modcc/visitor.hpp 1 addition, 0 deletionsmodcc/visitor.hpp
- tests/modcc/driver.cpp 7 additions, 0 deletionstests/modcc/driver.cpp
- tests/modcc/test.hpp 3 additions, 6 deletionstests/modcc/test.hpp
- tests/modcc/test_lexer.cpp 115 additions, 28 deletionstests/modcc/test_lexer.cpp
- tests/modcc/test_optimization.cpp 24 additions, 24 deletionstests/modcc/test_optimization.cpp
- tests/modcc/test_parser.cpp 405 additions, 406 deletionstests/modcc/test_parser.cpp
Please register or sign in to comment