Skip to content

Commit bad1703

Browse files
authored
Update README.md
1 parent 0067650 commit bad1703

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# BookPart 3
22

3-
This is source code for part III of the book series on building an interpreter using Object Pascal (https://www.objectpascalinterpreter.com). The major outward change in this version include library support, a range of (currently) small builtin libraries such as math. The biggest internal change is to separate code generation from syntax analysis in the for of an abstract syntax tree. User functions are also now first-class entities which can be passed around like any other variable. Example code:
3+
This is source code for part III of the book series on building an interpreter using Object Pascal (https://www.objectpascalinterpreter.com). The major outward change in this version includes library support, a range of small builtin libraries such as math (these will be expanded). The biggest internal change is to separate code generation from syntax analysis in the form of an abstract syntax tree. User functions are also now first-class entities which can be passed around like any other variable. Example code:
44

55

66
// Quick sort algorithm, depends on recursion
@@ -76,3 +76,26 @@ Passing functions as arguments:
7676

7777
s = runtest (cube, 5)
7878
println (s)
79+
80+
Use of modules:
81+
82+
First define a new module:
83+
84+
a1 = 1.234
85+
b1 = 5.678
86+
87+
function sqrt (x)
88+
return x^0.5
89+
end;
90+
91+
function input (prompt)
92+
print (prompt + " ");
93+
return readString()
94+
end
95+
96+
Importing and using the module:
97+
98+
import lib
99+
100+
println (lib.sqrt (25))
101+
println (lib.a1)

0 commit comments

Comments
 (0)