annotate compile_old_c.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 18a4403fe576
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
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2 Import parser_old_c.rhope
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4 Main[args]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
5 {
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6 fname <- [args]Index[1]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7 {
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8 file <- [File[~]]Open["r"]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
9 text <- String[[file]Read[[file]Length]]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
10 params <- Parser[]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
11 Print[["Parsing "]Append[fname]]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
12 Null[text, params, Parse Program[], 0]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
13 {
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
14 Print["Parsing imports"]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15 Process Imports[~, params]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16 {
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17 tree <- [~]Workers << [ Map[[~]Workers >>, Check Worker Literals[?, ~]] ]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
18 { Print["Compiling"] }
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
19 }
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
20 compiled <- [Tree to Program Native[tree]]Compile Program[C Program[]]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
21 { Print["Compiled program to backend"] }
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
22 outfile <- [File[ [fname]Append[".c"] ]]Truncate
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
23 [[compiled]Text]Write to File[outfile]
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
24 { Print[["Wrote output to "]Append[ [fname]Append[".c"] ]] }
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 }{
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
27 Print["You must provide a file name to compile"]
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 }
25a205094f9b More performance optimizations
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
30