Skip to content

Commit 0111e58

Browse files
committed
Add support for ISO-8859-1 characters
- Add support for accents and other ISO-8859-1 characters to the antlr parser - Close RPTools#30
1 parent 6751bce commit 0111e58

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ repositories {
3636

3737
dependencies {
3838
implementation 'rhino:js:1.6R5'
39-
implementation 'antlr:antlr:2.7.6'
39+
implementation 'antlr:antlr:2.7.7'
4040
testImplementation group: 'junit', name: 'junit', version: '4.11'
4141
antlr 'antlr:antlr:2.7.7'
4242
}

src/main/antlr/net/rptools/parser/expression.g

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class ExpressionLexer extends Lexer;
161161

162162
options {
163163
k=3; // needed for newline junk
164-
charVocabulary='\u0000'..'\u007F'; // allow ascii
164+
charVocabulary='\u0000'..'\u00FF'; // allow ISO 8859-1
165165
}
166166

167167
ASSIGN : '=' ;

src/main/java/net/rptools/parser/Parser.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import antlr.RecognitionException;
1919
import antlr.TokenStreamException;
2020
import java.io.ByteArrayInputStream;
21+
import java.nio.charset.StandardCharsets;
2122
import java.util.ArrayList;
2223
import java.util.Collection;
2324
import java.util.List;
@@ -248,7 +249,8 @@ public Expression parseExpression(String expression) throws ParserException {
248249
try {
249250
String s = applyTransforms(expression);
250251

251-
ExpressionLexer lexer = new ExpressionLexer(new ByteArrayInputStream(s.getBytes()));
252+
ExpressionLexer lexer =
253+
new ExpressionLexer(new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1)));
252254
ExpressionParser parser = new ExpressionParser(lexer);
253255

254256
parser.expression();

0 commit comments

Comments
 (0)