Skip to content

Commit

Permalink
SCL-3270 : Added support for += operator
Browse files Browse the repository at this point in the history
Added support for +=, -=, /= and *= operators, and created JUnit tests for them.
  • Loading branch information
sebastianwandel committed Jan 4, 2021
1 parent 9d9e450 commit 5cdab2c
Show file tree
Hide file tree
Showing 16 changed files with 87,686 additions and 83,445 deletions.
9 changes: 8 additions & 1 deletion src/com/joanju/proparse/BaseTokenTypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1229,4 +1229,11 @@ PACKAGEPROTECTED=1231
PACKAGEPRIVATE=1232
EVENT_HANDLER=1233
EVENT_HANDLER_CONTEXT=1234
Last_Token_Number=1235
PLUS_EQUAL = 1235
MINUS_EQUAL = 1236
DIVIDE_EQUAL = 1237
MULTIPLY_EQUAL = 1238
TRUE = 1239
FALSE = 1240
NULL = 1241
Last_Token_Number = 1242
31 changes: 28 additions & 3 deletions src/com/joanju/proparse/Lexer.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ ProToken nextToken() throws IOException {
// slash (division) can only be followed by whitespace or '('
// ...that's what I found empirically, anyway. (jag 2003/05/09)
return makeToken(SLASH);
} else if (currChar=='=') {
append();
getChar();
return makeToken(DIVIDE_EQUAL);
} else {
append();
getChar();
Expand Down Expand Up @@ -178,7 +182,14 @@ ProToken nextToken() throws IOException {
return makeToken(SEMI);
case '*':
getChar();
return makeToken(STAR);
if(currChar == '=') {
append();
getChar();
return makeToken(MULTIPLY_EQUAL);
}
else {
return makeToken(STAR);
}
case '?':
getChar();
return makeToken(UNKNOWNVALUE);
Expand Down Expand Up @@ -229,10 +240,24 @@ ProToken nextToken() throws IOException {

case '+':
getChar();
return plusMinusStart(PLUS);
if(currChar == '=') {
append();
getChar();
return makeToken(PLUS_EQUAL);
}
else {
return plusMinusStart(PLUS);
}
case '-':
getChar();
return plusMinusStart(MINUS);
if(currChar == '=') {
append();
getChar();
return makeToken(MINUS_EQUAL);
}
else {
return plusMinusStart(MINUS);
}

case '#':
case '|':
Expand Down
4 changes: 4 additions & 0 deletions src/com/joanju/proparse/NodeTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ public void writeXferSchema(DataXferStream out) throws IOException {}
add(DISPLAY, 4, "display", TI.KEYWORD | TI.RESERVED);
add(DISTINCT, 8, "distinct", TI.KEYWORD | TI.RESERVED);
add(DIVIDE, 0, "", TI.NO_FLAGS);
add(DIVIDE_EQUAL, 2, "/=", TI.NO_FLAGS);
add(DO, 2, "do", TI.KEYWORD | TI.RESERVED);
add(DOS, 3, "dos", TI.KEYWORD | TI.RESERVED);
add(DOT_COMMENT, 0, "", TI.NO_FLAGS);
Expand Down Expand Up @@ -969,6 +970,7 @@ public void writeXferSchema(DataXferStream out) throws IOException {}
add(MINIMUM, 3, "minimum", TI.KEYWORD | TI.MAY_BE_REGULAR_FUNC);
add(MINSIZE, 8, "min-size", TI.KEYWORD);
add(MINUS, 0, "", TI.NO_FLAGS);
add(MINUS_EQUAL, 2, "-=", TI.NO_FLAGS);
add(MINVALUE, 7, "min-value", TI.KEYWORD);
add(MODULO, 3, "modulo", TI.KEYWORD);
add(MONTH, 5, "month", TI.KEYWORD | TI.MAY_BE_REGULAR_FUNC);
Expand All @@ -979,6 +981,7 @@ public void writeXferSchema(DataXferStream out) throws IOException {}
add(MULTIPLE, 8, "multiple", TI.KEYWORD);
add(MULTIPLEKEY, 12, "multiple-key", TI.KEYWORD);
add(MULTIPLY, 0, "", TI.NO_FLAGS);
add(MULTIPLY_EQUAL, 2, "*=", TI.NO_FLAGS);
add(MUSTEXIST, 10, "must-exist", TI.KEYWORD);
add(Method_param_list, 0, "", TI.NO_FLAGS);
add(Method_parameter, 0, "", TI.NO_FLAGS);
Expand Down Expand Up @@ -1122,6 +1125,7 @@ public void writeXferSchema(DataXferStream out) throws IOException {}
add(PINNABLE, 8, "pinnable", TI.KEYWORD);
add(PIPE, 0, "", TI.NO_FLAGS);
add(PLUS, 0, "", TI.NO_FLAGS);
add(PLUS_EQUAL, 2, "+=", TI.NO_FLAGS);
add(PLUSMINUSSTART, 0, "", TI.NO_FLAGS);
add(PORTRAIT, 8, "portrait", TI.KEYWORD);
add(POSITION, 8, "position", TI.KEYWORD);
Expand Down
Loading

0 comments on commit 5cdab2c

Please sign in to comment.