Class: Parameters06

Seven~ Parameters06

Example 7/06: compile functions with parameters and local variables.


new Parameters06()

Source:

Extends

Classes

Fun
Symbol
Var

Members


context

Manages a stack of contexts for assign or call to a name

Source:

funct

Describes current function

Inherited From:
Overrides:
Source:

size

Manages next (global) variable address

Inherited From:
Overrides:
Source:

Methods


Do()

Do: 'do'; returns address of slot for bzero to od

Inherited From:
Overrides:
Source:

Else()

Else: 'else'; creates slot for branch to fi, returns address of else

Inherited From:
Overrides:
Source:

Then()

Then: 'then'; returns address for bzero to else fi

Inherited From:
Overrides:
Source:

While()

While: 'while'; returns address for branch to while

Inherited From:
Overrides:
Source:

_alloc()

Replace: returns new Var at next local/global address.

Overrides:
Source:

_check_defs()

Flags undefined functions, returns main if defined

Inherited From:
Overrides:
Source:

_dcl()

Replace: sets innermost map, returns sym

Overrides:
Source:

_find()

Extend: checks local then global map, returns sym

Overrides:
Source:

_startup(main)

[Extend] Push 0 for main parameters.

Parameters:
Name Type Description
main Fun

describes main().

Overrides:
Source:

add()

add: '+' product;

Inherited From:
Overrides:
Source:

args()

args: '(' [ sums ] ')'; expects context, codes call

Source:

assign()

assign: symbol action; codes Pop, pops context

Overrides:
Source:

divide()

divide: '/' signed;

Inherited From:
Overrides:
Source:

eq()

eq: '=' sum;

Inherited From:
Overrides:
Source:

fun()

fun: head parms [ block ] ';';

Overrides:
Source:

ge()

ge: '>=' sum;

Inherited From:
Overrides:
Source:

gt()

gt: '>' sum;

Inherited From:
Overrides:
Source:

head: 'function' Name; returns function symbol

Inherited From:
Overrides:
Source:

input()

input: 'input' [ Number ];

Inherited From:
Overrides:
Source:

le()

le: '<=' sum;

Inherited From:
Overrides:
Source:

loop()

loop: While cmp Do stmts 'od';

Inherited From:
Overrides:
Source:

lt()

lt: '<' sum;

Inherited From:
Overrides:
Source:

multiply()

multiply: '*' signed;

Inherited From:
Overrides:
Source:

name()

name: symbol [ args ]; codes variable load, pops context

Overrides:
Source:

names()

names: Name [{ ',' Name }]; defines new variables, returns number of names

Inherited From:
Overrides:
Source:

ne()

ne: '<>' sum;

Inherited From:
Overrides:
Source:

number()

number: Number;

Inherited From:
Overrides:
Source:

parms()

parms: '(' [ names ] ')';

Source:

print()

print: 'print' sums;

Inherited From:
Overrides:
Source:

prog()

prog: [ vars ] funs; returns executable

Inherited From:
Overrides:
Source:

return()

return: 'return' [ sum ];

Inherited From:
Overrides:
Source:

run()

Creates stack machine

Inherited From:
Overrides:
Source:

select()

select: 'if' cmp Then stmts [ Else stmts ] 'fi';

Inherited From:
Overrides:
Source:

signed()

signed: [ '-' ] term;

Inherited From:
Overrides:
Source:

stmt()

stmt: assign | print | loop | select; [replace] no op

Inherited From:
Overrides:
Source:

store()

store: '=' sum; expects context, codes assignment

Source:

subtract()

subtract: '-' product;

Inherited From:
Overrides:
Source:

sum()

sum: 'let' Name '=' sum | product [{ add | subtract }];

Inherited From:
Overrides:
Source:

sums()

sums: sum [{ ',' sum }]; returns number of values

Inherited From:
Overrides:
Source:

symbol()

symbol: Name; pushes context, returns symbol

Source:

toString()

Represents code as text

Inherited From:
Overrides:
Source: