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

Grammar Dart.g "part of" new rule to recognize some files #45916

Closed
pedro-mimoso opened this issue May 5, 2021 · 6 comments
Closed

Grammar Dart.g "part of" new rule to recognize some files #45916

pedro-mimoso opened this issue May 5, 2021 · 6 comments
Labels
area-specification (deprecated) Deprecated: use area-language and a language- label. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@pedro-mimoso
Copy link

Hello, I'm doing a Masters Thesis that involves using a Dart grammar, and i think this one is the best so far.

If you are interested i did a clone of various projects of dart and analyzed how the accuracy of the grammar was in those projects.

I started using it in version 0.4 with antlr4, but now i saw that it had some changes and i did the same tests again and i saw some really great improvements in accuracy.

However, i did need to add some rules to the grammar, because "part of" is not recognized.

part of cobblestone;

It accepts a uri instead of cobblestone for example.

@pedro-mimoso
Copy link
Author

I have no permissions to do a push from a local branch i created to do the pull request unfortunately

@eernstg eernstg added area-specification (deprecated) Deprecated: use area-language and a language- label. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels May 5, 2021
@eernstg
Copy link
Member

eernstg commented May 5, 2021

Thanks! That's a missing update; it is handled in https://dart-review.googlesource.com/c/sdk/+/198400.

@pedro-mimoso
Copy link
Author

pedro-mimoso commented May 11, 2021

@eernstg I checked the update, but the rule of the parser "partHeader" is not being called. Regards Pedro Mimoso Silva.

@eernstg
Copy link
Member

eernstg commented May 12, 2021

@pedro-mimoso — The grammar rule partHeader is used in the grammar rule partDeclaration, so it would be used if we invoke partDeclaration() in a similar way as libraryDefinition() is invoked in parseLibrary. So SpecParser.java will not call it currently, and the spec parser cannot parse a part file.

However, the only thing which is not tested because of this fact is the partHeader rule itself, because topLevelDefinition is tested all the time from libraryDefinition. So I considered that to be a minor problem.

(SpecParser.java is indeed a very thin and not very capable wrapper around Dart.g. The main motivation for having the spec parser in the first place is that it can confirm or reject the assumption that the grammar rules in the specification will actually allow us to parse Dart code that the analyzer/compilers accept, so it just needs to be able to run on a lot of Dart source code. That is possible even though it won't parse any part files.)

Are you trying to use SpecParser.java to parse Dart code in order to achieve some other goal?

@pedro-mimoso
Copy link
Author

@eernstg at this moment i'm using only the Grammar, Dart.g to test with ANTLR grun command if it parses projects extracted from github, so i can see the accuracy for each project. i Hva e a script in python that runs the command "grun" for each file of the project by passing the "libraryDefinition" rule as the first rule of the Grammar. So in this case since partHeader is never called in the Grammar itself, files who use "part of" will give an error. But since the main objective of this Grammar is not the same of mine there is no need to change :). I just made a quick adjustment and it parses those files

@eernstg
Copy link
Member

eernstg commented May 14, 2021

Very good, thanks!

eernstg added a commit to dart-lang/language that referenced this issue May 19, 2021
Tiny bug fix, cf. dart-lang/sdk#45916:

The specification currently allows for a part of directive where the enclosing library is specified using <identifier> ('.' <identifier>)*, but not using <uri>. The latter is intended to work, and it has been working in all tools for a while, and this PR just brings the specification up to date.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-specification (deprecated) Deprecated: use area-language and a language- label. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

2 participants