diff options
author | Shevek <[email protected]> | 2017-05-02 00:26:44 -0700 |
---|---|---|
committer | Shevek <[email protected]> | 2017-05-02 00:26:44 -0700 |
commit | da16a8e409ea51b3d17edb0be6f22e8d5530219e (patch) | |
tree | 5688717ad1772684dc274dc6c06a2533ca9de94e /src/main/java/org | |
parent | 36432e516e199b5a0602aba6e1a8b97cb5d72777 (diff) |
Fix #34.
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/anarres/cpp/Preprocessor.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main/java/org/anarres/cpp/Preprocessor.java b/src/main/java/org/anarres/cpp/Preprocessor.java index 2bbea4e..5b07824 100644 --- a/src/main/java/org/anarres/cpp/Preprocessor.java +++ b/src/main/java/org/anarres/cpp/Preprocessor.java @@ -1559,6 +1559,16 @@ public class Preprocessor implements Closeable { } } + private int expr_char(Token token) { + Object value = token.getValue(); + if (value instanceof Character) + return ((Character) value).charValue(); + String text = String.valueOf(value); + if (text.length() == 0) + return 0; + return text.charAt(0); + } + private long expr(int priority) throws IOException, LexerException { @@ -1595,7 +1605,7 @@ public class Preprocessor implements Closeable { lhs = value.longValue(); break; case CHARACTER: - lhs = ((Character) tok.getValue()).charValue(); + lhs = expr_char(tok); break; case IDENTIFIER: if (warnings.contains(Warning.UNDEF)) |