Skip to content
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

Merged
merged 2 commits into from
Dec 17, 2020

Conversation

TwitchBronBron
Copy link
Member

According to the BrightScript documentation, a % can be appended to an integer literal to enforce that it becomes an integer type.

image

Currently bsc shows a syntax error on that trailing %, so this PR fixes that.

Fixes #233

@@ -792,6 +792,12 @@ describe('lexer', () => {
});

describe('long integer literals', () => {
it('respects \'&\' suffix', () => {
Copy link
Member Author

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.

}

if (designator === '!') {
} else if (designator === '!') {
Copy link
Member Author

Choose a reason for hiding this comment

The 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 return statements and making it easier to follow the flow.

this.advance();
this.addToken(TokenKind.LongIntegerLiteral);

} else if (designator === '%') {
Copy link
Member Author

Choose a reason for hiding this comment

The 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 %

@TwitchBronBron TwitchBronBron merged commit e9e95fc into master Dec 17, 2020
@TwitchBronBron TwitchBronBron deleted the type-declaration-character-after-literal branch December 17, 2020 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected character '%' (char code 37)
2 participants