-
-
Save simonvar/5bbc9fba89af239552ba7c1555714468 to your computer and use it in GitHub Desktop.
This file contains 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
package org.meerkat | |
import org.meerkat.Syntax._ | |
import org.meerkat.input.GraphxInput | |
import org.meerkat.parsers.Parsers._ | |
import org.meerkat.parsers._ | |
import org.meerkat.sppf.SPPFToDot | |
import scalax.collection.Graph | |
import scalax.collection.edge.Implicits._ | |
import org.meerkat.util.wrappers | |
/** | |
* <p>Date: 02.01.18 </p>\ | |
* | |
* @author Simon | |
* | |
*/ | |
object Main { | |
//**************************************************************************************************** | |
val eps = syn("e") | |
val S1 = syn("exit36" | "-entry36" | eps) | |
val SS1 = syn("entry36" | "-exit36" | eps) | |
val road = syn("name" | "data" | "arr_elem"| eps) | |
val neroad = syn("-name" | "-data" | "-arr_elem"| eps | epsilon) | |
val C: Nonterminal[String] = syn(SS1 ~ C ~ S1 | C ~ C | neroad | road | eps | epsilon) | |
val memAlias: Nonterminal[String] = syn(road ~ memAlias ~ neroad | memAlias ~ memAlias | C | eps) | |
//**************************************************************************************************** | |
//**************************************************************************************************** | |
val g = Graph( | |
(0 ~+#> 1) ("e"), | |
(2 ~+#> 3) ("e"), | |
(4 ~+#> 5) ("e"), | |
(6 ~+#> 7) ("e"), | |
(10 ~+#> 8) ("e"), | |
(9 ~+#> 11) ("e"), | |
(1 ~+#> 3) ("name"), | |
(3 ~+#> 1) ("-name"), | |
(3 ~+#> 5) ("e"), | |
(8 ~+#> 7) ("name"), | |
(7 ~+#> 8) ("-name"), | |
(12 ~+#> 15) ("e"), | |
(13 ~+#> 16) ("e"), | |
(14 ~+#> 17) ("e"), | |
(11 ~+#> 15) ("entry36"), | |
(16 ~+#> 8) ("-exit36"), | |
(15 ~+#> 11) ("-entry36"), | |
(8 ~+#> 16) ("exit36"), | |
(15 ~+#> 16) ("data"), | |
(17 ~+#> 16) ("-arr_elem"), | |
(16 ~+#> 15) ("-data"), | |
(16 ~+#> 17) ("arr_elem"), | |
) | |
//**************************************************************************************************** | |
def main(args: Array[String]): Unit = { | |
var toDot = new SPPFToDot() | |
// var graph = GraphxInput(g) | |
var sppf = getSPPFs(memAlias, GraphxInput(g)).right.getOrElse(null) | |
println(g.toString) | |
//toDot.visit(sppf._1.head) | |
//sppf._1.map(org.meerkat.util.wrappers.SPPFToTrees).head.map(println) | |
//println(toDot.get) | |
println(sppf) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment