From 6dd78f44adf6fb032d0ecd9db813651b9524fcac Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Wed, 6 Sep 2023 08:49:19 +0200 Subject: chore: refactor some APIs The scanner returns a slice of pointers to tokens instead of a slice of tokens. The parser now pass the initial node context. --- parser/dot.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'parser/dot.go') diff --git a/parser/dot.go b/parser/dot.go index f486cd5..11d5014 100644 --- a/parser/dot.go +++ b/parser/dot.go @@ -50,7 +50,10 @@ func (n *Node) astDot(out io.Writer, label string) { for _, c := range nod.Child { anc[c] = nod } - name := strings.ReplaceAll(nod.Name(), `"`, `\"`) + name := "" + if nod.Token != nil { + name = strings.ReplaceAll(nod.Name(), `"`, `\"`) + } fmt.Fprintf(out, "%d [label=\"%s\"]; ", index[nod], name) if anc[nod] != nil { fmt.Fprintf(out, "%d -> %d; ", index[anc[nod]], index[nod]) -- cgit v1.2.3