annotate compile_old.rhope @ 131:0a4682be2db2

Modify lexer and new parser to work in compiler
author Mike Pavone <pavone@retrodev.com>
date Fri, 05 Nov 2010 02:43:34 +0000
parents 25a205094f9b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
114
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1 Import parser_old.rhope
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3 Main[args]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4 {
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
5 fname <- [args]Index[1]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6 {
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7 file <- <String@File[~]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8 ,text <- [file]Get FString[[file]Length]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
9 params <- New@Parser[]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
10 Print[["Parsing "]Append[fname]]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
11 Null[text, params, New@Parse Program[], 0]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
12 {
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
13 Print["Parsing imports"]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
14 Process Imports[~, params]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15 {
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16 tree <- [~]Workers << [ Map[[~]Workers >>, ["Check Worker Literals"]Set Input[1, ~]] ]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17 { Print["Compiling"] }
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
18 }
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
19 compiled <- [Tree to Program Native[tree]]Compile Program[C Program[]]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
20 { Print["Compiled program to backend"] }
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
21 outfile <- <String@File[ [fname]Append[".c"] ]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
22 [outfile]Put String[ [compiled]Text ]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
23 { Print[["Wrote output to "]Append[ [fname]Append[".c"] ]] }
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
24 }
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
25 }{
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
26 REPL[New@Parser[]]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
27 }
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
28 }
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
29