diff options
author | Ryo Nihei <nihei.dev@gmail.com> | 2021-04-08 00:36:22 +0900 |
---|---|---|
committer | Ryo Nihei <nihei.dev@gmail.com> | 2021-04-08 00:36:22 +0900 |
commit | 91b93662e8ec8a92d763fad74da56b360bba2660 (patch) | |
tree | 231e3728a0b682d9376bbe84c7a7a6ce55ff4177 /compiler/parser_test.go | |
parent | Print the result of the lex command in JSON format (diff) | |
download | tre-91b93662e8ec8a92d763fad74da56b360bba2660.tar.gz tre-91b93662e8ec8a92d763fad74da56b360bba2660.tar.xz |
Add logging to compile command
compile command writes logs out to the maleeni-compile.log file.
When you use compiler.Compile(), you can choose whether the lexer writes logs or not.
Diffstat (limited to 'compiler/parser_test.go')
-rw-r--r-- | compiler/parser_test.go | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/compiler/parser_test.go b/compiler/parser_test.go index 5c2d813..3bad222 100644 --- a/compiler/parser_test.go +++ b/compiler/parser_test.go @@ -1,49 +1,11 @@ package compiler import ( - "fmt" - "io" "os" "reflect" "testing" ) -func printAST(w io.Writer, ast astNode, ruledLine string, childRuledLinePrefix string, withAttrs bool) { - if ast == nil { - return - } - fmt.Fprintf(w, ruledLine) - fmt.Fprintf(w, "node: %v", ast) - if withAttrs { - fmt.Fprintf(w, ", nullable: %v, first: %v, last: %v", ast.nullable(), ast.first(), ast.last()) - } - fmt.Fprintf(w, "\n") - left, right := ast.children() - children := []astNode{} - if left != nil { - children = append(children, left) - } - if right != nil { - children = append(children, right) - } - num := len(children) - for i, child := range children { - line := "└─ " - if num > 1 { - if i == 0 { - line = "├─ " - } else if i < num-1 { - line = "│ " - } - } - prefix := "│ " - if i >= num-1 { - prefix = " " - } - printAST(w, child, childRuledLinePrefix+line, childRuledLinePrefix+prefix, withAttrs) - } -} - func TestParser(t *testing.T) { rune2Byte := func(char rune, index int) byte { return []byte(string(char))[index] |