mirror of https://github.com/aamine/cbc
* net/loveruby/cflat/compiler/Compiler.java (dumpTokenList): specialToken handling was wrong. We should trace t.specialToken while it becomes null, then follow t.next.
* net/loveruby/cflat/parser/Parser.jj: write token name for special tokens. git-svn-id: file:///Users/aamine/c/gitwork/public/cbc/trunk@3864 1b9489fe-b721-0410-924e-b54b9192deb8
This commit is contained in:
parent
4bee7c8246
commit
f50dfa8add
|
|
@ -1,3 +1,12 @@
|
|||
Sun Feb 3 18:30:18 2008 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* net/loveruby/cflat/compiler/Compiler.java (dumpTokenList):
|
||||
specialToken handling was wrong. We should trace t.specialToken
|
||||
while it becomes null, then follow t.next.
|
||||
|
||||
* net/loveruby/cflat/parser/Parser.jj: write token name for
|
||||
special tokens.
|
||||
|
||||
Mon Jan 21 05:37:28 2008 Minero Aoki <aamine@loveruby.net>
|
||||
|
||||
* net/loveruby/cflat/compiler/Compiler.java: new command line
|
||||
|
|
|
|||
|
|
@ -217,22 +217,44 @@ public class Compiler {
|
|||
}
|
||||
|
||||
protected void dumpTokenList(Token t, PrintStream s) {
|
||||
while (t != null) {
|
||||
dumpTokenList(t.specialToken, s);
|
||||
for (; t != null; t = t.next) {
|
||||
if (t.specialToken != null) {
|
||||
dumpSpecialTokenList(t.specialToken, s);
|
||||
}
|
||||
dumpToken(t, s);
|
||||
t = t.next;
|
||||
}
|
||||
}
|
||||
|
||||
protected void dumpSpecialTokenList(Token tok, PrintStream s) {
|
||||
for (Token t = specialTokenHead(tok); t != null; t = t.next) {
|
||||
dumpToken(t, s);
|
||||
}
|
||||
}
|
||||
|
||||
protected Token specialTokenHead(Token tok) {
|
||||
Token t = tok;
|
||||
while (t.specialToken != null) {
|
||||
t = t.specialToken;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
static final protected int typeLen = 24;
|
||||
|
||||
protected void dumpToken(Token t, PrintStream s) {
|
||||
String type = ParserConstants.tokenImage[t.kind];
|
||||
s.print(type);
|
||||
for (int n = typeLen - type.length(); n > 0; n--) {
|
||||
ljustPrint(s, typeLen, tokenType(t));
|
||||
s.println(TextUtils.escapeString(t.image));
|
||||
}
|
||||
|
||||
protected String tokenType(Token t) {
|
||||
return ParserConstants.tokenImage[t.kind];
|
||||
}
|
||||
|
||||
protected void ljustPrint(PrintStream s, int width, String value) {
|
||||
s.print(value);
|
||||
for (int n = width - value.length(); n > 0; n--) {
|
||||
s.print(" ");
|
||||
}
|
||||
s.println(TextUtils.escapeString(t.image));
|
||||
}
|
||||
|
||||
protected AST parseFile(Options opts)
|
||||
|
|
|
|||
|
|
@ -270,20 +270,20 @@ PARSER_END(Parser)
|
|||
|
||||
// linear-white-spaces
|
||||
// #@@range/lex_spaces{
|
||||
SPECIAL_TOKEN: { <([" ","\t","\n","\r"])+> }
|
||||
SPECIAL_TOKEN: { <SPACES: ([" ","\t","\n","\r"])+> }
|
||||
// #@@}
|
||||
|
||||
// block comment
|
||||
// #@@range/lex_block_comment{
|
||||
MORE: { "/*" : IN_BLOCK_COMMENT }
|
||||
MORE: { <"/*"> : IN_BLOCK_COMMENT }
|
||||
<IN_BLOCK_COMMENT> MORE: { <~[]> }
|
||||
<IN_BLOCK_COMMENT> SPECIAL_TOKEN: { "*/" : DEFAULT }
|
||||
<IN_BLOCK_COMMENT> SPECIAL_TOKEN: { <BLOCK_COMMENT: "*/"> : DEFAULT }
|
||||
// #@@}
|
||||
|
||||
// line comment
|
||||
// #@@range/lex_line_comment{
|
||||
SPECIAL_TOKEN: {
|
||||
<"//" (~["\n","\r"])* ("\n" | "\r\n" | "\r")?>
|
||||
<LINE_COMMENT: "//" (~["\n","\r"])* ("\n" | "\r\n" | "\r")?>
|
||||
}
|
||||
// #@@}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue