Chemeq : a chemical equation parser


chemeq V1.10-2, ©2000-2002 G. Khaznadar <georgesk @boltz.univ-littoral.fr>


Chemeq is hosted as a project at Savannah-GNU

chemeq is a basic standalone filter written in C language, flex and bison. It inputs strings like:
2H2 + O2 ---> 2 H2O
    
and can outputs LaTeX code, many useful messages and much more.
It aims to be embedded in educational applications.

Examples :

  1. chemeq used inside a WIMS server to implement simple exercises.
  2. chemeq used in a simple shell command :
    example:~$ echo "2H2 + O2 ---> 2 H2O" | chemeq -lc
    2\,H_{2}\,+\,O_{2}\,\rightarrow\,2\,H_{2}O
    OK
    
    which means : 2 molecules of dihydrogen react with one molecule of dioxygen, yelding two water molecules.
    The first line, "2\,H_{2}\,+\,O_{2}\,\rightarrow\,2\,H_{2}O" is a translation of the equation in LaTeX language.
    The second line "OK" means that the equation is well equilibrated.

    When the input is not successfully parsed, the filter fails with the exit code 1.
    example:~$ echo "2H^2 + O2 ---> 2 H2O" | chemeq -lc
    ERROR parse error at 4
    

  3. chemeq used in a shell command to match an erroneous syntax against a template, which may be a common student's mistake :
    example:~$ input="1/2 H2 + 1/2 O2 -> 1/2 H2O"
    example:~$ template="H2 +O2 ->H2O"
    example:~$ if [ "$(echo $input|chemeq -n)" = "$(echo $template|chemeq -n)" ]; then
    > echo match;
    > else echo no match;
    > fi
    match
    

NOTES


    This filter can be embedded in educational test systems, in order to analyze a student's answer to a problem of physics or chemistry.

    This software snippet is GPL, see the file COPYING.

    Feedback is welcome.


    Options, Installation, Test mode and demo.
    Georges Khaznadar
    Last modified: Tue May 21 15:15:04 CEST 2002