annotate trunk/src/main.d @ 315:29c33ce6c5bb

- Added method scanShebang to class Lexer. - TOK.Shebang is recognized by the token highlighter.
author aziz
date Wed, 15 Aug 2007 20:33:02 +0000
parents fa0b6f32c1ae
children ed4ef0173793
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;
312
fa0b6f32c1ae - Added Special to enum TOK.
aziz
parents: 309
diff changeset
29 case "parse":
fa0b6f32c1ae - Added Special to enum TOK.
aziz
parents: 309
diff changeset
30 if (args.length == 3)
fa0b6f32c1ae - Added Special to enum TOK.
aziz
parents: 309
diff changeset
31 parse(args[2]);
fa0b6f32c1ae - Added Special to enum TOK.
aziz
parents: 309
diff changeset
32 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
33 default:
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 }
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
36
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
37 void parse(string fileName)
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
38 {
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
39 auto sourceText = cast(char[]) std.file.read(fileName);
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
40 auto parser = new Parser(sourceText, fileName);
213
b0ebde88d2d4 - Added members trying, errorCount and prev (for debugging) to Parser.
aziz
parents: 112
diff changeset
41 parser.start();
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 303
diff changeset
42 auto root = parser.parseModule();
299
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 void print(Node[] decls, char[] indent)
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 249
diff changeset
45 {
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 249
diff changeset
46 foreach(decl; decls)
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 assert(decl !is null);
303
bc1112f7933d - Added keyword debug to some statements.
aziz
parents: 299
diff changeset
49 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
50 print(decl.children, indent ~ " ");
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 249
diff changeset
51 }
559d5d62e0c1 - Added checks for null before adding member to Node.children.
aziz
parents: 249
diff changeset
52 }
305
df237b3b5f09 - Added class Declarations.
aziz
parents: 303
diff changeset
53 print(root.children, "");
213
b0ebde88d2d4 - Added members trying, errorCount and prev (for debugging) to Parser.
aziz
parents: 112
diff changeset
54 foreach (error; parser.errors)
b0ebde88d2d4 - Added members trying, errorCount and prev (for debugging) to Parser.
aziz
parents: 112
diff changeset
55 {
b0ebde88d2d4 - Added members trying, errorCount and prev (for debugging) to Parser.
aziz
parents: 112
diff changeset
56 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
57 }
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
58 }
213
b0ebde88d2d4 - Added members trying, errorCount and prev (for debugging) to Parser.
aziz
parents: 112
diff changeset
59
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
60 char[] xml_escape(char[] text)
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 char[] result;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
63 foreach(c; text)
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
64 switch(c)
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
65 {
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
66 case '<': result ~= "&lt;"; break;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
67 case '>': result ~= "&gt;"; break;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
68 case '&': result ~= "&amp;"; break;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
69 default: result ~= c;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
70 }
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
71 return result;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
72 }
0
8ba2570de175 Initial import.
aziz
parents:
diff changeset
73
309
b4d842b0d2c7 - Added new files Settings.d, config.d and lang_en.d
aziz
parents: 308
diff changeset
74 void tokensToXML(string fileName)
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
75 {
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
76 auto sourceText = cast(char[]) std.file.read(fileName);
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
77 auto lx = new Lexer(sourceText, fileName);
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
78
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
79 auto token = lx.getTokens();
5
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
80 char* end = lx.text.ptr;
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
81
315
29c33ce6c5bb - Added method scanShebang to class Lexer.
aziz
parents: 312
diff changeset
82 writefln(`<?xml version="1.0"?>`\n
29c33ce6c5bb - Added method scanShebang to class Lexer.
aziz
parents: 312
diff changeset
83 `<?xml-stylesheet href="format.css" type="text/css"?>`\n
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
84 `<root>`);
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
85 if (lx.errors.length)
51
cadd2bfe686c - Displaying error messages in XML.
aziz
parents: 44
diff changeset
86 {
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
87 writefln("<compilerinfo>");
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
88 foreach (error; lx.errors)
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
89 {
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
90 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
91 }
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
92 writefln("</compilerinfo>");
51
cadd2bfe686c - Displaying error messages in XML.
aziz
parents: 44
diff changeset
93 }
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
94 writef(`<sourcetext>`);
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
95
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
96 // Traverse linked list and print tokens.
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
97 while (token.type != TOK.EOF)
4
92df59b1ec4a - Started implementation of scan().
aziz
parents: 3
diff changeset
98 {
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
99 token = token.next;
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 // Print whitespace between previous and current token.
5
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
102 if (end != token.start)
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
103 writef("%s", xml_escape(end[0 .. token.start - end]));
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
104
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
105 string srcText = xml_escape(token.srcText);
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
106
5
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
107 switch(token.type)
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
108 {
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
109 case TOK.Identifier:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
110 writef("<i>%s</i>", srcText);
5
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
111 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
112 case TOK.Comment:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
113 string c;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
114 switch (token.start[1])
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
115 {
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
116 case '/': c = "l"; break;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
117 case '*': c = "b"; break;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
118 case '+': c = "n"; break;
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
119 default:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
120 assert(0);
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
121 }
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
122 writef(`<c c="%s">%s</c>`, c, srcText);
5
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
123 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
124 case TOK.String:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
125 writef("<sl>%s</sl>", srcText);
9
5d6968cc751e - Parsing string and character literals now (rudimentary implementation.)
aziz
parents: 5
diff changeset
126 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
127 case TOK.CharLiteral, TOK.WCharLiteral, TOK.DCharLiteral:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
128 writef("<cl>%s</cl>", srcText);
9
5d6968cc751e - Parsing string and character literals now (rudimentary implementation.)
aziz
parents: 5
diff changeset
129 break;
308
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
130 case TOK.Assign, TOK.Equal,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
131 TOK.Less, TOK.Greater,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
132 TOK.LShiftAssign, TOK.LShift,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
133 TOK.RShiftAssign, TOK.RShift,
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
134 TOK.URShiftAssign, TOK.URShift,
308
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
135 TOK.OrAssign, TOK.OrBinary,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
136 TOK.AndAssign, TOK.AndBinary,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
137 TOK.PlusAssign, TOK.PlusPlus, TOK.Plus,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
138 TOK.MinusAssign, TOK.MinusMinus, TOK.Minus,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
139 TOK.DivAssign, TOK.Div,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
140 TOK.MulAssign, TOK.Mul,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
141 TOK.ModAssign, TOK.Mod,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
142 TOK.XorAssign, TOK.Xor,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
143 TOK.CatAssign,
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
144 TOK.Tilde,
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
145 TOK.Unordered,
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
146 TOK.UorE,
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
147 TOK.UorG,
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
148 TOK.UorGorE,
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
149 TOK.UorL,
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
150 TOK.UorLorE,
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
151 TOK.LorEorG:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
152 writef("<op>%s</op>", srcText);
14
cdf788d8bdaf - Parsing /= now.
aziz
parents: 10
diff changeset
153 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
154 case TOK.LorG:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
155 writef(`<op c="lg">&lt;&gt;</op>`);
39
69b940398d7b - Added unittest to test correct parsing of operator tokens.
aziz
parents: 35
diff changeset
156 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
157 case TOK.LessEqual:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
158 writef(`<op c="le">&lt;=</op>`);
39
69b940398d7b - Added unittest to test correct parsing of operator tokens.
aziz
parents: 35
diff changeset
159 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
160 case TOK.GreaterEqual:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
161 writef(`<op c="ge">&gt;=</op>`);
39
69b940398d7b - Added unittest to test correct parsing of operator tokens.
aziz
parents: 35
diff changeset
162 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
163 case TOK.AndLogical:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
164 writef(`<op c="aa">&amp;&amp;</op>`);
31
94f09f4e988e - Added struct for strings to Token with 'pf' = postfix.
aziz
parents: 30
diff changeset
165 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
166 case TOK.OrLogical:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
167 writef(`<op c="oo">||</op>`);
31
94f09f4e988e - Added struct for strings to Token with 'pf' = postfix.
aziz
parents: 30
diff changeset
168 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
169 case TOK.NotEqual:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
170 writef(`<op c="ne">!=</op>`);
44
5055947e0f98 - Specific operators and comments can be formatted with CSS now.
aziz
parents: 39
diff changeset
171 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
172 case TOK.Not:
307
5f6a173d4ad3 - Don't consider '\!' as an operator when it begins a template argument list.
aziz
parents: 306
diff changeset
173 // 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
174 // TODO: comments aren't skipped.
5f6a173d4ad3 - Don't consider '\!' as an operator when it begins a template argument list.
aziz
parents: 306
diff changeset
175 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
176 goto default;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
177 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
178 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
179 case TOK.Int32, TOK.Int64, TOK.Uint32, TOK.Uint64,
308
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
180 TOK.Float32, TOK.Float64, TOK.Float80,
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
181 TOK.Imaginary32, TOK.Imaginary64, TOK.Imaginary80:
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
182 writef("<n>%s</n>", srcText);
15
c70c028e47dd - Started implementation of lexing numbers.
aziz
parents: 14
diff changeset
183 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
184 case TOK.LParen, TOK.RParen, TOK.LBracket,
308
3b9fc1e72210 - Indented some cases. Removed case TOK.Catenate.
aziz
parents: 307
diff changeset
185 TOK.RBracket, TOK.LBrace, TOK.RBrace:
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
186 writef("<br>%s</br>", srcText);
20
d6adfbd7c513 - Added code for parsing braces.
aziz
parents: 17
diff changeset
187 break;
312
fa0b6f32c1ae - Added Special to enum TOK.
aziz
parents: 309
diff changeset
188 case TOK.Special:
fa0b6f32c1ae - Added Special to enum TOK.
aziz
parents: 309
diff changeset
189 writef("<st>%s</st>", srcText);
fa0b6f32c1ae - Added Special to enum TOK.
aziz
parents: 309
diff changeset
190 break;
315
29c33ce6c5bb - Added method scanShebang to class Lexer.
aziz
parents: 312
diff changeset
191 case TOK.Shebang:
29c33ce6c5bb - Added method scanShebang to class Lexer.
aziz
parents: 312
diff changeset
192 writef("<shebang>%s</shebang>", srcText);
29c33ce6c5bb - Added method scanShebang to class Lexer.
aziz
parents: 312
diff changeset
193 break;
306
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
194 default:
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
195 if (token.isKeyword())
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
196 writef("<k>%s</k>", srcText);
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
197 else
9c866aadcb5b - Moved code out of main() to separate functions.
aziz
parents: 305
diff changeset
198 writef("%s", srcText);
5
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
199 }
79b4e8848794 - Started writing XML generator.
aziz
parents: 4
diff changeset
200 end = token.end;
4
92df59b1ec4a - Started implementation of scan().
aziz
parents: 3
diff changeset
201 }
51
cadd2bfe686c - Displaying error messages in XML.
aziz
parents: 44
diff changeset
202 writef("\n</sourcetext>\n</root>");
0
8ba2570de175 Initial import.
aziz
parents:
diff changeset
203 }