Package

pli

Permalink

package pli

An implementation of a small subset of Scala.

The code in this package is part of the course material for the course “Implementation of Programming Languages” at Tübingen University, Germany.

Main components:

Helper components:

Main data structures:

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. pli
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. trait ASTNode extends AnyRef

    Permalink

    Nodes of the abstract syntax tree.

    Nodes of the abstract syntax tree.

    The abstract syntax tree is one of the main data structures of the language implementation. It is produced by the parser and consumed by many of the other components (see overview).

    The concrete nodes of the abstract syntax tree are implemented by case classes extending this trait, see “Known Subclasses” below for a list. They are further classified by nonterminal by intermediate traits in the inheritance hierarchy.

  2. case class Addition(lhs: Expression, rhs: Expression) extends Expression with Product with Serializable

    Permalink

    Nodes of the abstract syntax tree for expressions of the form “lhs + rhs”.

  3. case class Assignment(name: String, value: Expression) extends Statement with Product with Serializable

    Permalink

    Nodes of the abstract syntax tree for statements of the form “name = value”.

  4. case class Block(body: Seq[Statement]) extends Statement with Product with Serializable

    Permalink

    Nodes of the abstract syntax tree for statements.

  5. class Bytecode extends AnyRef

    Permalink

    Builder for bytecode arrays.

  6. class CodeGenerator extends AnyRef

    Permalink

    Code generator.

  7. class DebugVM extends VM

    Permalink

    A variant of the virtual machine that prints one line of debugging output for every instruction executed.

    A variant of the virtual machine that prints one line of debugging output for every instruction executed.

    To create a debug virtual machine, use the companion object’s apply methods.

  8. trait Expression extends ASTNode

    Permalink

    Nodes of the abstract syntax tree for expressions.

    Nodes of the abstract syntax tree for expressions.

    The concrete nodes for expressions of the abstract syntax tree are implemented by case classes extending this trait, see “Known Subclasses” below for a list.

  9. case class If(condition: Expression, thenBranch: Seq[Statement], elseBranch: Seq[Statement]) extends Statement with Product with Serializable

    Permalink

    Nodes of the abstract syntax tree for statements of the form “if ( condition ) thenBranch” or “if ( condition ) thenBranch else elseBranch”.

    Nodes of the abstract syntax tree for statements of the form “if ( condition ) thenBranch” or “if ( condition ) thenBranch else elseBranch”.

    If there is no else clause in the source code, the elseBranch will be an empty Block as if “else {}” would have been in the source code.

  10. class Interpreter extends AnyRef

    Permalink

    Interpreter.

  11. class Lexer extends AnyRef

    Permalink

    Turns a stream of characters into a stream of tokens.

    Turns a stream of characters into a stream of tokens.

    To create a lexer, use the companion object’s forFile or forString methods.

    The lexer is the first main componenent in the language implementation. It reads a stream of characters from a file, or for testing, from a string. It produces a stream of tokens which is further processed by the parser.

    The lexer classifies tokens according to their token type. The token type of the next token in the token stream is available from nextTokenType.

    The lexer keeps track of line and column positions inside the source code. The first character of the source code is line 1 and column 1. The location of the beginning of the next token is available from startLine and startColumn. The location of the first character after the next token is available from currentLine and currentColumn.

    Most token types classify a fixed string such as an operator or keyword. The following token types are special:

  12. case class Literal(value: Int) extends Expression with Product with Serializable

    Permalink

    Nodes of the abstract syntax tree for expressions of the form “value”.

  13. case class Multiplication(lhs: Expression, rhs: Expression) extends Expression with Product with Serializable

    Permalink

    Nodes of the abstract syntax tree for expressions of the form “lhs * rhs”.

  14. case class NumericValue(toInt: Int) extends Value with Product with Serializable

    Permalink

    Numbers at runtime.

  15. class Parser extends AnyRef

    Permalink

    Turns a stream of tokens into an abstract syntax tree.

    Turns a stream of tokens into an abstract syntax tree.

    To create a parser, use the companion object’s forLexer, forFile, or forString methods.

    The parser is the second main component in the language implementation. It reads a stream of tokens from the lexer. It produces an abstract syntax tree which is further processed by the other components (see overview).

    The parser has one method parseN for each nonterminal symbol N in the grammar´:

    Additional parseN methods are necessary for helper nonterminal symbols to implement operator precedence:

  16. class Pretty extends AnyRef

    Permalink

    Turns an abstract syntax tree back into a string.

    Turns an abstract syntax tree back into a string.

    To create a pretty printer, use the companion object’s toPrintWriter method.

    The pretty printer is a helper component in the language implementation. It can be used during debugging to print out abstract syntax trees for manual inspection.

  17. case class Print(value: Expression) extends Statement with Product with Serializable

    Permalink

    Nodes of the abstract syntax tree for statements of the form “print ( value )”.

  18. case class Program(name: String, superclass: String, body: Seq[Statement]) extends ASTNode with Product with Serializable

    Permalink

    Nodes of the abstract syntax tree for programs of the form “object name extends superclass { body }”.

  19. trait Statement extends ASTNode

    Permalink

    Nodes of the abstract syntax tree for statements.

    Nodes of the abstract syntax tree for statements.

    The concrete nodes for statements of the abstract syntax tree are implemented by case classes extending this trait, see “Known Subclasses” below for a list.

  20. case class Subtraction(lhs: Expression, rhs: Expression) extends Expression with Product with Serializable

    Permalink

    Nodes of the abstract syntax tree for expressions of the form “lhs - rhs”.

  21. class Table[A, B] extends AnyRef

    Permalink

    Mutable symbol table with support for nested scopes.

  22. trait TokenType extends AnyRef

    Permalink

    Used by the lexer to classify tokens in the token stream.

    Used by the lexer to classify tokens in the token stream.

    Each token type is implemented as a case object, see “Known Subclasses” below for a list.

  23. class VM extends AnyRef

    Permalink

    Simple virtual machine, that is, bytecode interpreter.

    Simple virtual machine, that is, bytecode interpreter.

    To create a virtual machine, use the companion object’s apply methods.

    For debugging, consider to use a debug virtual machine instead.

  24. trait Value extends AnyRef

    Permalink

    Values at runtime.

    Values at runtime.

    The representation of values of various dynamic types is implemented by case classes extending this trait, see “Known Subclasses” below for a list.

  25. case class Var(name: String, value: Expression) extends Statement with Product with Serializable

    Permalink

    Nodes of the abstract syntax tree for statements of the form “var name = value”.

  26. case class Variable(name: String) extends Expression with Product with Serializable

    Permalink

    Nodes of the abstract syntax tree for expressions of the form “name”.

  27. case class While(condition: Expression, body: Seq[Statement]) extends Statement with Product with Serializable

    Permalink

    Nodes of the abstract syntax tree for statements of the form “while ( condition ) body”.

