Skip to main content

module vis::Text

rascal-0.40.16

Visualizing values using "ASCII art".

Usage

import vis::Text;

Dependencies

import Node;
import List;
import ListRelation;
import ParseTree;
import Type;

Examples

rascal>syntax E = "e" | E "+" E;
ok
rascal>import IO;
ok
rascal>import vis::Text;
ok
rascal>ex = prettyTree([E] "e+e+e");
str: " ❖\n ├─ E = E \"+\" E \n │ ├─ E = \"e\" \n │ └─ E = E \"+\" E \n │ ├─ E = \"e\" \n │ └─ E = \"e\" \n └─ E = E \"+\" E \n ├─ E = E \"+\" E \n │ ├─ E = \"e\" \n │ └─ E = \"e\" \n └─ E = \"e\" \n"
---

├─ E = E "+" E
│ ├─ E = "e"
│ └─ E = E "+" E
│ ├─ E = "e"
│ └─ E = "e"
└─ E = E "+" E
├─ E = E "+" E
│ ├─ E = "e"
│ └─ E = "e"
└─ E = "e"

---
rascal>println(ex);

├─ E = E "+" E
│ ├─ E = "e"
│ └─ E = E "+" E
│ ├─ E = "e"
│ └─ E = "e"
└─ E = E "+" E
├─ E = E "+" E
│ ├─ E = "e"
│ └─ E = "e"
└─ E = "e"
ok

function prettyTree

Pretty prints parse trees using ASCII art lines for edges.

str prettyTree(Tree t, bool src=false, bool characters=true, bool \layout=false, bool literals=\layout)

function prettyNode

Pretty prints nodes and ADTs using ASCII art for the edges.

str prettyNode(node n, bool keywords=true)

function ppvalue

str ppvalue(value e, str(value) nodeLabel, lrel[str,value](value) edges)

function ppvalue {#vis-Text-ppvalue}

str ppvalue_(value e, str(value) nodeLabel, lrel[str,value](value) edges, str indent = "")