annotate trunk/src/main.d @ 309:b4d842b0d2c7

- Added new files Settings.d, config.d and lang_en.d - Removed redundant break statements from Lexer.d. - Added function Cast() to SyntaxTree.d. - Relocated compiler version info to Settings.d. - Removed messages variable from module Messages. Compiler messages are loaded dynamically now. - Relocated some functions from module Information to module Messages, and added some format functions to it. - Message tables are located in their own lang_*.d files. - Added getString() method to class StringLiteralsExpression. - Module Settings has a static struct GlobalSettings. It loads global settings from config.d and a language file.
author aziz
date Wed, 15 Aug 2007 16:07:05 +0000
parents 3b9fc1e72210
children fa0b6f32c1ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8ba2570de175 Initial import.
aziz
parents:
diff changeset
1 /++
8ba2570de175 Initial import.
aziz
parents:
diff changeset
2 Author: Aziz Köksal
249
32d354584b28 - Upgraded license notices to GPL3.
aziz
parents: 213
diff changeset
3 License: GPL3
0
8ba2570de175 Initial import.
aziz
parents:
diff changeset
4 +/
8ba2570de175 Initial import.
aziz
parents:
diff changeset
5 module dparser;
69
24db7c5522d5 - Added module Information for compiler messages like warnings, info and errors to the user.
aziz
parents: 66
diff changeset
6 import Parser;
3
4bbce78bfb1e - Added TOK enum.
aziz
parents: 0
diff changeset
7 import Lexer;
4bbce78bfb1e - Added TOK enum.
aziz
parents: 0
diff changeset
8 import Token;
54
e55bd2270f94 - Relocated messages table to a separate module.
aziz
parents: 51
diff changeset
9 import Messages;
3
4bbce78bfb1e - Added TOK enum.
aziz
parents: 0
diff changeset
10 import std.stdio;
4
92df59b1ec4a - Started implementation of scan().
aziz
parents: 3
diff changeset
11 import std.file;
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 308
diff changeset
12 import Settings;
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 308
diff changeset
13 import Declarations, Expressions, SyntaxTree;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
14
0
8ba2570de175 Initial import.
aziz
parents:
diff changeset
15 void main(char[][] args)
8ba2570de175 Initial import.
aziz
parents:
diff changeset
16 {
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 308
diff changeset
17 GlobalSettings.load();
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 308
diff changeset
18
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
19 if (args.length <= 1)
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 308
diff changeset
20 return writefln(format(MID.HelpMain, VERSION, usageHighlight, COMPILED_WITH, COMPILED_VERSION, COMPILED_DATE));
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
21
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
22 string command = args[1];
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
23 switch (command)
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
24 {
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
25 case "hl", "highlight":
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
26 if (args.length == 3)
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 308
diff changeset
27 tokensToXML(args[2]);
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
28 break;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
29 default:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
30 }
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
31 }
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
32
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
33 void parse(string fileName)
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
34 {
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
35 auto sourceText = cast(char[]) std.file.read(fileName);
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
36 auto parser = new Parser(sourceText, fileName);
213
b0ebde88d2d4 - Added members trying, errorCount and prev (for debugging) to Parser.
aziz
parents: 112
diff changeset
37 parser.start();
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 303
diff changeset
38 auto root = parser.parseModule();
299
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 249
diff changeset
39
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 249
diff changeset
40 void print(Node[] decls, char[] indent)
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 249
diff changeset
41 {
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 249
diff changeset
42 foreach(decl; decls)
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 249
diff changeset
43 {
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 249
diff changeset
44 assert(decl !is null);
303
bc1112f7933d - Added keyword debug to some statements.
aziz
parents: 299
diff changeset
45 writefln(indent, decl.classinfo.name, ": begin=%s end=%s", decl.begin ? decl.begin.srcText : "\33[31mnull\33[0m", decl.end ? decl.end.srcText : "\33[31mnull\33[0m");
299
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 249
diff changeset
46 print(decl.children, indent ~ " ");
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 249
diff changeset
47 }
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 249
diff changeset
48 }
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 303
diff changeset
49 print(root.children, "");
213
b0ebde88d2d4 - Added members trying, errorCount and prev (for debugging) to Parser.
aziz
parents: 112
diff changeset
50 foreach (error; parser.errors)
b0ebde88d2d4 - Added members trying, errorCount and prev (for debugging) to Parser.
aziz
parents: 112
diff changeset
51 {
b0ebde88d2d4 - Added members trying, errorCount and prev (for debugging) to Parser.
aziz
parents: 112
diff changeset
52 writefln(`%s(%d)P: %s`, parser.lx.fileName, error.loc, error.getMsg);
b0ebde88d2d4 - Added members trying, errorCount and prev (for debugging) to Parser.
aziz
parents: 112
diff changeset
53 }
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
54 }
213
b0ebde88d2d4 - Added members trying, errorCount and prev (for debugging) to Parser.
aziz
parents: 112
diff changeset
55
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
56 char[] xml_escape(char[] text)
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
57 {
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
58 char[] result;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
59 foreach(c; text)
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
60 switch(c)
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
61 {
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
62 case '<': result ~= "&lt;"; break;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
63 case '>': result ~= "&gt;"; break;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
64 case '&': result ~= "&amp;"; break;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
65 default: result ~= c;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
66 }
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
67 return result;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
68 }
0
8ba2570de175 Initial import.
aziz
parents:
diff changeset
69
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 308
diff changeset
70 void tokensToXML(string fileName)
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
71 {
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
72 auto sourceText = cast(char[]) std.file.read(fileName);
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
73 auto lx = new Lexer(sourceText, fileName);
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
74
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
75 auto token = lx.getTokens();
5
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
76 char* end = lx.text.ptr;
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
77
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
78 writef(`<?xml version="1.0"?>`
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
79 `<?xml-stylesheet href="format.css" type="text/css"?>`
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
80 `<root>`);
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
81 if (lx.errors.length)
51
cadd2bfe686c - Displaying error messages in XML.
aziz
parents: 44
diff changeset
82 {
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
83 writefln("<compilerinfo>");
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
84 foreach (error; lx.errors)
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
85 {
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
86 writefln(`<error t="%s">%s(%d): %s</error>`, "l", lx.fileName, error.loc, xml_escape(error.getMsg));
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
87 }
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
88 writefln("</compilerinfo>");
51
cadd2bfe686c - Displaying error messages in XML.
aziz
parents: 44
diff changeset
89 }
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
90 writef(`<sourcetext>`);
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
91
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
92 // Traverse linked list and print tokens.
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
93 while (token.type != TOK.EOF)
4
92df59b1ec4a - Started implementation of scan().
aziz
parents: 3
diff changeset
94 {
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
95 token = token.next;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
96
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
97 // Print whitespace between previous and current token.
5
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
98 if (end != token.start)
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
99 writef("%s", xml_escape(end[0 .. token.start - end]));
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
100
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
101 string srcText = xml_escape(token.srcText);
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
102
5
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
103 switch(token.type)
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
104 {
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
105 case TOK.Identifier:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
106 writef("<i>%s</i>", srcText);
5
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
107 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
108 case TOK.Comment:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
109 string c;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
110 switch (token.start[1])
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
111 {
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
112 case '/': c = "l"; break;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
113 case '*': c = "b"; break;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
114 case '+': c = "n"; break;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
115 default:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
116 assert(0);
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
117 }
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
118 writef(`<c c="%s">%s</c>`, c, srcText);
5
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
119 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
120 case TOK.String:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
121 writef("<sl>%s</sl>", srcText);
9
5d6968cc751e - Parsing string and character literals now (rudimentary implementation.)
aziz
parents: 5
diff changeset
122 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
123 case TOK.CharLiteral, TOK.WCharLiteral, TOK.DCharLiteral:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
124 writef("<cl>%s</cl>", srcText);
9
5d6968cc751e - Parsing string and character literals now (rudimentary implementation.)
aziz
parents: 5
diff changeset
125 break;
308
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
126 case TOK.Assign, TOK.Equal,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
127 TOK.Less, TOK.Greater,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
128 TOK.LShiftAssign, TOK.LShift,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
129 TOK.RShiftAssign, TOK.RShift,
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
130 TOK.URShiftAssign, TOK.URShift,
308
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
131 TOK.OrAssign, TOK.OrBinary,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
132 TOK.AndAssign, TOK.AndBinary,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
133 TOK.PlusAssign, TOK.PlusPlus, TOK.Plus,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
134 TOK.MinusAssign, TOK.MinusMinus, TOK.Minus,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
135 TOK.DivAssign, TOK.Div,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
136 TOK.MulAssign, TOK.Mul,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
137 TOK.ModAssign, TOK.Mod,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
138 TOK.XorAssign, TOK.Xor,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
139 TOK.CatAssign,
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
140 TOK.Tilde,
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
141 TOK.Unordered,
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
142 TOK.UorE,
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
143 TOK.UorG,
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
144 TOK.UorGorE,
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
145 TOK.UorL,
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
146 TOK.UorLorE,
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
147 TOK.LorEorG:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
148 writef("<op>%s</op>", srcText);
14
cdf788d8bdaf - Parsing /= now.
aziz
parents: 10
diff changeset
149 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
150 case TOK.LorG:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
151 writef(`<op c="lg">&lt;&gt;</op>`);
39
69b940398d7b - Added unittest to test correct parsing of operator tokens.
aziz
parents: 35
diff changeset
152 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
153 case TOK.LessEqual:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
154 writef(`<op c="le">&lt;=</op>`);
39
69b940398d7b - Added unittest to test correct parsing of operator tokens.
aziz
parents: 35
diff changeset
155 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
156 case TOK.GreaterEqual:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
157 writef(`<op c="ge">&gt;=</op>`);
39
69b940398d7b - Added unittest to test correct parsing of operator tokens.
aziz
parents: 35
diff changeset
158 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
159 case TOK.AndLogical:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
160 writef(`<op c="aa">&amp;&amp;</op>`);
31
94f09f4e988e - Added struct for strings to Token with 'pf' = postfix.
aziz
parents: 30
diff changeset
161 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
162 case TOK.OrLogical:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
163 writef(`<op c="oo">||</op>`);
31
94f09f4e988e - Added struct for strings to Token with 'pf' = postfix.
aziz
parents: 30
diff changeset
164 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
165 case TOK.NotEqual:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
166 writef(`<op c="ne">!=</op>`);
44
5055947e0f98 - Specific operators and comments can be formatted with CSS now.
aziz
parents: 39
diff changeset
167 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
168 case TOK.Not:
307
5f6a173d4ad3 - Don't consider '\!' as an operator when it begins a template argument list.
aziz
parents: 306
diff changeset
169 // Check if this is part of a template instantiation.
5f6a173d4ad3 - Don't consider '\!' as an operator when it begins a template argument list.
aziz
parents: 306
diff changeset
170 // TODO: comments aren't skipped.
5f6a173d4ad3 - Don't consider '\!' as an operator when it begins a template argument list.
aziz
parents: 306
diff changeset
171 if (token.prev.type == TOK.Identifier && token.next.type == TOK.LParen)
5f6a173d4ad3 - Don't consider '\!' as an operator when it begins a template argument list.
aziz
parents: 306
diff changeset
172 goto default;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
173 writef(`<op c="n">!</op>`);
35
c470b9356e35 - Added code for parsing Unordered, UorE, UorG, UorGorE, UorL, UorLorE, NotEqual and Not tokens.
aziz
parents: 33
diff changeset
174 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
175 case TOK.Int32, TOK.Int64, TOK.Uint32, TOK.Uint64,
308
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
176 TOK.Float32, TOK.Float64, TOK.Float80,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
177 TOK.Imaginary32, TOK.Imaginary64, TOK.Imaginary80:
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
178 writef("<n>%s</n>", srcText);
15
c70c028e47dd - Started implementation of lexing numbers.
aziz
parents: 14
diff changeset
179 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
180 case TOK.LParen, TOK.RParen, TOK.LBracket,
308
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
181 TOK.RBracket, TOK.LBrace, TOK.RBrace:
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
182 writef("<br>%s</br>", srcText);
20
d6adfbd7c513 - Added code for parsing braces.
aziz
parents: 17
diff changeset
183 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
184 default:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
185 if (token.isKeyword())
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
186 writef("<k>%s</k>", srcText);
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
187 else
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
188 writef("%s", srcText);
5
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
189 }
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
190 end = token.end;
4
92df59b1ec4a - Started implementation of scan().
aziz
parents: 3
diff changeset
191 }
51
cadd2bfe686c - Displaying error messages in XML.
aziz
parents: 44
diff changeset
192 writef("\n</sourcetext>\n</root>");
0
8ba2570de175 Initial import.
aziz
parents:
diff changeset
193 }