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.

Feature idea: template functionality for rules

See original GitHub issue

I am fairly new to this whole grammar thing, so please forgive me if I am missing something.

I think that adding some kind of template-functionality to lark would be a good idea to avoid redundancy in rules and to increase readability. A template would be a rule that takes parameters. Such a template could then be instantiated into a new rule by giving concrete values to these parameters. A grammar that contains templates could then be transformed into a grammar without templates by instantiating all used template rules.

For example, consider this grammar with templates

spaced(content): " " content " "
r1: "+" spaced("hello")
r2: "-" spaced("world")

spaced is a template that takes a parameter content. spaced("hello") and spaced("world") would be concrete instances of spaced. In a pre-processing step, the grammar can then be transformed into a grammar without templates:

spaced_0: " " "hello" " "
spaced_1: " " "world" " "
r1: "+" spaced_0
r2: "-" spaced_1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
graps1commented, Mar 26, 2020

Cool, so if it isn’t a problem, I could give it a try in the coming weeks or so.

0reactions
erezshcommented, Aug 6, 2020

This feature has been implemented, so I consider this issue closed. Good job everyone!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Aha! Roadmaps | Create templates for features, activities, and ...
Aha! Roadmaps | Create templates for features, activities, and requirements. Features are short, simple descriptions of a new capability.
Read more >
Feature Request Template: How to Collect User ... - Sleekplan
A template helps you to set up clear guidelines about how and what exactly users should contribute and which information you want to...
Read more >
Feature Planning Template & Example for Teams - Instagantt
Feature planning can help you organize multiple ideas and steps that involve creating and building new features for your software product.
Read more >
Attribute rules and map template for feature editing
ArcGIS Pro 2.7 includes a new map template and a collection of editing rules that support the manual digitization, editing, and maintenance ...
Read more >
Product Features List (Template & Prioritizing Exercise)
Features are simply elements of your product that serve a function. For example, in Notion, 'tables', 'timelines', 'galleries' are all (very useful) features....
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