O'Reilly logo

Building Parsers with Java™ by Steven John Metsker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

16.10. A Sling Grammar

A Sling program is a series of statements:

statements = statement statement*; 

These statements may be either assignment statements, for statements, or plot statements:

statement     = assignment | forStatement | plotStatement; 
assignment    = variable '=' expression ';' ;
plotStatement = "plot" expression ';';
forStatement  =
    "for" '(' variable ',' expression ',' expression  ')'
    '{' statements '}';

A variable is any unreserved word; the reserved words in Sling are the elements shown in Figure 16.12.

variable = Word; 

Expressions in Sling allow for normal arithmetic manipulation:

 expression = term (plusTerm | minusTerm)*; plusTerm = '+' term; minusTerm = '-' term; term = element (timesElement | divideElement | remainderElement)*; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required