Mercurial > repos > tabletprog
annotate modules/compiler.tp @ 323:eb5f1fca9b78
Fix infinite loop in foldr:with
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 23 Mar 2015 21:18:26 -0700 |
parents | 004946743678 |
children |
rev | line source |
---|---|
252
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #{ |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 main <- :args { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 if: (args length) > 1 { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 file <- os open: (args get: 1) (os O_RDONLY) |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 code <- "" |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 chunksize <- 1024 |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 readsize <- chunksize |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 while: { readsize = chunksize} do: { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 seg <- os read: file chunksize |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 code <- code . seg |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 readsize <- seg byte_length |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 res <- parser top: code |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 if: res { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 methods <- symbols buildMethodTable: (res yield) |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 print: methods |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 } else: { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 print: "Parse failed!\n" |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 } else: { |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 print: "Usage compiler FILE\n" |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 } |
004946743678
Added code for building a method symbol table
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 } |