Pascal

The ppci.lang.pascal module contains functionality to transform pascal code into IR-code.

Warning

This module is a work in progress.

Module

Pascal front-end

class ppci.lang.pascal.PascalBuilder(diag, arch_info)

Generates IR-code from pascal source.

build(sources)

Build the given sources.

Raises compiler error when something goes wrong.

do_parse(src, context)

Lexing and parsing stage (phase 1)

class ppci.lang.pascal.Parser(diag)

Parses pascal into ast-nodes

add_symbol(sym)

Add a symbol to the current scope

parse_actual_parameter_list()

Parse a list of parameters

parse_block()

Parse a block.

A block being constants, types, variables and statements.

parse_case_of() → ppci.lang.pascal.nodes.CaseOf

Parse case-of statement

parse_compound_statement()

Parse a compound statement

parse_constant_definitions()

Parse constant definitions

parse_designator()

A designator designates an object with a name.

parse_factor() → ppci.lang.pascal.nodes.Expression

Parse a factor

parse_for() → ppci.lang.pascal.nodes.For

Parse a for statement

parse_function_def(public=True)

Parse function definition

parse_id_sequence()

Parse a sequence of id’s

parse_if()

Parse if statement

parse_primary_expression() → ppci.lang.pascal.nodes.Expression

Literal and parenthesis expression parsing

parse_program(context)

Parse a program

parse_read()

Parses a read statement

parse_readln()

Parses a readln statement

parse_repeat()

Parses a repeat statement

parse_return() → ppci.lang.pascal.nodes.Return

Parse a return statement

parse_simple_expression() → ppci.lang.pascal.nodes.Expression

Parse [-] term [-/+ term]*

parse_single_variable_declaration()

Parse a single variable declaration line ending in ‘;’

parse_source(tokens, context)

Parse a module from tokens

parse_statement() → ppci.lang.generic.nodes.Statement

Determine statement type based on the pending token

parse_term()

Parse a term (one or more factors)

parse_type_def(public=True)

Parse a type definition

parse_type_spec()

Parse type specification. Type specs are read from right to left.

A variable spec is given by: var [typeSpec] [modifiers] [pointer/array suffix] variable_name

For example: var int volatile * ptr; creates a pointer to a volatile integer.

parse_uses()

Parse import construct

parse_variable_declarations()

Parse variable declarations

parse_while() → ppci.lang.pascal.nodes.While

Parses a while statement

parse_write()

Parses a write statement

parse_writeln()

Parses a writeln statement

class ppci.lang.pascal.Lexer(diag)

Generates a sequence of token from an input stream

tokenize(text)

Keeps track of the long comments