Package elan.parser

This package is responsible for parsing the language Elan.

See:
          Description

Interface Summary
Parser  
 

Class Summary
AddParser  
AndParser  
AssignmentParser  
BackgroundParser  
BackParser  
BgParser  
BkParser  
CleanParser  
ClearscreenParser  
CsParser  
DifferenceParser  
ElanParser Illustrates the java.io.StreamTokenizer class and how it can be used to parse tokens for a toy example programming language (elan) For this example simple instructions are parsed, but lots of infrastructure is in place for parsing a more complete language.
EqualboolParser  
ExpressionParser This is a recursive descent parser for parsing expressions using the standard grammar for expressions (follows).
FdParser  
FenceParser  
ForwardParser  
GreaterParser  
HeadingParser  
HideturtleParser  
HomeParser  
HtParser  
IdentifierParser  
IfParser  
InstructionNames  
InstructionParser InstructionParser parses instructions; it uses token types to call appropriate parsers, and throws ParseExceptions in cases of error.
LeftParser  
LessParser  
LtParser  
MinusParser  
NotequalParser  
NotParser  
OrParser  
PcParser  
PdParser  
PencolorParser  
PendownParser  
PendownpParser  
PendownqParser  
PensizeParser  
PenupParser  
PrintParser  
ProductParser  
PsParser  
PuParser  
QuotientParser  
RandomnumParser  
RemainderParser  
RepeatParser  
RightParser  
RtParser  
SetbackgroundParser  
SetbgParser  
SetheadingParser  
SethParser  
SetpaletteParser  
SetpcParser  
SetpencolorParser  
SetpensizeParser  
SetpsParser  
SetshapeParser  
SetshParser  
SetxParser  
SetxyParser  
SetyParser  
ShapeParser  
ShowturtleParser  
StParser  
StrictInstructionListParser The StrictInstructionListParser parses a StrictInstructionList in the case of user-defined functions/
SumParser  
TellParser  
ToParser  
TowardsParser  
WindowParser  
WrapParser  
XcorParser  
YcorParser  
 

Exception Summary
FunctionArgumentException  
FunctionNameException  
ParseException  
 

Package elan.parser Description

This package is responsible for parsing the language Elan. It uses recursive descent with, currently, no lookahead.

Adding/Parsing a New Instruction

To parse a new instruction the following steps are followed. In the exposition we'll use the addition of a statement for an If instruction to the language as an example.

  1. Create a token for the instruction (probably a subclass of token.ReservedToken) with the same prefix as the new instruction, e.g., IfToken.java.

  2. Create a parser for the instruction with the same prefix as the instruction, e.g., IfParser.java. The parsing class (presumably implementing Parser) will return an instance of the parsed Instruction, see the next item.

  3. Create an instruction with prefix name, e.g., If.java in the elan.instruction package.

  4. Add the instruction name to the file instructions.prop, e.g., add a single line to the file containing the string If.

Owen L. Astrachan
Last modified: Wed Nov 28 13:22:28 EST 2001