Program
9 January 2019 OSU CSE 1
Program 9 January 2019 OSU CSE 1 BL Compiler Structure Code - - PowerPoint PPT Presentation
Program 9 January 2019 OSU CSE 1 BL Compiler Structure Code Tokenizer Parser Generator string of string of abstract string of characters tokens program integers (source code) (words) (object code) A BL program consists of
9 January 2019 OSU CSE 1
9 January 2019 OSU CSE 2
9 January 2019 OSU CSE 3
9 January 2019 OSU CSE 4
9 January 2019 OSU CSE 5
9 January 2019 OSU CSE 6
PROGRAM MyProg IS BEGIN END MyProg INSTRUCTION Instr1 IS END Instr1
BLOCK
BLOCK
INSTRUCTION Instr2 IS END Instr2
BLOCK
PROGRAM SteerClear IS INSTRUCTION Avoid IS IF random THEN turnright ELSE turnleft END IF END Avoid INSTRUCTION Flee IS turnright turnright END Flee BEGIN WHILE true DO IF next-is-empty THEN move ELSE IF next-is-enemy THEN Flee ELSE Avoid END IF END IF END WHILE END SteerClear
9 January 2019 OSU CSE 7
PROGRAM SteerClear IS INSTRUCTION Avoid IS IF random THEN turnright ELSE turnleft END IF END Avoid INSTRUCTION Flee IS turnright turnright END Flee BEGIN WHILE true DO IF next-is-empty THEN move ELSE IF next-is-enemy THEN Flee ELSE Avoid END IF END IF END WHILE END SteerClear
9 January 2019 OSU CSE 8
9 January 2019 OSU CSE 9
BLOCK BLOCK BLOCK
9 January 2019 OSU CSE 10
BLOCK BLOCK BLOCK
9 January 2019 OSU CSE 11
BLOCK BLOCK BLOCK
9 January 2019 OSU CSE 12
BLOCK BLOCK BLOCK
WHILE true DO IF next-is-empty THEN move ELSE IF next-is-wall THEN Flee ELSE Avoid END IF END IF END WHILE
9 January 2019 OSU CSE 13
9 January 2019 OSU CSE 14
9 January 2019 OSU CSE 15
9 January 2019 OSU CSE 16
9 January 2019 OSU CSE 17
9 January 2019 OSU CSE 18
9 January 2019 OSU CSE 19
9 January 2019 OSU CSE 20
9 January 2019 OSU CSE 21
9 January 2019 OSU CSE 22
9 January 2019 OSU CSE 23
9 January 2019 OSU CSE 24
9 January 2019 OSU CSE 25
9 January 2019 OSU CSE 26
9 January 2019 OSU CSE 27
9 January 2019 OSU CSE 28
9 January 2019 OSU CSE 29
Map<String,Statement> c = p.newContext();
9 January 2019 OSU CSE 30
Map<String,Statement> c = p.newContext();
void swapContext(Map<String,Statement> c)
dynamic type returned by newContext.
[names in c are valid IDENTIFIERs] and [names in c do not match the names of primitive instructions in the BL language] and [bodies in c are all BLOCK statements]
c = #this.context and this.context = #c
9 January 2019 OSU CSE 31
9 January 2019 OSU CSE 32
p.swapContext(c);
9 January 2019 OSU CSE 33
p.swapContext(c);
9 January 2019 OSU CSE 34
9 January 2019 OSU CSE 35
Statement b = p.newBody();
9 January 2019 OSU CSE 36
Statement b = p.newBody();
BLOCK
9 January 2019 OSU CSE 37
9 January 2019 OSU CSE 38
9 January 2019 OSU CSE 39
9 January 2019 OSU CSE 40