Package slogo.parser

This package is responsible for parsing the language SLogo.

See:
          Description

Interface Summary
Parser  
 

Class Summary
AssignmentParser Parse an assignment statement, which is looks like
BackParser  
CleanParser  
ClearScreenParser  
DifferenceParser  
EqualParser  
ForwardParser  
GreaterParser  
HeadingParser  
HideTurtleParser  
HomeParser  
IdentifierParser  
IfParser  
InstructionNames  
InstructionParser Instruction Parser - calls appropriate Parser for each Instruction
IsPenDownParser  
LeftParser  
LessParser  
MinusParser  
NotEqualParser  
NumericExpressionParser Handles parsing numeric values
PenDownParser  
PenUpParser  
ProductParser  
QuotientParser  
RemainderParser  
RepeatParser Parse a REPEAT Statement, which looks like REPEAT numOrVar [ instructionlist ]
RightParser  
SetPenColorParser Parses the SETPENCOLOR instruction
SetXParser  
SetXYParser  
SetYParser  
ShowTurtleParser  
SLogoParser Illustrates the java.io.StreamTokenizer class and how it can be used to parse tokens for a toy example programming language (elan).
StrictInstructionListParser  
SumParser  
ToParser  
TowardsParser  
XCorParser  
YCorParser  
 

Exception Summary
ParseException  
 

Package slogo.parser Description

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

Adding/Parsing a New Instruction

To parse a new instruction the following steps are followed. 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 slogo.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.