- Clone the repository:
git clone https://github.com/ylyxa/Conjunctive-GLR.git
- Install pygraphviz
- Install other packages:
pip install -r requirements.txt
- Navigate to
/examples/
and then to the example's folder - Run
generate_and_run.sh
inside the folder
Grammar syntax:
Grammar → ((Rule ∨ TermRule)\n)+
Rule → Nterm ::= (ConjRHS ∨ DisjRHS);Semantic
ConjRHS → (Str & Str ∨ (Str & ConjRHS));Semantic
DisjRHS → (Str ∨ (Str | DisjRHS));Semantic
Str → (Nterm ∨ Term ∨ _)+
TermRule → Regex
Semantic → FunctionName
Nterm → [A-Z][a-zA-Z0-9]*
Term → [a-z][a-zA-Z0-9]*
Here Regex
means a python regular expression, FunctionName
- name of a function from semantic.py
Semantic functions are defined as Python functions that accept one argument (a list of lower-level semantic results) and return a single value (which is then passed up the graph).
Note: there must be a function pass_through
defined like this:
def pass_through(x):
return x[0]
Note: Semantic results are undetermined if the grammar is ambiguous or contains conjunctive rules. File must be named semantic.py
Must be defined as a function reconfigure
in reconfigure.py
. Function accepts one argument (semantic result for the graph root) and returns a string (to be used in the next step of the interpretation loop)
- Generate the interpreter: place
semantic.py
andreconfigure.py
in the same directory asgenerator.py
and rungenerator.py grammar
- Run the interpreter: navigate to
/generated/
generated by the program and runmain.py grammar input
wheregrammar
is the generated grammar andinput
is the file with the input string