1
0
forked from GitHub/gf-core

added Graphviz visualizations

This commit is contained in:
Krasimir Angelov
2024-04-15 09:19:11 +02:00
parent ef659f3e97
commit 876e3c734a
4 changed files with 117 additions and 7 deletions

View File

@@ -114,7 +114,7 @@ class PGF:
"""
...
def generateRandom(cat : Type, depth : int = 5) -> tuple[Expr,float]:
def generateRandom(self, cat : Type, depth : int = 5) -> tuple[Expr,float]:
"""
Generates a random abstract syntax trees of the given type.
The depth parameter specifies the maximal distance between
@@ -123,6 +123,16 @@ class PGF:
"""
...
def graphvizAbstractTree(self, e: Expr,
noFun:bool=False, noCat:bool=False,
nodeFont:str="",
nodeColor:str="",
nodeEdgeStyle:str="") -> str:
"""
Renders an abstract syntax tree in a Graphviz format
"""
...
def newTransaction(self) -> Transaction:
"""
Starts a new transaction which makes it possible to update
@@ -208,11 +218,11 @@ class Concr:
"""The name of the concrete syntax"""
...
def linearize(e: Expr) -> str:
def linearize(self, e: Expr) -> str:
"""Linearizes the abstract expression and returns as string"""
...
def bracketedLinearize(e: Expr) -> list[Any]:
def bracketedLinearize(self, e: Expr) -> list[Any]:
"""
Produces a bracketed linearization where syntactic phrases
are represented as objects of type Bracket and terminal tokens
@@ -221,6 +231,22 @@ class Concr:
"""
...
def hasLinearization(self, fun: Str) -> bool:
"""
Returns true if the given function has linearization in the concrete syntax
"""
...
def graphvizParseTree(self, e: Expr,
noLeaves:bool=False, noFun:bool=False, noCat:bool=False,
nodeFont:str="", leafFont:str="",
nodeColor:str="", leafColor:str="",
nodeEdgeStyle:str="", leafEdgeStyle:str="") -> str:
"""
Renders an abstract syntax tree as a parse tree in Graphviz format
"""
...
class PGFError:
"""
This is the exception that several functions throw