Skip to content
Snippets Groups Projects
Commit 4fcf4e57 authored by Ben Cumming's avatar Ben Cumming Committed by GitHub
Browse files

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.
parents 0ded25a6 584c70fe
No related branches found
No related tags found
No related merge requests found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment