Repository navigation
Semicolon rule #28
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
Merged
Merged
Semicolon rule #28
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c1fdcfd
Add basic functional test case for semicolon rule
adityatrivedi a0bf244
Add checks for semicolon terminated statements
adityatrivedi 318f2f0
Merge branch 'master' into at-semicolon-rule
adityatrivedi 5b0651f
Fix grammar for ';' bugs
adityatrivedi b5047fd
Update pylint rc to ignore TODOs
adityatrivedi 249b0eb
Test for more ';' cases
adityatrivedi 954247e
Update lexer, parser, listener for ';'
adityatrivedi 068f750
Add enum special case for ';' test
adityatrivedi 6dad509
Update grammar for UnionStyleEnumMember
adityatrivedi d263185
Fix grammar for protcolMemberDeclaration ';' error
adityatrivedi 1ccf945
Fix ';' grammar bug for variable declarations
adityatrivedi dcf073b
Add additional functional tests for ';' terminated
adityatrivedi de42425
Pass line and column stop info to printer
adityatrivedi d1ac383
Increase column value for semicolon rule by 1
alykhank 8d4d83e
Create namedtuple for Location type
alykhank 583ea8e
Use Location tuple in printer
adityatrivedi fbb47f5
Add additional tests for printer
adityatrivedi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| import Foundation; | ||
|
|
||
| println("Hello, World!") | ||
|
|
||
| enum CompassPoint { | ||
| case North; | ||
| case South; | ||
| case East; | ||
| case West; | ||
| }; | ||
|
|
||
| protocol SomeProtocol { | ||
| var fullName: String { get }; | ||
| func demo(); | ||
| func dummy(f: Int); | ||
| func foo(bar: String, baz: Double); | ||
| }; | ||
|
|
||
| extension SomeType { | ||
| // new functionality to add to SomeType goes here | ||
| }; | ||
|
|
||
| struct DemoStruct { | ||
| var x: String; | ||
|
|
||
| func test() { | ||
| // while loop test | ||
| while (true) | ||
| { | ||
| }; | ||
|
|
||
| // for loop | ||
| for ; ; { | ||
|
|
||
| }; | ||
|
|
||
| // do while | ||
| do { | ||
|
|
||
| } while (true); | ||
| }; | ||
| }; | ||
|
|
||
| // Class examples | ||
|
|
||
| class lowerCamelCase { | ||
| var x: String = "hello"; | ||
| let b = 2; | ||
|
|
||
| func demo() | ||
| { | ||
| for var x = 0; ; { | ||
| print(x); | ||
| }; | ||
|
|
||
| if temperatureInFahrenheit <= 32 { | ||
| println("It's very cold. Consider wearing a scarf."); | ||
| } else if temperatureInFahrenheit >= 86 { | ||
| println("It's really warm. Don't forget to wear sunscreen."); | ||
| } else { | ||
| println("It's not that cold. Wear a t-shirt."); | ||
| } | ||
| }; | ||
| }; | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,23 @@ | ||
| import os | ||
|
|
||
| from tailor.types.location import Location | ||
|
|
||
|
|
||
| class Printer: | ||
|
|
||
| def __init__(self, filepath): | ||
| self.__filepath = os.path.abspath(filepath) | ||
|
|
||
| def warn(self, ctx, warn_msg): | ||
| self.__print(ctx, 'warning', warn_msg) | ||
| def warn(self, warn_msg, ctx=None, loc=Location(1, 1)): | ||
| self.__print('warning', warn_msg, ctx, loc) | ||
|
|
||
| def error(self, ctx, err_msg): | ||
| self.__print(ctx, 'error', err_msg) | ||
| def error(self, err_msg, ctx=None, loc=Location(1, 1)): | ||
| self.__print('error', err_msg, ctx, loc) | ||
|
|
||
| def __print(self, ctx, classification, message): | ||
| print(self.__filepath + ':' + str(ctx.start.line) + ':' + | ||
| str(ctx.start.column) + ': ' + classification + ': ' + message) | ||
| def __print(self, classification, msg, ctx, loc): | ||
| if ctx is not None: | ||
| print(self.__filepath + ':' + str(ctx.start.line) + ':' + | ||
| str(ctx.start.column) + ': ' + classification + ': ' + msg) | ||
| else: | ||
| print(self.__filepath + ':' + str(loc.line) + ':' + | ||
| str(loc.column) + ': ' + classification + ': ' + msg) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Currently error messages display the
ctx.start.lineandctx.start.column, but for this type of rule (that checks for statement-terminating punctuation), the messages should use thectx.stop.lineandctx.stop.column. A parameter (that potentially defaults toctx.start) could be used to modifyerror()for this use case.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.
Done.