Interface | Description |
---|---|
Parser |
The interface that all parsers must implement
|
Class | Description |
---|---|
AssignmentParser |
Parse an assignment statement, which looks like
<id> <assignment_token, i.e., = > <expression>
|
ExpressionParser |
This is a recursive descent parser for parsing expressions using the standard
grammar for expressions (follows).
|
FDParser |
Parse a FORWARD Statement, which looks like
FORWARD numOrVar [ instructionlist ]
|
ForwardParser |
Parse a FORWARD Statement, which looks like
FORWARD numOrVar [ instructionlist ]
|
IdentifierParser |
Parser for identifiers
|
InstructionChecker | |
InstructionNames |
Reads the file of instruction names.
|
InstructionParser |
Instruction Parser - calls appropriate Parser for each Instruction
|
PrintParser |
The parser for the print instruction
|
RepeatParser |
Parse a REPEAT Statement, which looks like
REPEAT numOrVar [ instructionlist ]
|
RightParser |
Parse a RIGHT Statement, which looks like
RIGHT numOrVar
|
SLogoParser |
Illustrates the java.io.StreamTokenizer class and how it can be used to parse
tokens for a subset of the SLogo programming language.
|
StrictInstructionListParser |
The parser for lists of instructions.
|
Exception | Description |
---|---|
ParseException |
A specialized exception class for parsing errors
|
This package is responsible for parsing the language SLogo. It uses recursive descent with, currently, no lookahead.
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.
token.ReservedToken
) with
the same prefix as the new instruction, e.g., IfToken.java
.
IfParser.java
. The parsing class
(presumably implementing Parser
) will
return an instance of the parsed Instruction, see the next item.
If.java
in the slogo.instruction
package.
instructions.prop
,
e.g., add a single line to the file containing the string If.