Mercurial > projects > dil
changeset 312:fa0b6f32c1ae
- Added Special to enum TOK.
- Added special tokens to keyword list.
- Added case T.Special for parsing SpecialTokenExpression.
author | aziz |
---|---|
date | Wed, 15 Aug 2007 19:19:00 +0000 |
parents | 6543ce34a4e0 |
children | 1c1adededd8f |
files | trunk/src/Expressions.d trunk/src/Keywords.d trunk/src/Parser.d trunk/src/SyntaxTree.d trunk/src/Token.d trunk/src/format.css trunk/src/main.d |
diffstat | 7 files changed, 49 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/Expressions.d Wed Aug 15 17:37:03 2007 +0000 +++ b/trunk/src/Expressions.d Wed Aug 15 19:19:00 2007 +0000 @@ -579,6 +579,17 @@ this.identifier = identifier; } } + +class SpecialTokenExpression : Expression +{ + Token* special; + this(Token* special) + { + mixin(set_kind); + this.special = special; + } +} + /* class IdentifierListExpression : Expression {
--- a/trunk/src/Keywords.d Wed Aug 15 17:37:03 2007 +0000 +++ b/trunk/src/Keywords.d Wed Aug 15 19:19:00 2007 +0000 @@ -105,5 +105,13 @@ {TOK.Volatile, "volatile"}, {TOK.Wchar, "wchar"}, {TOK.While, "while"}, - {TOK.With, "with"} + {TOK.With, "with"}, + // Special tokens: + {TOK.Special, "__FILE__"}, + {TOK.Special, "__LINE__"}, + {TOK.Special, "__DATE__"}, + {TOK.Special, "__TIME__"}, + {TOK.Special, "__TIMESTAMP__"}, + {TOK.Special, "__VENDOR__"}, + {TOK.Special, "__VERSION__"}, ];
--- a/trunk/src/Parser.d Wed Aug 15 17:37:03 2007 +0000 +++ b/trunk/src/Parser.d Wed Aug 15 19:19:00 2007 +0000 @@ -1759,10 +1759,12 @@ Statement parseNoScopeOrEmptyStatement() { if (token.type == T.Semicolon) + { nT(); + return new EmptyStatement(); + } else return parseNoScopeStatement(); - return null; } Statement parseAttributeStatement() @@ -3545,6 +3547,10 @@ e = new TraitsExpression(id, args); break; } + case T.Special: + e = new SpecialTokenExpression(token); + nT(); + break; default: // TODO: issue error msg. error(MID.ExpectedButFound, "Expression", token.srcText);
--- a/trunk/src/SyntaxTree.d Wed Aug 15 17:37:03 2007 +0000 +++ b/trunk/src/SyntaxTree.d Wed Aug 15 19:19:00 2007 +0000 @@ -149,6 +149,7 @@ SliceExpression, PrimaryExpressio, IdentifierExpression, + SpecialTokenExpression, DotListExpression, TemplateInstanceExpression, ThisExpression,
--- a/trunk/src/Token.d Wed Aug 15 17:37:03 2007 +0000 +++ b/trunk/src/Token.d Wed Aug 15 19:19:00 2007 +0000 @@ -19,6 +19,7 @@ Identifier, Comment, String, + Special, CharLiteral, WCharLiteral, DCharLiteral, // Numbers @@ -169,6 +170,7 @@ "Identifier", "Comment", "String", + "Special", "CharLiteral", "WCharLiteral", "DCharLiteral", "Int32", "Int64", "Uint32", "Uint64",
--- a/trunk/src/format.css Wed Aug 15 17:37:03 2007 +0000 +++ b/trunk/src/format.css Wed Aug 15 19:19:00 2007 +0000 @@ -12,15 +12,27 @@ margin: 1em; } compilerinfo error { display: block; } +/* Number */ n { color: teal; } +/* Keyword */ k { color: darkblue; font-weight: bold; } +/* Line and block comments */ c[c=l], c[c=b] { color: green; } +/* Nested comments */ c[c=n] { color: darkgreen; } +/* Identifier */ i { color: black; } +/* String literal */ sl { color: red; } +/* Character literal */ cl { color: purple; } +/* Operator */ op { color: royalblue; } +/* All bracket types */ br { color: orange; } +/* Special tokens */ +st { color: green; font-weight: bold; } +/* Particular operators */ op[c=aa] { content: "and"; } /*&& ∧*/ op[c=oo] { content: "or"; } /*|| ∨*/ op[c=n] { content: "¬"; } /*!*/
--- a/trunk/src/main.d Wed Aug 15 17:37:03 2007 +0000 +++ b/trunk/src/main.d Wed Aug 15 19:19:00 2007 +0000 @@ -26,6 +26,10 @@ if (args.length == 3) tokensToXML(args[2]); break; + case "parse": + if (args.length == 3) + parse(args[2]); + break; default: } } @@ -181,6 +185,9 @@ TOK.RBracket, TOK.LBrace, TOK.RBrace: writef("<br>%s</br>", srcText); break; + case TOK.Special: + writef("<st>%s</st>", srcText); + break; default: if (token.isKeyword()) writef("<k>%s</k>", srcText);