go.mondoo.com/cnquery@v0.0.0-20231005093811-59568235f6ea/mqlc/parser/parser-dev.go (about)

     1  // Copyright (c) Mondoo, Inc.
     2  // SPDX-License-Identifier: BUSL-1.1
     3  
     4  //go:build !production
     5  // +build !production
     6  
     7  package parser
     8  
     9  import (
    10  	"encoding/json"
    11  	"fmt"
    12  )
    13  
    14  func (p *parser) inspect(pos string) {
    15  	fmt.Printf("%s: [%#v] - %#v\n", pos, p.nextTokens, p.token)
    16  }
    17  
    18  // Inspect the AST of the parsed tree
    19  func Inspect(ast *AST) {
    20  	res, err := json.MarshalIndent(ast, "", "  ")
    21  	if err != nil {
    22  		fmt.Println("\033[31;1mFailed to marshal AST:\033[0m " + err.Error())
    23  	}
    24  	fmt.Println(string(res))
    25  }