Closed wildthink closed 6 years ago
The syntax tree leafs store string ranges but you can map it to store strings instead using the mapLeafs
function to generate a more human readable syntax tree:
let string = "(a+b)*(-c)"
let syntaxTree: SyntaxTree<NonTerminal, Range<String.Index>> = parser.parse(string)
let humanReadable: SyntaxTree<NonTerminal, String> = syntaxTree.mapLeafs { leaf in
String(string[leaf])
}
I see that you are moving forward with swift 4.1 but is there any chance you could point me in the right direction to clean up the dot output as illustrated with
your parser.syntaxTree(for: "(a + b)*(-c)")
example?Thanks.