aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2005-06-07 18:55:17 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2005-06-07 18:55:17 +0000
commitd30bc13c09ed8408aae06f17666d5cd765124d1f (patch)
tree1979c9a69398e27f5f9cb0fad2c5158827e277e3 /src/main/javassist
parent2c834425c98ad18bb10d01ee7263f13d8948f13d (diff)
downloadjavassist-d30bc13c09ed8408aae06f17666d5cd765124d1f.tar.gz
javassist-d30bc13c09ed8408aae06f17666d5cd765124d1f.zip
support non us-ascii identifiers (JIRA May20,2005)
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@173 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist')
-rw-r--r--src/main/javassist/compiler/Lex.java20
-rw-r--r--src/main/javassist/compiler/SyntaxError.java4
2 files changed, 17 insertions, 7 deletions
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);
}
}