Last active
August 29, 2015 14:01
-
-
Save JakeCoxon/84e4a91756d701e6483b to your computer and use it in GitHub Desktop.
String/Graph grammar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val form1 = StringForm("aAabBbaB") | |
val grammar1 = new StringGrammar( | |
"A" -> "aAB", | |
"A" -> "aa", | |
"B" -> "bbbb") | |
val derivation1 = StringDerivation("aAB") | |
form1.applyFirst(grammar1) | |
form1.applyFirst(derivation1) | |
val form2 = GraphForm("A->b A->c c->d") | |
val grammar2 = GraphGrammar( | |
"A(a b c)" -> "A->a A->b A->c") | |
val derivation1 = GraphDerivation("a b c", "A->a A->b A->c") | |
form2.applyFirst(grammar2) | |
form2.applyFirst(derivation2) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment