Marker trait for all built-in entities.
A built-in type with an implicit definition that the compiler must have special knowledge about.
A user-defined constant entity represented by a constant declaration.
An entity that represents some program object.
An environment is a stack of scopes with the innermost scope on the top.
An environment is a stack of scopes with the innermost scope on the top.
An entity that represents an error situation.
A built-in value of some type that is represented by a particular integer value.
A user-defined module represented by a module declaration.
Support for unique ids for named things.
A named entity.
A scope maps identifiers to entities.
A scope maps identifiers to entities.
An entity representing by a user-provided type declaration.
A user-defined type.
A variable entity including a reference to its types' definition.
A entity represented by names for whom we have seen more than one declaration so we are unsure what is being represented.
Static support for entity names.
An unknown entity, represented by names whose declarations are missing.
The name of this artefact.
The actual type of an expression following type aliases.
The actual type of an expression following type aliases.
Pretty-print a block, omitting the BEGIN if there are no statements.
Pretty-print a block, omitting the BEGIN if there are no statements. Add the possibility of declarations to the previous level.
Built-in Boolean type.
Built-in Boolean type.
Check an AST node for semantic errors.
Check an AST node for semantic errors. Report any errors using the messaging module. This default implementation just ask the node's children to check themselves.
Process the command-line arguments and return Some(filename) of the input file if processing should continue, None otherwise.
Process the command-line arguments and return Some(filename) of the input file if processing should continue, None otherwise.
Process the AST, returning the new one.
Process the AST, returning the new one. By default, do nothing.
The built-in type associated with a type declaration.
The built-in type associated with a type declaration.
The default environment.
The default environment.
Define i to be e in the current scope of env, raising an error if the environment is empty.
Define i to be e in the current scope of env, raising an error if the environment is empty.
The type given by a type definition.
The type given by a type definition.
Custom driver for section tagging and challenge mode for errors.
Custom driver for section tagging and challenge mode for errors. If a parse error occurs: in challenge mode, just send "parse failed" to standard output, otherwise send the message to the errors file.
Enter a new empty scope nested within the given environment.
Enter a new empty scope nested within the given environment.
The program entity referred to by an identifier definition or use.
The program entity referred to by an identifier definition or use. In the case of a definition it's the thing being defined, so define it to be a reference to the declaration. If it's already defined, return a entity that indicates a multiple definition. In the case of a use, it's the thing defined elsewhere that is being referred to here, so look it up in the environment.
The entity for an identifier definition as given by its declaration context.
The entity for an identifier definition as given by its declaration context.
The environment containing bindings for all identifiers visible at the given node.
The environment containing bindings for all identifiers visible at the given node. It starts at the module declaration with the default environment. At blocks we enter a nested scope which is removed on exit from the block. At constant and type declarations the left-hand side binding is not in scope on the right-hand side. Each identifier definition just adds its binding to the chain. The envout cases for assignment and expression mean that we don't need to traverse into those constructs, since declarations can't occur there.
Is an expression expected to be constant or not? Either the expression is the root of an expected constant expression or its parent expression is expected to be constant.
Is an expression expected to be constant or not? Either the expression is the root of an expected constant expression or its parent expression is expected to be constant.
The type expected of an expression as defined by its context.
The type expected of an expression as defined by its context.
The type expected of an expression as defined by its context.
The type expected of an expression as defined by its context.
Built-in false constant.
Built-in false constant.
The type of the entity denoted by an identifier use.
The type of the entity denoted by an identifier use.
Perform initialisation of semantic analysis that is necessary before processing an AST.
Perform initialisation of semantic analysis that is necessary before processing an AST.
Built-in integer type.
Built-in integer type.
Return true if the given type is Boolean or an unknown type.
Return true if the given type is Boolean or an unknown type.
Compatibility of types.
Compatibility of types. Return true if the type is compatible with the expected type. Unknown types are compatible with any other type. Otherwise, use look up the base types of what we have and compare them.
Return true if the entity is erroneous or is a constant.
Return true if the entity is erroneous or is a constant.
Say whether i is defined in any scope of env.
Say whether i is defined in any scope of env.
Say whether i is defined in an innermost scope of env (i.
Say whether i is defined in an innermost scope of env (i.e., in the current scope).
Say whether i is defined in an outer scope of env (i.
Say whether i is defined in an outer scope of env (i.e., not in the current scope).
Say whether i is defined in the given scope.
Say whether i is defined in the given scope.
Say whether i is defined in the current scope of env.
Say whether i is defined in the current scope of env.
Return true if the entity is an error, false otherwise.
Return true if the entity is an error, false otherwise.
Return true if the given type is integer or an unknown type.
Return true if the given type is integer or an unknown type.
Return true if the expression can legally appear on the left-hand side of an assignment statement.
Return true if the expression can legally appear on the left-hand side of an assignment statement. At this level only allow identifiers of variables or things we don't know anything about. The true default is used so that this computation can be used in redefinitions.
Return true if the entity is erroneous or is a module.
Return true if the entity is erroneous or is a module.
Return true if the identifier is an r-value and hence its value can be used (ie.
Return true if the identifier is an r-value and hence its value can be used (ie. it's erroneous or is a constant, value or variable).
Return true if the entity is erroneous or is a type.
Return true if the entity is erroneous or is a type.
Return true if the entity is erroneous or is a variable.
Return true if the entity is erroneous or is a variable.
Is an expression constant or not? Unknown entities are constant.
Is an expression constant or not? Unknown entities are constant. Strictly speaking we only need to support integer expressions here, but we treat Boolean ones as constant in the same way so that we avoid spurious errors. Type analysis will reject Boolean constant expressions anyway.
Leave the outermost scope of the given environment, raising an error if the environment is empty.
Leave the outermost scope of the given environment, raising an error if the environment is empty.
Look up i in env, returning the mapped Entity if there is one, otherwise return e.
Look up i in env, returning the mapped Entity if there is one, otherwise return e. If scope is true, just search the innermost scope, otherwise search outwards in all scopes, returning the first Entity found, if any.
Process the given abstract syntax tree.
Process the given abstract syntax tree. Send output to emitter, marking sections so that we can split things later.
Process the AST, returning the new one.
Process the AST, returning the new one. By default, return the AST unchanged.
Reset the environment module.
Reset the environment module.
Is this expression the root of what is expected to be a constant expression? At this level only expressions on the RHS of a constant declaration have this property.
Is this expression the root of what is expected to be a constant expression? At this level only expressions on the RHS of a constant declaration have this property.
Create a root environment, i.
Create a root environment, i.e., one that has a single scope containing the given bindings.
Output a section heading so that the output can be split later.
Output a section heading so that the output can be split later.
Pretty-print a nested list of nodes separated by sep (default: semi colon) and line breaks.
Pretty-print a nested list of nodes separated by sep (default: semi colon) and line breaks.
The type of an expression.
The type of an expression.
Built-in true constant.
Built-in true constant.
The actual type that a user type denotes.
The actual type that a user type denotes.
A type that is unknown, eg because the typed thing is erroneously defined.
A type that is unknown, eg because the typed thing is erroneously defined.
What is the value of an integer expression? Only needs to be valid if the expression is an integer constant (see isconst above) and is defined (eg, no divide by zero.
What is the value of an integer expression? Only needs to be valid if the expression is an integer constant (see isconst above) and is defined (eg, no divide by zero.) Returns zero in all other cases. FIXME: Ignores issues of overflow.