Skip navigation links

Package slogo.parser

This package is responsible for parsing the language SLogo.

See: Description

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 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.
Skip navigation links