diff options
| author | Marc Vertes <mvertes@free.fr> | 2023-09-06 08:49:19 +0200 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2023-09-06 08:49:19 +0200 |
| commit | 6dd78f44adf6fb032d0ecd9db813651b9524fcac (patch) | |
| tree | d1d4b3305db708614f147b2294b4b0e28336a55d /parser/dot.go | |
| parent | 4241593b42bffac2f8fcb63f1e88621fe025e360 (diff) | |
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.
Diffstat (limited to 'parser/dot.go')
| -rw-r--r-- | parser/dot.go | 5 |
1 files changed, 4 insertions, 1 deletions
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]) |
