Romeo Intermediate Language Specification
Author....... Kevin P. Albrecht
Version...... 1.00
Date......... 4 Feb 2004
General
- all programs must end with 'stop'
- in this document, guarantees by the parser are in
square brackets
Operations
Special
nop
line number: (line number), a: (filename)
jump a: (statement index number)
stop
cond a: (boolean), b: (jump to if a<>0), c: (jump to if a=0)
TYPE(a): int, rat
call a: (jump to)
pushes return address on call stack
ret jump to address on top of call stack
asc a: destination string
b: integer value to convert to the ASCII character of
rand a: destination to place randomly generated integer
Type Conversion
- converts puts converted value of 'b' into 'a'
- 'xir' means int->rat
xir
xis
xri
xrs
xsi
xsr
Assignment
set a: b TYPE: int, rat, str
Stack
- stack calls are typesafe
pushl local_stack << a TYPE: int, rat, str
popl local_stack >> a TYPE: int, rat, str
pushr return_stack << a TYPE: int, rat, str
popr return_stack >> a TYPE: int, rat, str
Unary Arithmetic
neg a: -b TYPE: int, rat; [ a.type == b.type ]
Binary Arithmetic
add a: b + c TYPE: int, rat
sub a: b - c TYPE: int, rat
mult a: b * c TYPE: int, rat
div a: b / c TYPE: int, rat
pow a: b ^ c TYPE: int, rat; a.type == b.type
mod a: b mod c TYPE: int
eq a: b = c TYPE: int, rat
neq a: b <> c TYPE: int, rat
lt a: b < c TYPE: int, rat
gt a: b > c TYPE: int, rat
lteq a: b <= c TYPE: int, rat
gteq a: b >= c TYPE: int, rat
or a: b or c TYPE: int, rat
and a: b and c TYPE: int, rat
Unary Arithmetic
cat a: b (concatenate) c TYPE: str
seq a: b = c TYPE: str
sneq a: b <> c TYPE: str
Console
cin a: (input) TYPE: int, rat, str
- loops until non-blank line is input.
cout (output): a TYPE: int, rat, str
- does not output a newline character by default.
File Input/Output
fio IO_TYPE:int B C
IO_TYPE OPERATION B C
------- ----------- ----------------- --------------
0 open input dest handle (int) filename (str)
1 open output dest handle (int) filename (str)
2 close handle (int) NULL
3 read handle (int) dest line (str)
4 write handle (int) line (str)