Comments (3)
And one more: token.getText() for "1." number returns "1" instead of "1." or "1.0".
from jcpp.
I'm not sure if this is the same issue, but I encountered float problems as well.
Consider the following string:
ANGLE = 0.6108652381980154;
After preprocessing, my lexer receives the following string:
ANGLE = 06108652381980154;
After spending the whole morning researching this issue, I came up with the following fix.
One of the problems is that you consider every value that starts with a zero as either an octal int or a hexadecimal value (and not a float). I fixed this by changing the part at line 826 in LexerSource.cpp (the function token) into this:
case '0':
/* decimal, octal or hex */
d = read();
if (d == 'x' || d == 'X')
tok = number_hex((char)d);
else if(d == '.')
{
unread(d);
unread(c);
tok = number_decimal();
}
else{
unread(d);
tok = number_octal();
}
break;
Secondly, you forgot to add a '.' to your stringbuilder with the name "text" in the function number_decimal. This is the fixed function:
private Token number_decimal()
throws IOException,
LexerException {
StringBuilder text = new StringBuilder();
String integer = _number_part(text, 10);
NumericValue value = new NumericValue(10, integer);
int d = read();
if (d == '.') {
text.append('.');
String fraction = _number_part(text, 10);
value.setFractionalPart(fraction);
d = read();
}
if (d == 'E' || d == 'e') {
String exponent = _number_part(text, 10);
value.setExponent(exponent);
d = read();
}
// XXX Make sure it's got enough parts
return _number_suffix(text, value, d);
}
from jcpp.
Same bug existed for exponents. Fixed in github, will make 1.4.1. Thank you.
from jcpp.
Related Issues (20)
- NullPointerException when #endif is missing HOT 2
- 0x is not a legal hex constant
- Handle framework includes properly HOT 3
- Absolute paths in includes HOT 11
- Empty variadic arguments HOT 1
- ``, ## VA_ARGS'' should remove the comma, if the variadic argument is empty. HOT 5
- Whitespace used in token pasting HOT 5
- pragma() should use source_token() not token()
- Re-check multiline comment whitespace preservation HOT 1
- Line number mismatch after pop_source() HOT 1
- Fix unit test suite on windows
- Any tutorials on this project? HOT 5
- Stripping line comments HOT 1
- Support extension of preprocessor HOT 1
- ClassCastException with character constants in expressions HOT 1
- Please publish module names HOT 2
- skip empty LN with # instead of filling LN HOT 1
- Unable to run Main class via Gradle
- Link to coverage report on README.md is broken
- Main doesn't return nonzero exit code on failure. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jcpp.