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

New repo: Grammar.jl #2

Open
2 tasks
sebdumancic opened this issue Dec 16, 2022 · 0 comments
Open
2 tasks

New repo: Grammar.jl #2

sebdumancic opened this issue Dec 16, 2022 · 0 comments
Assignees

Comments

@sebdumancic
Copy link
Member

sebdumancic commented Dec 16, 2022

should contain all code related to declaring a grammar and basic supporting functions (generating random expressions, getting number of rules and so on...)

Core functionality:

  • specifying grammars: add, remove rules, read grammars from files, parsing macros, basic helper functions, store
    grammars
  • core type: context-free grammar

Others:

  • different types grammars: context-free, context-sensitive, probabilistic

Interfacing with other parts:

  • no input dependencies from other packages
  • Search.jl uses it to define iterators/search procedures
grammar = @cfgrammar begin
    Real = x                      # symbol
    Real = Real * Real            # julia expression
    Real = f(Real)                # function call
    Real = _(Base.rand(1.0:5.0))  # special syntax, eval argument of _() at derivation time
    Real = A | B | cos(Real)        # multiple rules on a single line
    Real = 1 | 2 | 3
    Real = |(4:6)                 # same as Real = 4 | 5 | 6
    Real = |([7,8,9])             # same as Real = 7 | 8 | 9 
end
   
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants