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.

Reusing same pattern in a rule

See original GitHub issue

Here is an example of grammar that I would like to have:

heredoc = "<<<" marker:[\w]+ "\n" text:[\s\S]+ "\n" marker {
    return text.join('');
}

Right now it doesn’t work but It would be nice to be able to use marker later in the rule. So I properly parse:

<<<HELLO
1
2
3
HELLO

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
hildjjcommented, Oct 16, 2021

See #196 for a fully-worked example of a stack when parsing XML.

0reactions
jcubiccommented, Dec 17, 2021

@Mingun I again needed to add validation with error (now I fully understand how this works), but I think that your example is not documented. The README don’t shows that you can use {} anywhere in the code and that you can use this pattern:

name:(rule / '' { error('xxx') })

Are there any other patterns like this? If yes then they should be documented separately (maybe on Wiki list of useful single rule examples on one page), no one have time to read full grammar to search for patterns that you can use.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to reuse a pattern rule for the same target in (GNU) make?
Sometimes I have to re-run the same operation within the same command chain to get a certain target, e.g. make input.filtered.sorted.updated.
Read more >
Rule reuse through inheritance | Pega Academy
Pattern inheritance is automatic. Pattern inheritance uses the existing class name structure to determine which rules are available for reuse.
Read more >
How to reuse variable - Error: Pattern appears on the right ...
"Rule: Pattern x_fake appears on the right-hand side of rule..." and "ListPlot: x_fake is not a list of numbers or pairs of numbers"....
Read more >
A Patterns-Based Rules Methodology | Enforcing Business ...
This article introduces a pattern-based rules methodology that includes proactive rules checking, a categorization scheme for business rules ...
Read more >
Reusing Custom Attributes in Condition Patterns - Noodlesoft
If you use the same custom attribute in an action for this rule, it will have the value of the first condition that...
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