LKAST class documentation

Authors

Generated by builder

Contents -

  1. Software documentation for the LKAST class
  2. Software documentation for the LKAST(Interpreter) category
  3. Software documentation for the LKAST(Visitor) category
  4. Software documentation for the LKASTVisitor protocol

Software documentation for the LKAST class

LKAST : NSObject

Declared in:
LKAST.h

Root class for AST nodes. Every node in the abstract syntax tree inherits from this. It stores the parent, allowing navigation up the tree, and a pointer to the symbol table for this scope.


Instance Variables

Method summary

code 

+ (NSMutableDictionary*) code;

Returns the AST nodes available at runtime for subclasses and categories.


check 

- (BOOL) check;

Performs semantic analysis on this node and all of its children.


checkWithErrorReporter: 

- (BOOL) checkWithErrorReporter: (id<LKCompilerDelegate>)errorReporter;

Performs semantic analysis on this node and all of its children, reporting errors and warnings to the object specified by the argument.


compileWithGenerator: 

- (void*) compileWithGenerator: (id<LKCodeGenerator>)aGenerator;

Compile this AST node with the specified code generator.


inheritSymbolTable: 

- (void) inheritSymbolTable: (LKSymbolTable*)aSymbolTable;

Inherits the given symbol table from the parent.


initWithSymbolTable: 

- (id) initWithSymbolTable: (LKSymbolTable*)aSymbolTable;

Initialise a new AST node with the specified symbol table.


isBracketed 

- (BOOL) isBracketed;

Returns whether the AST node represents a bracketed expression.


isBranch 

- (BOOL) isBranch;

Returns YES for AST nodes that branch unconditionally.


isComment 

- (BOOL) isComment;

Returns YES for AST nodes with no code generation


module 

- (LKModule*) module;

Returns the module containing the current AST.


parent 

- (LKAST*) parent;

Returns the parent of this AST node.


print 

- (void) print;

Prints the syntax tree from this node. Use only for debugging.


setBracketed: 

- (void) setBracketed: (BOOL)aFlag;

Set whether the AST node represents a bracketed expression.


setParent: 

- (void) setParent: (LKAST*)aNode;

Sets the parent of this node. Also sets connections between the nodes' symbol tables.


symbols 

- (LKSymbolTable*) symbols;

Returns the symbol table for this node.




Instance Variables for LKAST Class

isBracket

@protected BOOL isBracket;

Is this a parenthetical expression? Avoids creating explicit nodes for parenthetical expressions. Might not be sensible.


parent

@protected LKAST* parent;

Node above this one in the tree.


symbols

@protected LKSymbolTable* symbols;

Symbol table for this context. If no new symbols are defined, this is a pointer to the parent's symbol table.





Software documentation for the LKAST(Interpreter) category

LKAST(Interpreter)

Declared in:
LKAST.h
Description forthcoming.
Method summary

interpretInContext: 

- (id) interpretInContext: (LKInterpreterContext*)context;

Interprets the AST node with the specified context object. Returns the result.


Software documentation for the LKAST(Visitor) category

LKAST(Visitor)

Declared in:
LKAST.h
Description forthcoming.
Method summary

visitArray: withVisitor: 

- (void) visitArray: (NSMutableArray*)anArray withVisitor: (id<LKASTVisitor>)aVisitor;

Convenience method. Visits every element in a specified mutable array, replacing elements with the versions returned by the visitor if they have changed.


visitWithVisitor: 

- (void) visitWithVisitor: (id<LKASTVisitor>)aVisitor;

Visit the abstract syntax tree with the specified visitor.


Software documentation for the LKASTVisitor protocol

LKASTVisitor

Declared in:
LKAST.h

Protocol for AST visitors. Used for classes that perform AST transforms.

Method summary

visitASTNode: 

- (LKAST*) visitASTNode: (LKAST*)anAST;

Visit the specified AST node. The argument will be replaced by the return value in the AST if the two differ.