-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support integer type declaration char #254
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -629,13 +629,10 @@ export class Lexer { | |
if (numberOfDigits >= 10 && designator !== '&') { | ||
// numeric literals over 10 digits with no type designator are implicitly Doubles | ||
this.addToken(TokenKind.DoubleLiteral); | ||
return; | ||
} else if (designator === '#') { | ||
// numeric literals ending with "#" are forced to Doubles | ||
this.advance(); | ||
asString = this.source.slice(this.start, this.current); | ||
this.addToken(TokenKind.DoubleLiteral); | ||
return; | ||
} else if (designator === 'd') { | ||
// literals that use "D" as the exponent are also automatic Doubles | ||
|
||
|
@@ -655,15 +652,10 @@ export class Lexer { | |
// replace the exponential marker with a JavaScript-friendly "e" | ||
asString = this.source.slice(this.start, this.current).replace(/[dD]/, 'e'); | ||
this.addToken(TokenKind.DoubleLiteral); | ||
return; | ||
} | ||
|
||
if (designator === '!') { | ||
} else if (designator === '!') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I combined several separate if statements into one continuous if...else if...else if... block. This cleaned up the code by removing several |
||
// numeric literals ending with "!" are forced to Floats | ||
this.advance(); | ||
asString = this.source.slice(this.start, this.current); | ||
this.addToken(TokenKind.FloatLiteral); | ||
return; | ||
} else if (designator === 'e') { | ||
// literals that use "E" as the exponent are also automatic Floats | ||
|
||
|
@@ -680,21 +672,18 @@ export class Lexer { | |
this.advance(); | ||
} | ||
|
||
asString = this.source.slice(this.start, this.current); | ||
this.addToken(TokenKind.FloatLiteral); | ||
return; | ||
} else if (containsDecimal) { | ||
// anything with a decimal but without matching Double rules is a Float | ||
this.addToken(TokenKind.FloatLiteral); | ||
return; | ||
} | ||
|
||
if (designator === '&') { | ||
} else if (designator === '&') { | ||
// numeric literals ending with "&" are forced to LongIntegers | ||
asString = this.source.slice(this.start, this.current); | ||
this.advance(); | ||
this.addToken(TokenKind.LongIntegerLiteral); | ||
|
||
} else if (designator === '%') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the core of the change. we just needed a separate if block for handling |
||
//numeric literals ending with "%" are forced to Integer | ||
this.advance(); | ||
this.addToken(TokenKind.IntegerLiteral); | ||
} else { | ||
// otherwise, it's a regular integer | ||
this.addToken(TokenKind.IntegerLiteral); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly impacted by this code, but the test for this was missing so I added it.