question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use annotators instead of duplicating grammar rules

See original GitHub issue

In out RustParser.bnf file, there’s a pattern repeated thrice, for function, constant and type_alias.

A fake rule is defined to describe a single PSI element, and then a number of implementations (elementType = bla-bla-bla) of this rules are provide. The goal of this implementations is to enforce small syntactic differences. For example, top level functions always have body, but functions in interfaces can just end in ;.

A better way to handle this is to have exactly one non fake rule in .bnf and write a custom annotator which would say something like “top level functions must have a body, change ; to {}?”. See, how this is done in Kotlin: if you write override fun foo() at the top level, the PSI will containg a FUN, which would be annotated with two errors (an extra override and a missing body).

So this issue is exactly about removing special casing in the parser and writing an annotator. The best place to start is constant, then type_alias. function might prove to be tricky, because different functions have different grammar for parameters (I hate this). It might be useful to look at the Kotlin’s annotator!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
alygincommented, Jan 10, 2017

No progress so far, unfortunately. The plan was to finish the simple duplication errors (done), then gain the understanding of all the parameters variety while finishing this issue and after that implement parameter names duplication detection.

So the parameters + functions refactoring is the next in my todo-list, but I can’t make promises on how long it will take. If this work hampers the progress of something else, I can pass the baton back to you. Otherwise, I’ll be glad to try to finish this off.

1reaction
alygincommented, Jan 5, 2017

Okay, I’ll tackle it. Though, that might take time, such kind of gymnastics is new for me 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Automatic annotation of error types for grammatical error ...
In this thesis, I develop a system to automatically annotate parallel original and corrected sentence pairs with explicit edits and error types. In...
Read more >
Annotating Errors in Student Texts: First Experiences and ...
In this work we provide an added layer of hu- man annotation on top of UCSW. In this layer we correct errors due...
Read more >
Natural Language Annotation for Machine Learning [Book]
Most linguists view grammar as itself consisting of distinct modules or systems, either by cognitive design or for descriptive convenience. These areas usually ......
Read more >
Manual Annotation - Spark NLP - John Snow Labs
A prediction is a list of annotations created automatically by Spark NLP pre-trained models or from the rules. A project owner/manager can ...
Read more >
How to use bad grammar to get good results in your copy
Is bad grammar ever a good thing? Content experts at Distinctly discuss the merits of breaking the rules of grammar when creating persuasive ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found