Simple example recursive-descent parser for expressions.

LA home
Computing
FP
 SML
  SML97
   Exp

Also see
Parsing
C
Java
exp.sml -- parser
The lexical analysis function converts a char list into a Symbol list; to see this try, e.g.,
    use "exp.sml";
    lexical(explode "(1+2)*3-4/5+x");
The parser takes a Symbol list and produces a parse tree : Exp, e.g.,
    expression(lexical(explode "(1+2)*3-4/5+x"));
main.sml -- parse text from a file
wrapper for the parser, asks for a file name, opens it, calls the parser, e.g.,
    use "main.sml";
    run "data";
 
Note, these expressions include arithmetic (+, -, *, /), relational (=, <>, <=, >=, < >), and logical (and, or, not) operators.
 
And there is a syntax (and semantics) for a small programming language [here].
www:

free:
Linux
 Ubuntu operating-sys
OpenOffice office-suite
The GIMP ~photoshop
Firefox web-browser
FlashBlock flash on/off

SML:
:: cons
[x1,...] list
[ ] list
@ append
fn =>  &lambda .
: has type
Compared

© L. Allison   http://www.allisons.org/ll/   (or as otherwise indicated),
Created with "vi (Linux + Solaris)",  charset=iso-8859-1,  fetched Tuesday, 07-Feb-2012 15:57:43 EST.