Value Members

  1. object Bytecode

    Permalink

    Factory methods for Bytecode instances.

  2. object ClosingBrace extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify “}” tokens in the token stream.

  3. object ClosingParenthesis extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify “)” tokens in the token stream.

  4. object DebugVM

    Permalink

    Factory methods for creating debug virtual machines.

  5. object ElseKeyword extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify “else” tokens in the token stream.

  6. object EndOfFile extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify the end of the token stream.

  7. object EqualsOperator extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify “=” tokens in the token stream.

  8. object ExtendsKeyword extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify “extends” tokens in the token stream.

  9. object Identifier extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify identifier tokens in the token stream.

    Used by the lexer to classify identifier tokens in the token stream.

    The name of the identifier is available from Lexer.nextTokenText.

  10. object IfKeyword extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify “if” tokens in the token stream.

  11. object IntegerLiteral extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify integer literal tokens in the token stream.

    Used by the lexer to classify integer literal tokens in the token stream.

    The value of the integer literal is available from Lexer.nextTokenIntegerValue.

  12. object Lexer

    Permalink

    Factory methods for creating lexers.

  13. object MinusOperator extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify “-” tokens in the token stream.

  14. object ObjectKeyword extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify “object” tokens in the token stream.

  15. object Opcode

    Permalink

    Opcodes of individual bytecode instructions.

  16. object OpeningBrace extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify “{” tokens in the token stream.

  17. object OpeningParenthesis extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify “(” tokens in the token stream.

  18. object Parser

    Permalink

    Factory methods for creating parsers.

  19. object PlusOperator extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify “+” tokens in the token stream.

  20. object Pretty

    Permalink

    Factory methods for creating pretty printers.

  21. object PrintKeyword extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify “print” tokens in the token stream.

  22. object Semicolon extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify “;” tokens in the token stream.

  23. object Table

    Permalink

    Factory methods for creating symbol tables.

  24. object TimesOperator extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify “*” tokens in the token stream.

  25. object VM

    Permalink

    Factory methods for creating virtual machines.

  26. object VarKeyword extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify “var” tokens in the token stream.

  27. object WhileKeyword extends TokenType with Product with Serializable

    Permalink

    Used by the lexer to classify “while” tokens in the token stream.

Inherited from AnyRef

Inherited from Any

Ungrouped