aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/sqlvm/cmd/ast-printer
Commit message (Collapse)AuthorAgeFilesLines
* core: vm: sqlvm: ast: handle error in AST printerTing-Wei Lan2019-03-261-5/+11
| | | | Catch the error reported by fmt.Fprintf and report it to the caller.
* core: vm: sqlvm: fill source code position in AST nodesTing-Wei Lan2019-03-261-2/+3
| | | | | | | | | | | | | | | Now all AST nodes should have position information recorded during parsing. These fields are intended to be used to report errors and make debugging easier. However, precise location of each token is currently unavailable. It can be done in the future if it becomes necessary. To make it easier to traverse an AST, GetChildren is modified to skip nil nodes in the output. This means callers of GetChildren don't have to check for nil in returned slices. AST printer is modified to print the position and the corresponding source code token. A few special handling for interfaces are removed because reflection works better for structs.
* core: vm: sqlvm: introduce interfaces for AST nodesTing-Wei Lan2019-03-261-4/+4
| | | | | | | | | In order to make our AST easier and safer to use, all declarations with empty interface type are now removed. This changes also makes it possible to traverse the AST without using reflection or understanding what each type means because all AST nodes have at least one common interface.
* core: vm: sqlvm: ast: don't hardcode output and indent in PrintASTTing-Wei Lan2019-03-261-1/+2
| | | | | It is now possible to write AST dump to a writer other than stdout and use indent string other than 2 spaces.
* core: vm: sqlvm: process non-UTF-8 input and escape sequencesTing-Wei Lan2019-03-261-2/+3
| | | | | | | | | | | | | | | 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: parser: properly handle errorsTing-Wei Lan2019-03-261-1/+1
| | | | | | Instead of ignoring errors, errors returned from external functions are normalized and reported to users. Errors which should be impossible to occur are converted to panic calls.
* core: vm: sqlvm: remove optional interface and add print tag for detailwmin02019-03-261-3/+9
| | | | | | | There are some changes in print ast utility. 1. instead of using optional interface to get detail, use reflect 2. implement a `print` field tag for printer switching detail mode or not
* core: vm: sqlvm: move AST and parser to their own packagesTing-Wei Lan2019-03-261-3/+4
| | | | | | | | In order to avoid putting too many different things in single package and allow other projects to reuse the syntax tree and the parser, these two components are moved to different packages and all nodes used in AST are now exported. A lot of comments are added in this commit to pass golint checks.
* core: vm: sqlvm: add sql language parser prototypingwmin02019-03-261-0/+16
Add sql language parser prototyping along with 1. grammar file implemented with github.com/mna/pigeon 2. ast node struct definition 3. simple parser test which only test if error existed 4. ast printer utility for visualizing parsing result