Skip to content

Commit

Permalink
m-m-m/base#8: scanner API changes for unicode
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille committed Dec 25, 2024
1 parent 1fb7947 commit 0262828
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ private void parsePackage() {

consume();
String actualPkg = "";
char c = peek();
if ((c == 'p') && expect("package")) {
int cp = peek();
if ((cp == 'p') && expect("package")) {
skipWhile(CharFilter.WHITESPACE);
actualPkg = readUntil(';', true).trim();
}
Expand Down Expand Up @@ -668,24 +668,24 @@ private void applyCommentAndAnnotations(BaseElement element) {
private CodeTypeCategory parseCategory() {

consume();
char c = peek();
if (c == 'c') {
int cp = peek();
if (cp == 'c') {
if (expect("class")) {
return CodeTypeCategory.CLASS;
}
} else if (c == 'i') {
} else if (cp == 'i') {
if (expect("interface")) {
return CodeTypeCategory.INTERFACE;
}
} else if (c == 'e') {
} else if (cp == 'e') {
if (expect("enum")) {
return CodeTypeCategory.ENUMERAION;
}
} else if (c == 'r') {
} else if (cp == 'r') {
if (expect("record")) {
return CodeTypeCategory.RECORD;
}
} else if (c == '@') {
} else if (cp == '@') {
if (expect("@interface")) {
return CodeTypeCategory.ANNOTATION;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ public void consume() {

// clearConsumeState();
skipWhile(CharFilter.WHITESPACE);
char c = peek();
if (c == '/') { // comment or doc?
int cp = peek();
if (cp == '/') { // comment or doc?
next();
parseDocOrComment();
consume();
} else if (c == '@') { // annotation?
} else if (cp == '@') { // annotation?
next();
getElementComment();
parseAnnotations();
Expand Down Expand Up @@ -332,8 +332,8 @@ CodeExpression parseAssignmentValue() {
List<CodeExpression> expressions = null;
while (true) {
parseWhitespacesAndComments();
char c = peek();
if (CHAR_FILTER_OPERATOR.accept(c)) {
int cp = peek();
if (CHAR_FILTER_OPERATOR.accept(cp)) {
String operatorName = readWhile(CHAR_FILTER_OPERATOR);
CodeOperator nextOperator = BaseOperator.of(operatorName);
if (operator == null) {
Expand Down Expand Up @@ -431,14 +431,14 @@ private String getQualifiedName(String name) {

private void parseDocOrComment() {

char c = peek();
if (c == '/') {
int cp = peek();
if (cp == '/') {
String docLine = readLine(true);
this.comments.add(new BaseSingleLineComment(docLine));
} else if (c == '*') {
} else if (cp == '*') {
next();
c = peek();
if (c == '*') { // JavaDoc or regular comment
cp = peek();
if (cp == '*') { // JavaDoc or regular comment
next();
if (!this.javaDocLines.isEmpty()) {
LOG.warn("Duplicate JavaDoc in {}.", this.file);
Expand All @@ -451,7 +451,7 @@ private void parseDocOrComment() {
this.comments.add(comment);
}
} else {
LOG.warn("Illegal language: {} in {}.", "/" + c, this.file);
LOG.warn("Illegal language: {} in {}.", "/" + cp, this.file);
}
}

Expand All @@ -466,11 +466,11 @@ private void parseDocOrBlockComment(List<String> lines) {
}
while (true) {
skipWhile(CharFilter.WHITESPACE);
char c = peek();
if (c == '*') {
int cp = peek();
if (cp == '*') {
next();
c = peek();
if (c == '/') {
cp = peek();
if (cp == '/') {
next();
skipWhile(CharFilter.WHITESPACE);
return;
Expand Down Expand Up @@ -509,26 +509,26 @@ protected CodeModifiers parseModifiers(boolean inInterface) {
boolean found = true;
while (found) {
skipWhile(CharFilter.WHITESPACE);
char c = peek();
if (c == 'a') {
int cp = peek();
if (cp == 'a') {
found = parseModifierKeyword(modifiers, CodeModifiers.KEY_ABSTRACT);
} else if (c == 'd') {
} else if (cp == 'd') {
found = parseModifierKeyword(modifiers, CodeModifiers.KEY_DEFAULT);
} else if (c == 'n') {
} else if (cp == 'n') {
found = parseModifierKeyword(modifiers, CodeModifiers.KEY_NATIVE);
} else if (c == 'f') {
} else if (cp == 'f') {
found = parseModifierKeyword(modifiers, CodeModifiers.KEY_FINAL);
} else if (c == 'v') {
} else if (cp == 'v') {
found = parseModifierKeyword(modifiers, CodeModifiers.KEY_VOLATILE);
} else if (c == 's') {
} else if (cp == 's') {
found = parseModifierKeyword(modifiers, CodeModifiers.KEY_STATIC);
if (!found) {
found = parseModifierKeyword(modifiers, CodeModifiers.KEY_SYNCHRONIZED);
if (!found) {
found = parseModifierKeyword(modifiers, CodeModifiers.KEY_SYNCHRONIZED);
}
}
} else if (c == 't') {
} else if (cp == 't') {
found = parseModifierKeyword(modifiers, CodeModifiers.KEY_TRANSIENT);
} else {
found = false;
Expand Down

0 comments on commit 0262828

Please sign in to comment.