Browse Source

support non us-ascii identifiers (JIRA May20,2005)


git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@173 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
tags/rel_3_17_1_ga
chiba 19 years ago
parent
commit
d30bc13c09
3 changed files with 19 additions and 9 deletions
  1. 2
    2
      Readme.html
  2. 15
    5
      src/main/javassist/compiler/Lex.java
  3. 2
    2
      src/main/javassist/compiler/SyntaxError.java

+ 2
- 2
Readme.html View File

@@ -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.

<p><br>


+ 15
- 5
src/main/javassist/compiler/Lex.java View File

@@ -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)

+ 2
- 2
src/main/javassist/compiler/SyntaxError.java View File

@@ -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);
}
}

Loading…
Cancel
Save