From dab8ef6f9f0a4a945114a96c28a422a73eb1c770 Mon Sep 17 00:00:00 2001 From: Ting-Wei Lan Date: Mon, 28 Jan 2019 18:03:53 +0800 Subject: core: vm: sqlvm: process non-UTF-8 input and escape sequences Our parser is able to process queries with invalid UTF-8, provided that it is compatible with ASCII. Since doing so requires encoding the input before passing to pigeon, Parse* functions generated by pigeon are unexported because they should not be used directly. Escape sequences in string literals and identifiers are now recognized. In addition to escape sequences supported by solidity, we support \U similar to the one supported by Go to allow users to specify non-BMP Unicode code point without using multiple \x escapes. AST printer is modified to quote non-printable characters in strings to prevent control characters from messing up the terminal. --- core/vm/sqlvm/cmd/ast-printer/main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'core/vm/sqlvm/cmd') diff --git a/core/vm/sqlvm/cmd/ast-printer/main.go b/core/vm/sqlvm/cmd/ast-printer/main.go index 9cdcc6dd6..7b4251fa1 100644 --- a/core/vm/sqlvm/cmd/ast-printer/main.go +++ b/core/vm/sqlvm/cmd/ast-printer/main.go @@ -14,10 +14,11 @@ func main() { flag.Parse() - n, err := parser.ParseString(flag.Arg(0)) + n, err := parser.Parse([]byte(flag.Arg(0))) fmt.Printf("detail: %t\n", detail) - fmt.Printf("err:\n%+v\n", err) if err == nil { ast.PrintAST(n, "", detail) + } else { + fmt.Printf("err:\n%+v\n", err) } } -- cgit v1.2.3