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.

Support custom user defined declarative APIs

See original GitHub issue
$.RULE("selectStatement", () => {
    $.SUBRULE($.selectClause)
    $.SUBRULE($.fromClause)
    $.OPTION(() => {
        $.SUBRULE($.whereClause)        
    })
})

rule('selectStatement', [{
    rule: 'selectClause',
  }, {
    rule: 'fromClause',
  }, {
    option: {rule: 'whereClause'}
  }      
])

$.RULE("selectClause", () => {
    $.CONSUME(Select);
    $.AT_LEAST_ONE_SEP({SEP: Comma, DEF: () => {
        $.CONSUME(Identifier);
    }});
})

$rule('selectClause', [{
    consume: Select
  }, {
    repeat: {
      min: 1,
      separator: Comma, 
      rule: {
        consume: Identifier
      }
    }
  }
])

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
bd82commented, Apr 15, 2017

btw, I understand the appeal of a “clearer natural API”.

But one of the reasoning for the existing ugly APIs is that by being “pure” programatic APIs with very little abstraction is that the parser can be easily debugged just by setting a regular break point inside the parser. No in any generated code or in any additional abstraction.

0reactions
bd82commented, Feb 10, 2018

Usage Docs and links to runable example here: http://sap.github.io/chevrotain/website/Deep_Dive/custom_apis.html (link will be valid after 2.0 release.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Declarative API — SQLAlchemy 1.3 Documentation
Construct a base class for declarative class definitions. The new base class will be given a metaclass that produces appropriate Table objects ...
Read more >
Declarative API
Construct a base class for declarative class definitions. ... A type to use as the base for the generated declarative base class.
Read more >
Creating a declarative API | core - Cloud Robotics
In this guide we will use a Kubernetes-style declarative API to interface ... This is a custom resource definition (CRD) for a resource...
Read more >
Designing Declarative APIs. Ilya Birman - YouTube
What if it was a part of HTML? In this talk, I will give examples of declarative APIs, will guide you through designing...
Read more >
Declarative Configuration Reference Guide
An array of routes configured for this API instance towards the service. ... include the basic credentials defined in config.username and config.password ....
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