From: chiba Date: Tue, 7 Jun 2005 18:55:17 +0000 (+0000) Subject: support non us-ascii identifiers (JIRA May20,2005) X-Git-Tag: rel_3_17_1_ga~449 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d30bc13c09ed8408aae06f17666d5cd765124d1f;p=javassist.git support non us-ascii identifiers (JIRA May20,2005) git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@173 30ef5769-5b8d-40dd-aea6-55b5d6557bb3 --- diff --git a/Readme.html b/Readme.html index 913f8f84..63aa0094 100644 --- a/Readme.html +++ b/Readme.html @@ -583,8 +583,8 @@ Denis Taye, Colin Sampaleanu, Robert Bialek, Asato Shimotaki, Howard Lewis Ship, Richard Jones, Marjan Sterjev, Bruce McDonald, Mark Brennan, Vlad Skarzhevskyy, Brett Randall, Tsuyoshi Murakami, Nathan Meyers, Yoshiyuki Usui -Yutaka Sunaga, Arjan van der Meer, and Bruce Eckel -for their contributions. +Yutaka Sunaga, Arjan van der Meer, Bruce Eckel, Guillaume Pothier, +and Kumar Matcha for their contributions.


diff --git a/src/main/javassist/compiler/Lex.java b/src/main/javassist/compiler/Lex.java index fcd2d4d7..3f555332 100644 --- a/src/main/javassist/compiler/Lex.java +++ b/src/main/javassist/compiler/Lex.java @@ -133,8 +133,7 @@ public class Lex implements TokenId { return readSeparator('.'); } } - else if ('A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '_' - || c == '$') + else if (Character.isJavaIdentifierStart((char)c)) return readIdentifier(c, token); else return readSeparator(c); @@ -434,8 +433,7 @@ public class Lex implements TokenId { do { tbuf.append((char)c); c = getc(); - } while ('A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' || c == '_' - || c == '$' || '0' <= c && c <= '9'); + } while (Character.isJavaIdentifierPart((char)c)); ungetc(c); @@ -497,7 +495,7 @@ public class Lex implements TokenId { ktable.append("return", RETURN); ktable.append("short", SHORT); ktable.append("static", STATIC); - ktable.append("strict", STRICT); + ktable.append("strictfp", STRICT); ktable.append("super", SUPER); ktable.append("switch", SWITCH); ktable.append("synchronized", SYNCHRONIZED); @@ -525,6 +523,18 @@ public class Lex implements TokenId { lastChar = c; } + public String getTextAround() { + int begin = position - 10; + if (begin < 0) + begin = 0; + + int end = position + 10; + if (end > maxlen) + end = maxlen; + + return input.substring(begin, end); + } + private int getc() { if (lastChar < 0) if (position < maxlen) diff --git a/src/main/javassist/compiler/SyntaxError.java b/src/main/javassist/compiler/SyntaxError.java index 2e4f1e0e..bdf6edc5 100644 --- a/src/main/javassist/compiler/SyntaxError.java +++ b/src/main/javassist/compiler/SyntaxError.java @@ -16,7 +16,7 @@ package javassist.compiler; public class SyntaxError extends CompileError { - public SyntaxError(Lex l) { - super("syntax error", l); + public SyntaxError(Lex lexer) { + super("syntax error near \"" + lexer.getTextAround() + "\"", lexer); } }