├── test_data ├── common.libsonnet └── functions.jsonnet ├── go.mod ├── .gitignore ├── go.sum ├── .github ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── scip.yml │ └── pr-auditor.yml ├── refs ├── path_resolver.go └── listener.go ├── types ├── types.go └── scope.go ├── parser ├── Jsonnet.tokens ├── JsonnetLexer.tokens ├── jsonnet_listener.go ├── jsonnet_base_listener.go ├── Jsonnet.interp ├── JsonnetLexer.interp └── jsonnet_lexer.go ├── README.md ├── cmd └── lsif-jsonnet │ └── main.go ├── Jsonnet.g4 ├── dumper └── dumper.go ├── LICENSE └── protocol └── protocol.go /test_data/common.libsonnet: -------------------------------------------------------------------------------- 1 | local bar(x, y) = x - y; 2 | 3 | { 4 | bar :: bar, 5 | } 6 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module lsif-jsonnet 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/antlr/antlr4 v0.0.0-20190922154701-7982187134a6 7 | github.com/spf13/pflag v1.0.5 8 | ) 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, build with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/antlr/antlr4 v0.0.0-20190922154701-7982187134a6 h1:qGBE0ODSxUVyCm1ZEZuXFvddTfk2qMH3cnmAcbgmC04= 2 | github.com/antlr/antlr4 v0.0.0-20190922154701-7982187134a6/go.mod h1:T7PbCXFs94rrTttyxjbyT5+/1V8T2TYDejxUfHJjw1Y= 3 | github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= 4 | github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= 5 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Test plan 2 | 3 | 10 | -------------------------------------------------------------------------------- /.github/workflows/scip.yml: -------------------------------------------------------------------------------- 1 | name: SCIP 2 | 'on': 3 | - push 4 | jobs: 5 | scip-go: 6 | runs-on: ubuntu-latest 7 | container: sourcegraph/scip-go 8 | steps: 9 | - uses: actions/checkout@v1 10 | - name: Get src-cli 11 | run: curl -L https://sourcegraph.com/.api/src-cli/src_linux_amd64 -o /usr/local/bin/src; 12 | chmod +x /usr/local/bin/src 13 | - name: Set directory to safe for git 14 | run: git config --global --add safe.directory $GITHUB_WORKSPACE 15 | - name: Generate SCIP data 16 | run: scip-go 17 | - name: Upload SCIP data 18 | run: src code-intel upload -github-token=${{ secrets.GITHUB_TOKEN }} 19 | -------------------------------------------------------------------------------- /test_data/functions.jsonnet: -------------------------------------------------------------------------------- 1 | local common = import './common.libsonnet'; 2 | 3 | // Define a local function. 4 | // Default arguments are like Python: 5 | local foo(x, y=10) = x + y; 6 | 7 | local my_value = { 8 | // A method 9 | foo(x): x * x, 10 | }; 11 | 12 | { 13 | // Functions are first class citizens. 14 | call_inline_function: 15 | (function(x) x * x)(5), 16 | 17 | // Using the variable fetches the function, 18 | // the parens call the function. 19 | call: foo(2), 20 | 21 | common_call: common.bar(3, 2), 22 | 23 | // Like python, parameters can be named at 24 | // call time. 25 | named_params: foo(x=2), 26 | // This allows changing their order 27 | named_params2: foo(y=3, x=2), 28 | 29 | // my_value.foo returns the function, 30 | // which is then called like any other. 31 | call_method1: my_value.foo(3), 32 | 33 | standard_lib: 34 | std.join(' ', std.split('foo/bar', '/')), 35 | len: [ 36 | std.length('hello'), 37 | std.length([1, 2, 3]), 38 | ], 39 | } 40 | -------------------------------------------------------------------------------- /.github/workflows/pr-auditor.yml: -------------------------------------------------------------------------------- 1 | # See https://docs.sourcegraph.com/dev/background-information/ci#pr-auditor 2 | name: pr-auditor 3 | on: 4 | pull_request_target: 5 | types: [ closed, edited, opened, synchronize, ready_for_review ] 6 | workflow_dispatch: 7 | 8 | jobs: 9 | check-pr: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | with: 14 | repository: 'sourcegraph/devx-service' 15 | token: ${{ secrets.PR_AUDITOR_TOKEN }} 16 | - uses: actions/setup-go@v4 17 | with: { go-version: '1.22' } 18 | 19 | - run: 'go run ./cmd/pr-auditor' 20 | env: 21 | GITHUB_EVENT_PATH: ${{ env.GITHUB_EVENT_PATH }} 22 | GITHUB_TOKEN: ${{ secrets.PR_AUDITOR_TOKEN }} 23 | GITHUB_RUN_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} 24 | report_failure: 25 | needs: check-pr 26 | if: ${{ failure() }} 27 | uses: sourcegraph/workflows/.github/workflows/report-job-failure.yml@main 28 | secrets: inherit 29 | -------------------------------------------------------------------------------- /refs/path_resolver.go: -------------------------------------------------------------------------------- 1 | package refs 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | ) 7 | 8 | type PathResolver struct { 9 | basePaths []string 10 | } 11 | 12 | func PathExists(path string) (bool, error) { 13 | _, err := os.Stat(path) 14 | if err == nil { 15 | return true, nil 16 | } 17 | if os.IsNotExist(err) { 18 | return false, nil 19 | } 20 | return false, err 21 | } 22 | 23 | func NewPathResolver(basePaths []string) (*PathResolver, error) { 24 | absPaths := make([]string, 0, len(basePaths)) 25 | 26 | for _, path := range basePaths { 27 | absPath, err := filepath.Abs(path) 28 | if err != nil { 29 | return nil, err 30 | } 31 | absPaths = append(absPaths, absPath) 32 | } 33 | return &PathResolver{absPaths}, nil 34 | } 35 | 36 | func (pr *PathResolver) AddPath(basePath string) error { 37 | absPath, err := filepath.Abs(basePath) 38 | if err != nil { 39 | return err 40 | } 41 | pr.basePaths = append(pr.basePaths, absPath) 42 | return nil 43 | } 44 | 45 | func (pr *PathResolver) Resolve(path string) (string, error) { 46 | if filepath.IsAbs(path) { 47 | return path, nil 48 | } 49 | for _, bp := range pr.basePaths { 50 | candidate := filepath.Join(bp, path) 51 | 52 | ex, err := PathExists(candidate) 53 | if err != nil { 54 | return "", err 55 | } 56 | 57 | if ex { 58 | return candidate, nil 59 | } 60 | } 61 | return "", nil 62 | } 63 | -------------------------------------------------------------------------------- /types/types.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/antlr/antlr4/runtime/Go/antlr" 7 | ) 8 | 9 | type Pos struct { 10 | Line int 11 | Column int 12 | } 13 | 14 | func NewPos(token antlr.Token) Pos { 15 | return Pos{ 16 | Line: token.GetLine(), 17 | Column: token.GetColumn(), 18 | } 19 | } 20 | 21 | func (p Pos) String() string { 22 | return fmt.Sprintf("(line:%d, col:%d)", p.Line, p.Column) 23 | } 24 | 25 | func (p Pos) IsValid() bool { 26 | return p.Line > 0 27 | } 28 | 29 | func (p Pos) Less(op Pos) bool { 30 | if p.Line == op.Line { 31 | return p.Column < op.Column 32 | } 33 | return p.Line < op.Line 34 | } 35 | 36 | func (p Pos) LessEq(op Pos) bool { 37 | return !op.Less(p) 38 | } 39 | 40 | type Use struct { 41 | StartPos Pos 42 | File string 43 | } 44 | 45 | func (u Use) String() string { 46 | return fmt.Sprintf("(%s:%d:%d)", u.File, u.StartPos.Line, u.StartPos.Column) 47 | } 48 | 49 | const ( 50 | ValueDeclaration = "Value" 51 | FunctionDeclaration = "Function" 52 | ParamDeclaration = "Param" 53 | ImportDeclaration = "Import" 54 | ) 55 | 56 | type Declaration struct { 57 | Name string 58 | StartPos Pos 59 | File string 60 | Parent *Scope 61 | Inner *Scope 62 | Type string 63 | Uses []Use 64 | } 65 | 66 | func (dcl *Declaration) String() string { 67 | return fmt.Sprintf("%s{name:%s, pos: %v, uses: %v}", dcl.Type, dcl.Name, dcl.StartPos, dcl.Uses) 68 | } 69 | -------------------------------------------------------------------------------- /parser/Jsonnet.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | T__3=4 5 | T__4=5 6 | T__5=6 7 | T__6=7 8 | T__7=8 9 | T__8=9 10 | T__9=10 11 | T__10=11 12 | DOLLAR=12 13 | ASSERT=13 14 | ELSE=14 15 | ERROR=15 16 | FALSE=16 17 | FOR=17 18 | FUNCTION=18 19 | IF=19 20 | IMPORT=20 21 | IMPORTSTR=21 22 | LOCAL=22 23 | NULL=23 24 | SELF=24 25 | SUPER=25 26 | TAILSTRICT=26 27 | THEN=27 28 | TRUE=28 29 | EQUALS=29 30 | NOTEQUALS=30 31 | PLUS=31 32 | MINUS=32 33 | MULTIPLY=33 34 | DIVIDE=34 35 | MODULUS=35 36 | AND=36 37 | OR=37 38 | NOT=38 39 | GT=39 40 | GE=40 41 | LT=41 42 | LE=42 43 | IN=43 44 | SHIFTLEFT=44 45 | SHIFTRIGHT=45 46 | BITNOT=46 47 | BITAND=47 48 | BITXOR=48 49 | BITOR=49 50 | STRING=50 51 | NUMBER=51 52 | ID=52 53 | Whitespace=53 54 | Newline=54 55 | BlockComment=55 56 | LineComment=56 57 | '('=1 58 | ')'=2 59 | '{'=3 60 | '}'=4 61 | '['=5 62 | ','=6 63 | ']'=7 64 | '.'=8 65 | ':'=9 66 | ';'=10 67 | '='=11 68 | '$'=12 69 | 'assert'=13 70 | 'else'=14 71 | 'error'=15 72 | 'false'=16 73 | 'for'=17 74 | 'function'=18 75 | 'if'=19 76 | 'import'=20 77 | 'importstr'=21 78 | 'local'=22 79 | 'null'=23 80 | 'self'=24 81 | 'super'=25 82 | 'tailstrict'=26 83 | 'then'=27 84 | 'true'=28 85 | '=='=29 86 | '!='=30 87 | '+'=31 88 | '-'=32 89 | '*'=33 90 | '/'=34 91 | '%'=35 92 | '&&'=36 93 | '||'=37 94 | '!'=38 95 | '>'=39 96 | '>='=40 97 | '<'=41 98 | '<='=42 99 | 'in'=43 100 | '<<'=44 101 | '>>'=45 102 | '~'=46 103 | '&'=47 104 | '^'=48 105 | '|'=49 106 | -------------------------------------------------------------------------------- /parser/JsonnetLexer.tokens: -------------------------------------------------------------------------------- 1 | T__0=1 2 | T__1=2 3 | T__2=3 4 | T__3=4 5 | T__4=5 6 | T__5=6 7 | T__6=7 8 | T__7=8 9 | T__8=9 10 | T__9=10 11 | T__10=11 12 | DOLLAR=12 13 | ASSERT=13 14 | ELSE=14 15 | ERROR=15 16 | FALSE=16 17 | FOR=17 18 | FUNCTION=18 19 | IF=19 20 | IMPORT=20 21 | IMPORTSTR=21 22 | LOCAL=22 23 | NULL=23 24 | SELF=24 25 | SUPER=25 26 | TAILSTRICT=26 27 | THEN=27 28 | TRUE=28 29 | EQUALS=29 30 | NOTEQUALS=30 31 | PLUS=31 32 | MINUS=32 33 | MULTIPLY=33 34 | DIVIDE=34 35 | MODULUS=35 36 | AND=36 37 | OR=37 38 | NOT=38 39 | GT=39 40 | GE=40 41 | LT=41 42 | LE=42 43 | IN=43 44 | SHIFTLEFT=44 45 | SHIFTRIGHT=45 46 | BITNOT=46 47 | BITAND=47 48 | BITXOR=48 49 | BITOR=49 50 | STRING=50 51 | NUMBER=51 52 | ID=52 53 | Whitespace=53 54 | Newline=54 55 | BlockComment=55 56 | LineComment=56 57 | '('=1 58 | ')'=2 59 | '{'=3 60 | '}'=4 61 | '['=5 62 | ','=6 63 | ']'=7 64 | '.'=8 65 | ':'=9 66 | ';'=10 67 | '='=11 68 | '$'=12 69 | 'assert'=13 70 | 'else'=14 71 | 'error'=15 72 | 'false'=16 73 | 'for'=17 74 | 'function'=18 75 | 'if'=19 76 | 'import'=20 77 | 'importstr'=21 78 | 'local'=22 79 | 'null'=23 80 | 'self'=24 81 | 'super'=25 82 | 'tailstrict'=26 83 | 'then'=27 84 | 'true'=28 85 | '=='=29 86 | '!='=30 87 | '+'=31 88 | '-'=32 89 | '*'=33 90 | '/'=34 91 | '%'=35 92 | '&&'=36 93 | '||'=37 94 | '!'=38 95 | '>'=39 96 | '>='=40 97 | '<'=41 98 | '<='=42 99 | 'in'=43 100 | '<<'=44 101 | '>>'=45 102 | '~'=46 103 | '&'=47 104 | '^'=48 105 | '|'=49 106 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JSonnet LSIF indexer ![](https://img.shields.io/badge/status-development-yellow) 2 | 3 | 🚨 This implementation is still in very early stage and follows the latest LSIF specification closely. 4 | 5 | ## Language Server Index Format 6 | 7 | The purpose of the Language Server Index Format (LSIF) is to define a standard format for language servers or other 8 | programming tools to dump their knowledge about a workspace. This dump can later be used to answer language server 9 | [LSP](https://microsoft.github.io/language-server-protocol/) requests for the same workspace without running the 10 | language server itself. Since much of the information would be invalidated by a change to the workspace, 11 | the dumped information typically excludes requests used when mutating a document. So, for example, the result of a code 12 | complete request is typically not part of such a dump. 13 | 14 | A first draft specification can be found [here](https://github.com/Microsoft/language-server-protocol/blob/master/indexFormat/specification.md). 15 | 16 | ## JSonnet 17 | 18 | [JSonnet](https://jsonnet.org) is a data templating language related to JSON. 19 | 20 | ## Implementation 21 | 22 | In true open-source spirit the implementation is made from these parts: 23 | 24 | - The parser is generated by [Antlr4](https://www.antlr.org) from a grammar file modified from 25 | [this GitHub Gist](https://gist.github.com/ironchefpython/84380aa60871853dc86719dd598c35e4). 26 | 27 | - The protocol.go code was borrowed and modified from [lsif-go](https://github.com/sourcegraph/lsif-go). 28 | 29 | - The LSIF dumper is a modification of indexer.go from [lsif-go](https://github.com/sourcegraph/lsif-go). 30 | 31 | - The scope implementation is a modification of [go.types.Scope](https://golang.org/pkg/go/types/#Scope). 32 | 33 | Many thanks to the creators of these. 34 | 35 | ## Status 36 | 37 | This was put together quickly to learn LSIF and JSonnet. It is missing many features, for example 38 | hover results, documentation comments (parser currently discards comments), error handling, the standard library is not covered. 39 | It has not seen code reviews, so it's highly likely that there are bugs, omissions and oversights. 40 | It can serve as a starting point for more production-ready implementations for JSonnet or other languages. 41 | 42 | ## Usage 43 | 44 | - Build the `cmd/lsif-jsonnet` cli the usual way with Go. 45 | - The cli mimics the flags of the `jsonnet` cli, so you can specify `libsonnet` search paths with `-J` and the output 46 | file with `-o`. 47 | - Run the cli on your jsonnet file and generate an LSIF data file. 48 | - You can use the generated LSIF data file in [VSCode](https://code.visualstudio.com) with the LSIF plugin or when running a 49 | [Sourcegraph](https://docs.sourcegraph.com/user/code_intelligence/lsif) instance. Feel free to fork and use the 50 | [test-jsonnet-lsif](https://github.com/uwedeportivo/test-jsonnet-lsif) repo as your test code. 51 | 52 | ## Re-generate parser 53 | 54 | After installing [Antlr4](https://github.com/antlr/antlr4) and the [Go target](https://github.com/antlr/antlr4/blob/master/doc/go-target.md) 55 | you can run this command from the repo root: 56 | 57 | ```bash 58 | antlr -Dlanguage=Go -o parser Jsonnet.g4 59 | ``` 60 | 61 | ## Testing and validating LSIF output 62 | 63 | [lsif-util](https://www.npmjs.com/package/lsif-util) is a commandline tool for validating the generated LSIF data syntactically. 64 | It also supports producing [dot graphs](https://graphviz.gitlab.io/_pages/doc/info/lang.html) that can be turned into PNG images 65 | with [dot](https://graphviz.gitlab.io/download/). 66 | 67 | - Validate: `lsif-util validate data.lsif` 68 | - Visualize: `lsif-util visualize data.lsif --distance 2 | dot -Tpng -o image.png` 69 | -------------------------------------------------------------------------------- /cmd/lsif-jsonnet/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bufio" 5 | "errors" 6 | "fmt" 7 | "io" 8 | "os" 9 | "path/filepath" 10 | "strings" 11 | 12 | flag "github.com/spf13/pflag" 13 | "lsif-jsonnet/dumper" 14 | "lsif-jsonnet/protocol" 15 | "lsif-jsonnet/refs" 16 | ) 17 | 18 | const version = "1.0.0" 19 | const versionString = version + ", protocol version " + protocol.Version 20 | 21 | func main() { 22 | if err := mainImpl(); err != nil { 23 | fmt.Fprintf(os.Stderr, "error: %v\n", err) 24 | os.Exit(1) 25 | } 26 | } 27 | 28 | func findRepo(dir string) (string, error) { 29 | inRepo, err := refs.PathExists(filepath.Join(dir, ".git")) 30 | if err != nil { 31 | return "", err 32 | } 33 | if inRepo { 34 | return dir, nil 35 | } 36 | 37 | if len(dir) == 1 && dir[0] == filepath.Separator { 38 | return "", errors.New("no repo found") 39 | } 40 | 41 | return findRepo(filepath.Dir(dir)) 42 | } 43 | 44 | func collectInputFiles(args []string) ([]string, error) { 45 | var res []string 46 | 47 | if len(args) == 0 { 48 | cwd, err := os.Getwd() 49 | if err != nil { 50 | return nil, err 51 | } 52 | args = []string{cwd} 53 | } 54 | 55 | for _, arg := range args { 56 | absArg, err := filepath.Abs(arg) 57 | if err != nil { 58 | return nil, err 59 | } 60 | 61 | fi, err := os.Stat(absArg) 62 | if err != nil { 63 | return nil, err 64 | } 65 | 66 | if fi.IsDir() { 67 | xs, err := collectInputsInDir(absArg) 68 | if err != nil { 69 | return nil, err 70 | } 71 | res = append(res, xs...) 72 | } else { 73 | res = append(res, absArg) 74 | } 75 | } 76 | return res, nil 77 | } 78 | 79 | func collectInputsInDir(dir string) ([]string, error) { 80 | var res []string 81 | err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { 82 | if err != nil { 83 | return err 84 | } 85 | if !info.IsDir() && strings.HasSuffix(path, ".jsonnet") { 86 | res = append(res, path) 87 | } 88 | return nil 89 | }) 90 | return res, err 91 | } 92 | 93 | func mainImpl() error { 94 | var help = flag.BoolP("help", "h", false, "This message") 95 | var jps = flag.StringArrayP("jpath", "J", nil, "Optional. Specify an additional library search dir (right-most wins)") 96 | var outFile = flag.StringP("output-file", "o", "", "Optional. Write to the output file rather than stdout") 97 | var projectRoot = flag.StringP("project-root", "p", "", "Optional. Specifies which dir is the project root. Defaults to repo dir where sources are located.") 98 | 99 | flag.Parse() 100 | 101 | if *help { 102 | fmt.Fprintf(os.Stderr, "lsif-jsonnet %s\n", versionString) 103 | fmt.Fprintln(os.Stderr, `Basic usage: lsif-jsonnet -J -o -p 104 | 105 | If no directories or jsonnet input files are specified, it will look for files with .jsonnet suffix in current working dir tree.`) 106 | flag.PrintDefaults() 107 | os.Exit(0) 108 | } 109 | 110 | var lps []string 111 | 112 | for _, p := range filepath.SplitList(os.Getenv("JSONNET_PATH")) { 113 | lps = append(lps, p) 114 | } 115 | 116 | for _, pp := range *jps { 117 | for _, p := range filepath.SplitList(pp) { 118 | lps = append(lps, p) 119 | } 120 | } 121 | 122 | pathResolver, err := refs.NewPathResolver(lps) 123 | if err != nil { 124 | return fmt.Errorf("failed to instantiate path resolver: %w\n", err) 125 | } 126 | 127 | inputs, err := collectInputFiles(flag.Args()) 128 | if err != nil { 129 | return err 130 | } 131 | 132 | if len(inputs) == 0 { 133 | return errors.New("no jsonnet input files found") 134 | } 135 | 136 | var lls []*refs.Listener 137 | 138 | for _, absInFile := range inputs { 139 | inDir := filepath.Dir(absInFile) 140 | err = pathResolver.AddPath(inDir) 141 | if err != nil { 142 | return fmt.Errorf("failed to add %s to path resolver: %w\n", inDir, err) 143 | } 144 | 145 | ll, err := refs.ParseFile(absInFile, pathResolver) 146 | if err != nil { 147 | return fmt.Errorf("failed to parse %s: %w\n", absInFile, err) 148 | } 149 | 150 | lls = append(lls, ll) 151 | } 152 | 153 | var outWriter io.Writer 154 | 155 | if len(*outFile) > 0 { 156 | f, err := os.Create(*outFile) 157 | if err != nil { 158 | return fmt.Errorf("failed to create %s: %w\n", *outFile, err) 159 | } 160 | defer f.Close() 161 | 162 | bw := bufio.NewWriter(f) 163 | defer bw.Flush() 164 | 165 | outWriter = bw 166 | } else { 167 | outWriter = os.Stdout 168 | } 169 | 170 | toolInfo := &protocol.ToolInfo{ 171 | Name: "lsif-jsonnet", 172 | Version: version, 173 | Args: os.Args[1:], 174 | } 175 | 176 | root := *projectRoot 177 | if root == "" { 178 | repoRoot, err := findRepo(filepath.Dir(inputs[0])) 179 | if err != nil { 180 | return errors.New("couldn't determine project root") 181 | } 182 | root = repoRoot 183 | } 184 | 185 | dmpr := dumper.NewDumper(root, outWriter) 186 | 187 | return dmpr.DumpProject(toolInfo, lls) 188 | } 189 | -------------------------------------------------------------------------------- /types/scope.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "io" 7 | "sort" 8 | "strings" 9 | ) 10 | 11 | var Universe *Scope = &Scope{} 12 | 13 | // A Scope maintains a set of objects and links to its containing 14 | // (parent) and contained (children) scopes. Objects may be inserted 15 | // and looked up by name. The zero value for Scope is a ready-to-use 16 | // empty scope. 17 | type Scope struct { 18 | parent *Scope 19 | children []*Scope 20 | elems map[string]*Declaration // lazily allocated 21 | pos, end Pos // scope extent; may be invalid 22 | } 23 | 24 | // NewScope returns a new, empty scope contained in the given parent 25 | // scope, if any. The comment is for debugging only. 26 | func NewScope(parent *Scope, pos, end Pos) *Scope { 27 | s := &Scope{parent, nil, nil, pos, end} 28 | // don't add children to Universe scope! 29 | if parent != nil && parent != Universe { 30 | parent.children = append(parent.children, s) 31 | } 32 | return s 33 | } 34 | 35 | // Parent returns the scope's containing (parent) scope. 36 | func (s *Scope) Parent() *Scope { return s.parent } 37 | 38 | // Len returns the number of scope elements. 39 | func (s *Scope) Len() int { return len(s.elems) } 40 | 41 | // Names returns the scope's element names in sorted order. 42 | func (s *Scope) Names() []string { 43 | names := make([]string, len(s.elems)) 44 | i := 0 45 | for name := range s.elems { 46 | names[i] = name 47 | i++ 48 | } 49 | sort.Strings(names) 50 | return names 51 | } 52 | 53 | // NumChildren returns the number of scopes nested in s. 54 | func (s *Scope) NumChildren() int { return len(s.children) } 55 | 56 | // Child returns the i'th child scope for 0 <= i < NumChildren(). 57 | func (s *Scope) Child(i int) *Scope { return s.children[i] } 58 | 59 | // Lookup returns the object in scope s with the given name if such an 60 | // object exists; otherwise the result is nil. 61 | func (s *Scope) Lookup(name string) *Declaration { 62 | return s.elems[name] 63 | } 64 | 65 | // LookupParent follows the parent chain of scopes starting with s until 66 | // it finds a scope where Lookup(name) returns a non-nil object, and then 67 | // returns that scope and object. If a valid position pos is provided, 68 | // only objects that were declared at or before pos are considered. 69 | // If no such scope and object exists, the result is (nil, nil). 70 | // 71 | // Note that obj.Parent() may be different from the returned scope if the 72 | // object was inserted into the scope and already had a parent at that 73 | // time (see Insert, below). This can only happen for dot-imported objects 74 | // whose scope is the scope of the package that exported them. 75 | func (s *Scope) LookupParent(name string, pos Pos) (*Scope, *Declaration) { 76 | for ; s != nil; s = s.parent { 77 | if obj := s.elems[name]; obj != nil && (!pos.IsValid() || obj.StartPos.LessEq(pos)) { 78 | return s, obj 79 | } 80 | } 81 | return nil, nil 82 | } 83 | 84 | // Insert attempts to insert an object obj into scope s. 85 | // If s already contains an alternative object alt with 86 | // the same name, Insert leaves s unchanged and returns alt. 87 | // Otherwise it inserts obj, sets the object's parent scope 88 | // if not already set, and returns nil. 89 | func (s *Scope) Insert(obj *Declaration) *Declaration { 90 | name := obj.Name 91 | if alt := s.elems[name]; alt != nil { 92 | return alt 93 | } 94 | if s.elems == nil { 95 | s.elems = make(map[string]*Declaration) 96 | } 97 | s.elems[name] = obj 98 | if obj.Parent == nil { 99 | obj.Parent = s 100 | } 101 | return nil 102 | } 103 | 104 | // StartPos and End describe the scope's source code extent [pos, end). 105 | // The results are guaranteed to be valid only if the type-checked 106 | // AST has complete position information. The extent is undefined 107 | // for Universe and package scopes. 108 | func (s *Scope) Pos() Pos { return s.pos } 109 | func (s *Scope) End() Pos { return s.end } 110 | 111 | // Contains reports whether pos is within the scope's extent. 112 | // The result is guaranteed to be valid only if the type-checked 113 | // AST has complete position information. 114 | func (s *Scope) Contains(pos Pos) bool { 115 | return s.pos.LessEq(pos) && pos.Less(s.end) 116 | } 117 | 118 | // Innermost returns the innermost (child) scope containing 119 | // pos. If pos is not within any scope, the result is nil. 120 | // The result is also nil for the Universe scope. 121 | // The result is guaranteed to be valid only if the type-checked 122 | // AST has complete position information. 123 | func (s *Scope) Innermost(pos Pos) *Scope { 124 | // Package scopes do not have extents since they may be 125 | // discontiguous, so iterate over the package's files. 126 | if s.parent == Universe { 127 | for _, s := range s.children { 128 | if inner := s.Innermost(pos); inner != nil { 129 | return inner 130 | } 131 | } 132 | } 133 | 134 | if s.Contains(pos) { 135 | for _, s := range s.children { 136 | if s.Contains(pos) { 137 | return s.Innermost(pos) 138 | } 139 | } 140 | return s 141 | } 142 | return nil 143 | } 144 | 145 | // WriteTo writes a string representation of the scope to w, 146 | // with the scope elements sorted by name. 147 | // The level of indentation is controlled by n >= 0, with 148 | // n == 0 for no indentation. 149 | // If recurse is set, it also writes nested (children) scopes. 150 | func (s *Scope) WriteTo(w io.Writer, n int, recurse bool) { 151 | const ind = ". " 152 | indn := strings.Repeat(ind, n) 153 | 154 | fmt.Fprintf(w, "%s scope %p {\n", indn, s) 155 | 156 | indn1 := indn + ind 157 | for _, name := range s.Names() { 158 | fmt.Fprintf(w, "%s%s\n", indn1, s.elems[name]) 159 | } 160 | 161 | if recurse { 162 | for _, s := range s.children { 163 | s.WriteTo(w, n+1, recurse) 164 | } 165 | } 166 | 167 | fmt.Fprintf(w, "%s}\n", indn) 168 | } 169 | 170 | // String returns a string representation of the scope, for debugging. 171 | func (s *Scope) String() string { 172 | var buf bytes.Buffer 173 | s.WriteTo(&buf, 0, false) 174 | return buf.String() 175 | } 176 | -------------------------------------------------------------------------------- /Jsonnet.g4: -------------------------------------------------------------------------------- 1 | // language spec: https://jsonnet.org/ref/spec.html 2 | // language tutorial: https://jsonnet.org/learning/tutorial.html 3 | // grammar from: https://gist.github.com/ironchefpython/84380aa60871853dc86719dd598c35e4 4 | // slightly changed the slice rule 5 | grammar Jsonnet; 6 | 7 | jsonnet 8 | : expr EOF 9 | ; 10 | 11 | expr 12 | : value=(NULL | TRUE | FALSE | SELF | DOLLAR | STRING | NUMBER ) # Value 13 | | '(' expr ')' # Parens 14 | | '{' objinside? '}' # Object 15 | | '[' ( elems+=expr (',' elems+=expr)* )? ','? ']' # Array 16 | | '[' expr ','? forspec+ ']' # ArrayComp 17 | | expr '.' ID # Index 18 | | expr '[' expr ']' # IndexExpr 19 | | expr '[' startIdx=expr? ':' endIdx=expr? (':' step=expr? )? ']' # Slice 20 | | SUPER . ID # IndexSuper 21 | | SUPER '[' expr ']' # IndexSuperExpr 22 | | expr '(' args? ')' TAILSTRICT? # Apply 23 | | ID # Var 24 | | IF expr THEN expr ( ELSE expr )? # IfThenElse 25 | | op=(PLUS | MINUS | NOT | BITNOT) expr # UnaryExpr 26 | | expr op=(MULTIPLY | DIVIDE | MODULUS) expr # BinaryExpr 27 | | expr op=(PLUS | MINUS) expr # BinaryExpr 28 | | expr op=(SHIFTLEFT | SHIFTRIGHT) expr # BinaryExpr 29 | | expr op=(GT | GE | LT | LE | IN) expr # BinaryExpr 30 | | expr op=(EQUALS | NOTEQUALS) expr # BinaryExpr 31 | | expr op=BITAND expr # BinaryExpr 32 | | expr op=BITXOR expr # BinaryExpr 33 | | expr op=BITOR expr # BinaryExpr 34 | | expr op=AND expr # BinaryExpr 35 | | expr op=OR expr # BinaryExpr 36 | | expr '{' objinside? '}' # ApplyBrace 37 | | FUNCTION '(' params? ')' expr # Function 38 | | assertion ';' expr # Assert 39 | | IMPORT STRING # Import 40 | | IMPORTSTR STRING # Import 41 | | ERROR expr # ErrorExpr 42 | | expr IN SUPER # InSuper 43 | | LOCAL binds+=bind (',' binds+=bind)* ';' expr # LocalBind 44 | ; 45 | 46 | 47 | objinside 48 | : members+=member (',' members+=member)* ','? # Members 49 | | ( objlocal ',' )* '[' key=expr ']' ':' value=expr ( ',' objlocal )* ','? forspec+ 50 | # ObjectComp 51 | ; 52 | 53 | member 54 | : objlocal | assertion | field 55 | ; 56 | 57 | field 58 | : fieldname PLUS? visibility expr # ValueField 59 | | fieldname '(' params? ')' visibility expr # FunctionField 60 | ; 61 | 62 | visibility 63 | : ':' 64 | | ':' ':' 65 | | ':' ':' ':' 66 | ; 67 | 68 | objlocal 69 | : LOCAL bind 70 | ; 71 | 72 | forspec 73 | : FOR ID IN expr ifspec* 74 | ; 75 | 76 | ifspec 77 | : IF expr 78 | ; 79 | 80 | fieldname 81 | : ID 82 | | STRING 83 | | '[' expr ']' 84 | ; 85 | 86 | assertion 87 | : ASSERT condition=expr (':' message=expr)? 88 | ; 89 | 90 | 91 | bind 92 | : ID '=' expr # ValueBind 93 | | ID '(' params? ')' '=' expr # FunctionBind 94 | ; 95 | 96 | 97 | args 98 | : pos+=expr ( ',' pos+=expr )* ( ',' names+=ID '=' named+=expr )* ','? 99 | | names+=ID '=' named+=expr ( ',' names+=ID '=' named+=expr )* ','? 100 | ; 101 | 102 | params 103 | : pos+=ID ( ',' pos+=ID )* ( ',' names+=ID '=' defaults+=expr )* ','? 104 | | names+=ID '=' defaults+=expr ( ',' names+=ID '=' defaults+=expr )* ','? 105 | ; 106 | 107 | 108 | DOLLAR : '$'; 109 | 110 | ASSERT : 'assert'; 111 | ELSE : 'else'; 112 | ERROR : 'error'; 113 | FALSE : 'false'; 114 | FOR : 'for'; 115 | FUNCTION : 'function'; 116 | IF : 'if'; 117 | IMPORT : 'import'; 118 | IMPORTSTR : 'importstr'; 119 | LOCAL : 'local'; 120 | NULL : 'null'; 121 | SELF : 'self'; 122 | SUPER : 'super'; 123 | TAILSTRICT: 'tailstrict'; 124 | THEN : 'then'; 125 | TRUE : 'true'; 126 | 127 | EQUALS : '==' ; 128 | NOTEQUALS : '!='; 129 | PLUS : '+'; 130 | MINUS : '-'; 131 | MULTIPLY : '*'; 132 | DIVIDE : '/'; 133 | MODULUS : '%'; 134 | AND : '&&'; 135 | OR : '||'; 136 | NOT : '!'; 137 | GT : '>'; 138 | GE : '>='; 139 | LT : '<'; 140 | LE : '<='; 141 | IN : 'in'; 142 | SHIFTLEFT : '<<'; 143 | SHIFTRIGHT: '>>'; 144 | BITNOT : '~'; 145 | BITAND : '&'; 146 | BITXOR : '^'; 147 | BITOR : '|'; 148 | 149 | STRING 150 | : '"' (ESCAPES | UNICODE | ~["\\\u0000-\u001F])* '"' 151 | | '\'' (ESCAPES | UNICODE | ~['\\\u0000-\u001F])* '\'' 152 | | '@' '"' ('""' | ~["])* '"' 153 | | '@' '\'' ('\'\'' | ~['])* '\'' 154 | | '@' '\'' ('\'\'' | ~['])* '\'' 155 | | '|||' ( ~'|' | '|' ~'|' | '||' ~'|' )* '|||' 156 | ; 157 | 158 | NUMBER: INT ( '.' DIGIT+ )? EXP?; 159 | 160 | ID: ALPHA (ALPHA | DIGIT)*; 161 | 162 | fragment ESCAPES: '\\' ["'\\/bfnrt]; 163 | fragment DIGIT: [0-9]; 164 | fragment ALPHA: [_a-zA-Z]; 165 | fragment UNICODE: 'u' HEX HEX HEX HEX; 166 | fragment HEX: [0-9a-fA-F]; 167 | fragment INT: '0' | [1-9] DIGIT*; 168 | fragment EXP: [Ee] [+\-]? DIGIT+; 169 | 170 | Whitespace 171 | : [ \t]+ -> skip 172 | ; 173 | 174 | Newline 175 | : ( '\r' '\n'? | '\n' ) -> skip 176 | ; 177 | 178 | BlockComment 179 | : '/*' .*? '*/' -> skip 180 | ; 181 | 182 | LineComment 183 | : ('//'|'#') ~[\r\n]* -> skip 184 | ; 185 | -------------------------------------------------------------------------------- /refs/listener.go: -------------------------------------------------------------------------------- 1 | package refs 2 | 3 | import ( 4 | "fmt" 5 | "io/ioutil" 6 | 7 | "github.com/antlr/antlr4/runtime/Go/antlr" 8 | "lsif-jsonnet/parser" 9 | "lsif-jsonnet/types" 10 | ) 11 | 12 | type Listener struct { 13 | pathResolver *PathResolver 14 | *parser.BaseJsonnetListener 15 | file string 16 | dcls []*types.Declaration 17 | imports []*Listener 18 | currentScope *types.Scope 19 | fileScope *types.Scope 20 | errs []error 21 | } 22 | 23 | func ParseFile(path string, pathResolver *PathResolver) (*Listener, error) { 24 | data, err := ioutil.ReadFile(path) 25 | if err != nil { 26 | return nil, err 27 | } 28 | 29 | return ParseData(data, path, pathResolver) 30 | } 31 | 32 | func ParseData(data []byte, path string, pathResolver *PathResolver) (*Listener, error) { 33 | is := antlr.NewInputStream(string(data)) 34 | 35 | lexer := parser.NewJsonnetLexer(is) 36 | stream := antlr.NewCommonTokenStream(lexer, antlr.TokenDefaultChannel) 37 | 38 | p := parser.NewJsonnetParser(stream) 39 | 40 | ast := p.Jsonnet() 41 | 42 | startPos, endPos := types.NewPos(ast.GetStart()), types.NewPos(ast.GetStop()) 43 | 44 | ll := NewListener(path, startPos, endPos, pathResolver) 45 | 46 | // Finally walk the tree 47 | antlr.ParseTreeWalkerDefault.Walk(ll, ast) 48 | 49 | return ll, nil 50 | } 51 | 52 | func NewListener(file string, pos, end types.Pos, pathResolver *PathResolver) *Listener { 53 | scope := types.NewScope(types.Universe, pos, end) 54 | ll := &Listener{ 55 | currentScope: scope, 56 | fileScope: scope, 57 | file: file, 58 | pathResolver: pathResolver, 59 | } 60 | return ll 61 | } 62 | 63 | func (ll *Listener) File() string { 64 | return ll.file 65 | } 66 | 67 | func (ll *Listener) Declarations() []*types.Declaration { 68 | return ll.dcls 69 | } 70 | 71 | func (ll *Listener) Imports() []*Listener { 72 | return ll.imports 73 | } 74 | 75 | func (ll *Listener) EnterFunctionBind(ctx *parser.FunctionBindContext) { 76 | id := ctx.ID() 77 | startPos, endPos := types.NewPos(ctx.GetStart()), types.NewPos(ctx.GetStop()) 78 | 79 | obj := ll.addDeclaration(id.GetSymbol(), types.FunctionDeclaration) 80 | 81 | scope := types.NewScope(ll.currentScope, startPos, endPos) 82 | ll.currentScope = scope 83 | obj.Inner = scope 84 | } 85 | 86 | func (ll *Listener) ExitFunctionBind(*parser.FunctionBindContext) { 87 | ll.currentScope = ll.currentScope.Parent() 88 | } 89 | 90 | func (ll *Listener) EnterFunctionField(ctx *parser.FunctionFieldContext) { 91 | fieldName := ctx.Fieldname() 92 | 93 | switch v := fieldName.(type) { 94 | case *parser.FieldnameContext: 95 | startPos, endPos := types.NewPos(ctx.GetStart()), types.NewPos(ctx.GetStop()) 96 | 97 | obj := ll.addDeclaration(v.ID().GetSymbol(), types.FunctionDeclaration) 98 | 99 | scope := types.NewScope(ll.currentScope, startPos, endPos) 100 | ll.currentScope = scope 101 | obj.Inner = scope 102 | default: 103 | } 104 | } 105 | 106 | // ExitFunctionField is called when production FunctionField is exited. 107 | func (ll *Listener) ExitFunctionField(*parser.FunctionFieldContext) { 108 | ll.currentScope = ll.currentScope.Parent() 109 | } 110 | 111 | func stripQuotes(str string) string { 112 | n := len(str) 113 | return str[1 : n-1] 114 | } 115 | 116 | func (ll *Listener) EnterValueBind(ctx *parser.ValueBindContext) { 117 | id := ctx.ID() 118 | startPos, endPos := types.NewPos(ctx.GetStart()), types.NewPos(ctx.GetStop()) 119 | 120 | obj := ll.addDeclaration(id.GetSymbol(), types.ValueDeclaration) 121 | 122 | scope := types.NewScope(ll.currentScope, startPos, endPos) 123 | ll.currentScope = scope 124 | 125 | rhs := ctx.Expr() 126 | switch v := rhs.(type) { 127 | case *parser.ImportContext: 128 | obj.Type = types.ImportDeclaration 129 | path := stripQuotes(v.STRING().GetText()) 130 | 131 | resolvedPath, err := ll.pathResolver.Resolve(path) 132 | if err != nil { 133 | obj.Inner = scope 134 | ll.errs = append(ll.errs, fmt.Errorf("failed to resolve import %s: %w", path, err)) 135 | } else { 136 | ill, err := ParseFile(resolvedPath, ll.pathResolver) 137 | if err != nil { 138 | obj.Inner = scope 139 | ll.errs = append(ll.errs, fmt.Errorf("failed to parse %s: %w", resolvedPath, err)) 140 | } else { 141 | ll.imports = append(ll.imports, ill) 142 | obj.Inner = ill.fileScope 143 | } 144 | } 145 | default: 146 | obj.Inner = scope 147 | } 148 | } 149 | 150 | func (ll *Listener) addDeclaration(token antlr.Token, declType string) *types.Declaration { 151 | obj := &types.Declaration{ 152 | Name: token.GetText(), 153 | File: ll.file, 154 | StartPos: types.NewPos(token), 155 | Parent: ll.currentScope, 156 | Type: declType, 157 | } 158 | 159 | ll.dcls = append(ll.dcls, obj) 160 | 161 | ll.currentScope.Insert(obj) 162 | return obj 163 | } 164 | 165 | func (ll *Listener) ExitValueBind(*parser.ValueBindContext) { 166 | ll.currentScope = ll.currentScope.Parent() 167 | } 168 | 169 | func (ll *Listener) EnterVar(ctx *parser.VarContext) { 170 | id := ctx.ID() 171 | pos := types.NewPos(id.GetSymbol()) 172 | _, decl := ll.currentScope.LookupParent(id.GetText(), pos) 173 | 174 | if decl != nil { 175 | decl.Uses = append(decl.Uses, types.Use{StartPos: pos, File: ll.file}) 176 | } 177 | } 178 | 179 | func (ll *Listener) EnterParams(ctx *parser.ParamsContext) { 180 | for _, dcl := range ctx.GetPos() { 181 | ll.addDeclaration(dcl, types.ParamDeclaration) 182 | } 183 | for _, dcl := range ctx.GetNames() { 184 | ll.addDeclaration(dcl, types.ParamDeclaration) 185 | } 186 | } 187 | 188 | func (ll *Listener) EnterFunction(ctx *parser.FunctionContext) { 189 | startPos, endPos := types.NewPos(ctx.GetStart()), types.NewPos(ctx.GetStop()) 190 | 191 | scope := types.NewScope(ll.currentScope, startPos, endPos) 192 | ll.currentScope = scope 193 | } 194 | 195 | func (ll *Listener) ExitFunction(*parser.FunctionContext) { 196 | ll.currentScope = ll.currentScope.Parent() 197 | } 198 | 199 | func (ll *Listener) EnterIndex(ctx *parser.IndexContext) { 200 | id := ctx.ID() 201 | pos := types.NewPos(id.GetSymbol()) 202 | expr := ctx.Expr() 203 | 204 | switch v := expr.(type) { 205 | case *parser.VarContext: 206 | tt := v.ID() 207 | _, decl := ll.currentScope.LookupParent(tt.GetText(), types.NewPos(tt.GetSymbol())) 208 | if decl != nil && decl.Inner != nil { 209 | fieldDecl := decl.Inner.Lookup(id.GetText()) 210 | 211 | if fieldDecl != nil { 212 | fieldDecl.Uses = append(fieldDecl.Uses, types.Use{StartPos: pos, File: ll.file}) 213 | } 214 | } 215 | default: 216 | } 217 | } 218 | -------------------------------------------------------------------------------- /dumper/dumper.go: -------------------------------------------------------------------------------- 1 | package dumper 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "io" 7 | 8 | "lsif-jsonnet/protocol" 9 | "lsif-jsonnet/refs" 10 | "lsif-jsonnet/types" 11 | ) 12 | 13 | // Dumps LSIF: https://github.com/Microsoft/language-server-protocol/blob/master/indexFormat/specification.md 14 | type Dumper struct { 15 | projectRoot string 16 | w io.Writer 17 | id int 18 | encoder *json.Encoder 19 | docIDByFile map[string]int 20 | } 21 | 22 | func NewDumper(projectRoot string, w io.Writer) *Dumper { 23 | encoder := json.NewEncoder(w) 24 | 25 | return &Dumper{ 26 | projectRoot: projectRoot, 27 | w: w, 28 | encoder: encoder, 29 | docIDByFile: map[string]int{}, 30 | } 31 | } 32 | 33 | func (dmpr *Dumper) DumpProject(info *protocol.ToolInfo, lls []*refs.Listener) error { 34 | _, err := dmpr.emitMetaData("file://"+dmpr.projectRoot, info) 35 | if err != nil { 36 | return fmt.Errorf(`emit "metadata": %w`, err) 37 | } 38 | proID, err := dmpr.emitProject() 39 | if err != nil { 40 | return fmt.Errorf(`emit "project": %w`, err) 41 | } 42 | 43 | _, err = dmpr.emitBeginEvent("project", proID) 44 | if err != nil { 45 | return fmt.Errorf(`emit "begin": %w`, err) 46 | } 47 | 48 | for _, ll := range lls { 49 | err = dmpr.dumpListener(ll, proID) 50 | if err != nil { 51 | return err 52 | } 53 | } 54 | 55 | _, err = dmpr.emitEndEvent("project", proID) 56 | return err 57 | } 58 | 59 | func (dmpr *Dumper) dumpListener(ll *refs.Listener, proID int) error { 60 | docID, err := dmpr.emitDocument(ll.File()) 61 | if err != nil { 62 | return err 63 | } 64 | _, err = dmpr.emitBeginEvent("document", docID) 65 | if err != nil { 66 | return err 67 | } 68 | 69 | _, err = dmpr.emitContains(proID, []int{docID}) 70 | if err != nil { 71 | return err 72 | } 73 | 74 | for _, dcl := range ll.Declarations() { 75 | err = dmpr.emitDeclaration(dcl, docID) 76 | if err != nil { 77 | return err 78 | } 79 | } 80 | 81 | for _, ill := range ll.Imports() { 82 | err = dmpr.dumpListener(ill, proID) 83 | if err != nil { 84 | return err 85 | } 86 | } 87 | 88 | _, err = dmpr.emitEndEvent("document", docID) 89 | return err 90 | } 91 | 92 | func (dmpr *Dumper) emitDeclaration(dcl *types.Declaration, docID int) error { 93 | startPos := protocol.Pos{ 94 | Line: dcl.StartPos.Line - 1, 95 | Character: dcl.StartPos.Column, 96 | } 97 | endPos := protocol.Pos{ 98 | Line: dcl.StartPos.Line - 1, 99 | Character: dcl.StartPos.Column + len(dcl.Name), 100 | } 101 | 102 | rangeID, err := dmpr.emitRange(startPos, endPos) 103 | if err != nil { 104 | return err 105 | } 106 | 107 | _, err = dmpr.emitContains(docID, []int{rangeID}) 108 | if err != nil { 109 | return err 110 | } 111 | 112 | resultSetID, err := dmpr.emitResultSet() 113 | if err != nil { 114 | return err 115 | } 116 | 117 | _, err = dmpr.emitNext(rangeID, resultSetID) 118 | if err != nil { 119 | return err 120 | } 121 | 122 | defResultID, err := dmpr.emitDefinitionResult() 123 | if err != nil { 124 | return err 125 | } 126 | 127 | _, err = dmpr.emitTextDocumentDefinition(resultSetID, defResultID) 128 | if err != nil { 129 | return err 130 | } 131 | 132 | _, err = dmpr.emitItem(defResultID, []int{rangeID}, docID) 133 | if err != nil { 134 | return err 135 | } 136 | 137 | for _, use := range dcl.Uses { 138 | err = dmpr.emitUse(use, dcl, resultSetID) 139 | if err != nil { 140 | return err 141 | } 142 | } 143 | return nil 144 | } 145 | 146 | func (dmpr *Dumper) emitUse(use types.Use, dcl *types.Declaration, resultSetID int) error { 147 | startPos := protocol.Pos{ 148 | Line: use.StartPos.Line - 1, 149 | Character: use.StartPos.Column, 150 | } 151 | endPos := protocol.Pos{ 152 | Line: use.StartPos.Line - 1, 153 | Character: use.StartPos.Column + len(dcl.Name), 154 | } 155 | 156 | rangeID, err := dmpr.emitRange(startPos, endPos) 157 | if err != nil { 158 | return err 159 | } 160 | _, err = dmpr.emitNext(rangeID, resultSetID) 161 | if err != nil { 162 | return err 163 | } 164 | 165 | docID, ok := dmpr.docIDByFile[use.File] 166 | if !ok { 167 | return fmt.Errorf("document %s not declared", use.File) 168 | } 169 | 170 | _, err = dmpr.emitContains(docID, []int{rangeID}) 171 | return err 172 | } 173 | 174 | var newLineBytes = []byte("\n") 175 | 176 | func (dmpr *Dumper) writeNewLine() error { 177 | _, err := dmpr.w.Write(newLineBytes) 178 | return err 179 | } 180 | 181 | func (dmpr *Dumper) nextID() int { 182 | dmpr.id++ 183 | return dmpr.id 184 | } 185 | 186 | func (dmpr *Dumper) emit(v interface{}) error { 187 | return dmpr.encoder.Encode(v) 188 | } 189 | 190 | func (dmpr *Dumper) emitMetaData(root string, info *protocol.ToolInfo) (int, error) { 191 | id := dmpr.nextID() 192 | return id, dmpr.emit(protocol.NewMetaData(id, root, info)) 193 | } 194 | 195 | func (dmpr *Dumper) emitBeginEvent(scope string, data int) (int, error) { 196 | id := dmpr.nextID() 197 | return id, dmpr.emit(protocol.NewEvent(id, "begin", scope, data)) 198 | } 199 | 200 | func (dmpr *Dumper) emitEndEvent(scope string, data int) (int, error) { 201 | id := dmpr.nextID() 202 | return id, dmpr.emit(protocol.NewEvent(id, "end", scope, data)) 203 | } 204 | 205 | func (dmpr *Dumper) emitProject() (int, error) { 206 | id := dmpr.nextID() 207 | return id, dmpr.emit(protocol.NewProject(id)) 208 | } 209 | 210 | func (dmpr *Dumper) emitDocument(path string) (int, error) { 211 | id, ok := dmpr.docIDByFile[path] 212 | if !ok { 213 | id = dmpr.nextID() 214 | dmpr.docIDByFile[path] = id 215 | } 216 | return id, dmpr.emit(protocol.NewDocument(id, "file://"+path, nil)) 217 | } 218 | 219 | func (dmpr *Dumper) emitContains(outV int, inVs []int) (int, error) { 220 | id := dmpr.nextID() 221 | return id, dmpr.emit(protocol.NewContains(id, outV, inVs)) 222 | } 223 | 224 | func (dmpr *Dumper) emitResultSet() (int, error) { 225 | id := dmpr.nextID() 226 | return id, dmpr.emit(protocol.NewResultSet(id)) 227 | } 228 | 229 | func (dmpr *Dumper) emitRange(start, end protocol.Pos) (int, error) { 230 | id := dmpr.nextID() 231 | return id, dmpr.emit(protocol.NewRange(id, start, end)) 232 | } 233 | 234 | func (dmpr *Dumper) emitNext(outV, inV int) (int, error) { 235 | id := dmpr.nextID() 236 | return id, dmpr.emit(protocol.NewNext(id, outV, inV)) 237 | } 238 | 239 | func (dmpr *Dumper) emitDefinitionResult() (int, error) { 240 | id := dmpr.nextID() 241 | return id, dmpr.emit(protocol.NewDefinitionResult(id)) 242 | } 243 | 244 | func (dmpr *Dumper) emitTextDocumentDefinition(outV, inV int) (int, error) { 245 | id := dmpr.nextID() 246 | return id, dmpr.emit(protocol.NewTextDocumentDefinition(id, outV, inV)) 247 | } 248 | 249 | func (dmpr *Dumper) emitItem(outV int, inVs []int, docID int) (int, error) { 250 | id := dmpr.nextID() 251 | return id, dmpr.emit(protocol.NewItem(id, outV, inVs, docID)) 252 | } 253 | -------------------------------------------------------------------------------- /parser/jsonnet_listener.go: -------------------------------------------------------------------------------- 1 | // Code generated from Jsonnet.g4 by ANTLR 4.8. DO NOT EDIT. 2 | 3 | package parser // Jsonnet 4 | 5 | import "github.com/antlr/antlr4/runtime/Go/antlr" 6 | 7 | // JsonnetListener is a complete listener for a parse tree produced by JsonnetParser. 8 | type JsonnetListener interface { 9 | antlr.ParseTreeListener 10 | 11 | // EnterJsonnet is called when entering the jsonnet production. 12 | EnterJsonnet(c *JsonnetContext) 13 | 14 | // EnterImport is called when entering the Import production. 15 | EnterImport(c *ImportContext) 16 | 17 | // EnterParens is called when entering the Parens production. 18 | EnterParens(c *ParensContext) 19 | 20 | // EnterVar is called when entering the Var production. 21 | EnterVar(c *VarContext) 22 | 23 | // EnterApply is called when entering the Apply production. 24 | EnterApply(c *ApplyContext) 25 | 26 | // EnterBinaryExpr is called when entering the BinaryExpr production. 27 | EnterBinaryExpr(c *BinaryExprContext) 28 | 29 | // EnterApplyBrace is called when entering the ApplyBrace production. 30 | EnterApplyBrace(c *ApplyBraceContext) 31 | 32 | // EnterIndex is called when entering the Index production. 33 | EnterIndex(c *IndexContext) 34 | 35 | // EnterUnaryExpr is called when entering the UnaryExpr production. 36 | EnterUnaryExpr(c *UnaryExprContext) 37 | 38 | // EnterIndexExpr is called when entering the IndexExpr production. 39 | EnterIndexExpr(c *IndexExprContext) 40 | 41 | // EnterArray is called when entering the Array production. 42 | EnterArray(c *ArrayContext) 43 | 44 | // EnterFunction is called when entering the Function production. 45 | EnterFunction(c *FunctionContext) 46 | 47 | // EnterErrorExpr is called when entering the ErrorExpr production. 48 | EnterErrorExpr(c *ErrorExprContext) 49 | 50 | // EnterInSuper is called when entering the InSuper production. 51 | EnterInSuper(c *InSuperContext) 52 | 53 | // EnterArrayComp is called when entering the ArrayComp production. 54 | EnterArrayComp(c *ArrayCompContext) 55 | 56 | // EnterAssert is called when entering the Assert production. 57 | EnterAssert(c *AssertContext) 58 | 59 | // EnterIndexSuperExpr is called when entering the IndexSuperExpr production. 60 | EnterIndexSuperExpr(c *IndexSuperExprContext) 61 | 62 | // EnterSlice is called when entering the Slice production. 63 | EnterSlice(c *SliceContext) 64 | 65 | // EnterValue is called when entering the Value production. 66 | EnterValue(c *ValueContext) 67 | 68 | // EnterIndexSuper is called when entering the IndexSuper production. 69 | EnterIndexSuper(c *IndexSuperContext) 70 | 71 | // EnterObject is called when entering the Object production. 72 | EnterObject(c *ObjectContext) 73 | 74 | // EnterIfThenElse is called when entering the IfThenElse production. 75 | EnterIfThenElse(c *IfThenElseContext) 76 | 77 | // EnterLocalBind is called when entering the LocalBind production. 78 | EnterLocalBind(c *LocalBindContext) 79 | 80 | // EnterMembers is called when entering the Members production. 81 | EnterMembers(c *MembersContext) 82 | 83 | // EnterObjectComp is called when entering the ObjectComp production. 84 | EnterObjectComp(c *ObjectCompContext) 85 | 86 | // EnterMember is called when entering the member production. 87 | EnterMember(c *MemberContext) 88 | 89 | // EnterValueField is called when entering the ValueField production. 90 | EnterValueField(c *ValueFieldContext) 91 | 92 | // EnterFunctionField is called when entering the FunctionField production. 93 | EnterFunctionField(c *FunctionFieldContext) 94 | 95 | // EnterVisibility is called when entering the visibility production. 96 | EnterVisibility(c *VisibilityContext) 97 | 98 | // EnterObjlocal is called when entering the objlocal production. 99 | EnterObjlocal(c *ObjlocalContext) 100 | 101 | // EnterForspec is called when entering the forspec production. 102 | EnterForspec(c *ForspecContext) 103 | 104 | // EnterIfspec is called when entering the ifspec production. 105 | EnterIfspec(c *IfspecContext) 106 | 107 | // EnterFieldname is called when entering the fieldname production. 108 | EnterFieldname(c *FieldnameContext) 109 | 110 | // EnterAssertion is called when entering the assertion production. 111 | EnterAssertion(c *AssertionContext) 112 | 113 | // EnterValueBind is called when entering the ValueBind production. 114 | EnterValueBind(c *ValueBindContext) 115 | 116 | // EnterFunctionBind is called when entering the FunctionBind production. 117 | EnterFunctionBind(c *FunctionBindContext) 118 | 119 | // EnterArgs is called when entering the args production. 120 | EnterArgs(c *ArgsContext) 121 | 122 | // EnterParams is called when entering the params production. 123 | EnterParams(c *ParamsContext) 124 | 125 | // ExitJsonnet is called when exiting the jsonnet production. 126 | ExitJsonnet(c *JsonnetContext) 127 | 128 | // ExitImport is called when exiting the Import production. 129 | ExitImport(c *ImportContext) 130 | 131 | // ExitParens is called when exiting the Parens production. 132 | ExitParens(c *ParensContext) 133 | 134 | // ExitVar is called when exiting the Var production. 135 | ExitVar(c *VarContext) 136 | 137 | // ExitApply is called when exiting the Apply production. 138 | ExitApply(c *ApplyContext) 139 | 140 | // ExitBinaryExpr is called when exiting the BinaryExpr production. 141 | ExitBinaryExpr(c *BinaryExprContext) 142 | 143 | // ExitApplyBrace is called when exiting the ApplyBrace production. 144 | ExitApplyBrace(c *ApplyBraceContext) 145 | 146 | // ExitIndex is called when exiting the Index production. 147 | ExitIndex(c *IndexContext) 148 | 149 | // ExitUnaryExpr is called when exiting the UnaryExpr production. 150 | ExitUnaryExpr(c *UnaryExprContext) 151 | 152 | // ExitIndexExpr is called when exiting the IndexExpr production. 153 | ExitIndexExpr(c *IndexExprContext) 154 | 155 | // ExitArray is called when exiting the Array production. 156 | ExitArray(c *ArrayContext) 157 | 158 | // ExitFunction is called when exiting the Function production. 159 | ExitFunction(c *FunctionContext) 160 | 161 | // ExitErrorExpr is called when exiting the ErrorExpr production. 162 | ExitErrorExpr(c *ErrorExprContext) 163 | 164 | // ExitInSuper is called when exiting the InSuper production. 165 | ExitInSuper(c *InSuperContext) 166 | 167 | // ExitArrayComp is called when exiting the ArrayComp production. 168 | ExitArrayComp(c *ArrayCompContext) 169 | 170 | // ExitAssert is called when exiting the Assert production. 171 | ExitAssert(c *AssertContext) 172 | 173 | // ExitIndexSuperExpr is called when exiting the IndexSuperExpr production. 174 | ExitIndexSuperExpr(c *IndexSuperExprContext) 175 | 176 | // ExitSlice is called when exiting the Slice production. 177 | ExitSlice(c *SliceContext) 178 | 179 | // ExitValue is called when exiting the Value production. 180 | ExitValue(c *ValueContext) 181 | 182 | // ExitIndexSuper is called when exiting the IndexSuper production. 183 | ExitIndexSuper(c *IndexSuperContext) 184 | 185 | // ExitObject is called when exiting the Object production. 186 | ExitObject(c *ObjectContext) 187 | 188 | // ExitIfThenElse is called when exiting the IfThenElse production. 189 | ExitIfThenElse(c *IfThenElseContext) 190 | 191 | // ExitLocalBind is called when exiting the LocalBind production. 192 | ExitLocalBind(c *LocalBindContext) 193 | 194 | // ExitMembers is called when exiting the Members production. 195 | ExitMembers(c *MembersContext) 196 | 197 | // ExitObjectComp is called when exiting the ObjectComp production. 198 | ExitObjectComp(c *ObjectCompContext) 199 | 200 | // ExitMember is called when exiting the member production. 201 | ExitMember(c *MemberContext) 202 | 203 | // ExitValueField is called when exiting the ValueField production. 204 | ExitValueField(c *ValueFieldContext) 205 | 206 | // ExitFunctionField is called when exiting the FunctionField production. 207 | ExitFunctionField(c *FunctionFieldContext) 208 | 209 | // ExitVisibility is called when exiting the visibility production. 210 | ExitVisibility(c *VisibilityContext) 211 | 212 | // ExitObjlocal is called when exiting the objlocal production. 213 | ExitObjlocal(c *ObjlocalContext) 214 | 215 | // ExitForspec is called when exiting the forspec production. 216 | ExitForspec(c *ForspecContext) 217 | 218 | // ExitIfspec is called when exiting the ifspec production. 219 | ExitIfspec(c *IfspecContext) 220 | 221 | // ExitFieldname is called when exiting the fieldname production. 222 | ExitFieldname(c *FieldnameContext) 223 | 224 | // ExitAssertion is called when exiting the assertion production. 225 | ExitAssertion(c *AssertionContext) 226 | 227 | // ExitValueBind is called when exiting the ValueBind production. 228 | ExitValueBind(c *ValueBindContext) 229 | 230 | // ExitFunctionBind is called when exiting the FunctionBind production. 231 | ExitFunctionBind(c *FunctionBindContext) 232 | 233 | // ExitArgs is called when exiting the args production. 234 | ExitArgs(c *ArgsContext) 235 | 236 | // ExitParams is called when exiting the params production. 237 | ExitParams(c *ParamsContext) 238 | } 239 | -------------------------------------------------------------------------------- /parser/jsonnet_base_listener.go: -------------------------------------------------------------------------------- 1 | // Code generated from Jsonnet.g4 by ANTLR 4.8. DO NOT EDIT. 2 | 3 | package parser // Jsonnet 4 | 5 | import "github.com/antlr/antlr4/runtime/Go/antlr" 6 | 7 | // BaseJsonnetListener is a complete listener for a parse tree produced by JsonnetParser. 8 | type BaseJsonnetListener struct{} 9 | 10 | var _ JsonnetListener = &BaseJsonnetListener{} 11 | 12 | // VisitTerminal is called when a terminal node is visited. 13 | func (s *BaseJsonnetListener) VisitTerminal(node antlr.TerminalNode) {} 14 | 15 | // VisitErrorNode is called when an error node is visited. 16 | func (s *BaseJsonnetListener) VisitErrorNode(node antlr.ErrorNode) {} 17 | 18 | // EnterEveryRule is called when any rule is entered. 19 | func (s *BaseJsonnetListener) EnterEveryRule(ctx antlr.ParserRuleContext) {} 20 | 21 | // ExitEveryRule is called when any rule is exited. 22 | func (s *BaseJsonnetListener) ExitEveryRule(ctx antlr.ParserRuleContext) {} 23 | 24 | // EnterJsonnet is called when production jsonnet is entered. 25 | func (s *BaseJsonnetListener) EnterJsonnet(ctx *JsonnetContext) {} 26 | 27 | // ExitJsonnet is called when production jsonnet is exited. 28 | func (s *BaseJsonnetListener) ExitJsonnet(ctx *JsonnetContext) {} 29 | 30 | // EnterImport is called when production Import is entered. 31 | func (s *BaseJsonnetListener) EnterImport(ctx *ImportContext) {} 32 | 33 | // ExitImport is called when production Import is exited. 34 | func (s *BaseJsonnetListener) ExitImport(ctx *ImportContext) {} 35 | 36 | // EnterParens is called when production Parens is entered. 37 | func (s *BaseJsonnetListener) EnterParens(ctx *ParensContext) {} 38 | 39 | // ExitParens is called when production Parens is exited. 40 | func (s *BaseJsonnetListener) ExitParens(ctx *ParensContext) {} 41 | 42 | // EnterVar is called when production Var is entered. 43 | func (s *BaseJsonnetListener) EnterVar(ctx *VarContext) {} 44 | 45 | // ExitVar is called when production Var is exited. 46 | func (s *BaseJsonnetListener) ExitVar(ctx *VarContext) {} 47 | 48 | // EnterApply is called when production Apply is entered. 49 | func (s *BaseJsonnetListener) EnterApply(ctx *ApplyContext) {} 50 | 51 | // ExitApply is called when production Apply is exited. 52 | func (s *BaseJsonnetListener) ExitApply(ctx *ApplyContext) {} 53 | 54 | // EnterBinaryExpr is called when production BinaryExpr is entered. 55 | func (s *BaseJsonnetListener) EnterBinaryExpr(ctx *BinaryExprContext) {} 56 | 57 | // ExitBinaryExpr is called when production BinaryExpr is exited. 58 | func (s *BaseJsonnetListener) ExitBinaryExpr(ctx *BinaryExprContext) {} 59 | 60 | // EnterApplyBrace is called when production ApplyBrace is entered. 61 | func (s *BaseJsonnetListener) EnterApplyBrace(ctx *ApplyBraceContext) {} 62 | 63 | // ExitApplyBrace is called when production ApplyBrace is exited. 64 | func (s *BaseJsonnetListener) ExitApplyBrace(ctx *ApplyBraceContext) {} 65 | 66 | // EnterIndex is called when production Index is entered. 67 | func (s *BaseJsonnetListener) EnterIndex(ctx *IndexContext) {} 68 | 69 | // ExitIndex is called when production Index is exited. 70 | func (s *BaseJsonnetListener) ExitIndex(ctx *IndexContext) {} 71 | 72 | // EnterUnaryExpr is called when production UnaryExpr is entered. 73 | func (s *BaseJsonnetListener) EnterUnaryExpr(ctx *UnaryExprContext) {} 74 | 75 | // ExitUnaryExpr is called when production UnaryExpr is exited. 76 | func (s *BaseJsonnetListener) ExitUnaryExpr(ctx *UnaryExprContext) {} 77 | 78 | // EnterIndexExpr is called when production IndexExpr is entered. 79 | func (s *BaseJsonnetListener) EnterIndexExpr(ctx *IndexExprContext) {} 80 | 81 | // ExitIndexExpr is called when production IndexExpr is exited. 82 | func (s *BaseJsonnetListener) ExitIndexExpr(ctx *IndexExprContext) {} 83 | 84 | // EnterArray is called when production Array is entered. 85 | func (s *BaseJsonnetListener) EnterArray(ctx *ArrayContext) {} 86 | 87 | // ExitArray is called when production Array is exited. 88 | func (s *BaseJsonnetListener) ExitArray(ctx *ArrayContext) {} 89 | 90 | // EnterFunction is called when production Function is entered. 91 | func (s *BaseJsonnetListener) EnterFunction(ctx *FunctionContext) {} 92 | 93 | // ExitFunction is called when production Function is exited. 94 | func (s *BaseJsonnetListener) ExitFunction(ctx *FunctionContext) {} 95 | 96 | // EnterErrorExpr is called when production ErrorExpr is entered. 97 | func (s *BaseJsonnetListener) EnterErrorExpr(ctx *ErrorExprContext) {} 98 | 99 | // ExitErrorExpr is called when production ErrorExpr is exited. 100 | func (s *BaseJsonnetListener) ExitErrorExpr(ctx *ErrorExprContext) {} 101 | 102 | // EnterInSuper is called when production InSuper is entered. 103 | func (s *BaseJsonnetListener) EnterInSuper(ctx *InSuperContext) {} 104 | 105 | // ExitInSuper is called when production InSuper is exited. 106 | func (s *BaseJsonnetListener) ExitInSuper(ctx *InSuperContext) {} 107 | 108 | // EnterArrayComp is called when production ArrayComp is entered. 109 | func (s *BaseJsonnetListener) EnterArrayComp(ctx *ArrayCompContext) {} 110 | 111 | // ExitArrayComp is called when production ArrayComp is exited. 112 | func (s *BaseJsonnetListener) ExitArrayComp(ctx *ArrayCompContext) {} 113 | 114 | // EnterAssert is called when production Assert is entered. 115 | func (s *BaseJsonnetListener) EnterAssert(ctx *AssertContext) {} 116 | 117 | // ExitAssert is called when production Assert is exited. 118 | func (s *BaseJsonnetListener) ExitAssert(ctx *AssertContext) {} 119 | 120 | // EnterIndexSuperExpr is called when production IndexSuperExpr is entered. 121 | func (s *BaseJsonnetListener) EnterIndexSuperExpr(ctx *IndexSuperExprContext) {} 122 | 123 | // ExitIndexSuperExpr is called when production IndexSuperExpr is exited. 124 | func (s *BaseJsonnetListener) ExitIndexSuperExpr(ctx *IndexSuperExprContext) {} 125 | 126 | // EnterSlice is called when production Slice is entered. 127 | func (s *BaseJsonnetListener) EnterSlice(ctx *SliceContext) {} 128 | 129 | // ExitSlice is called when production Slice is exited. 130 | func (s *BaseJsonnetListener) ExitSlice(ctx *SliceContext) {} 131 | 132 | // EnterValue is called when production Value is entered. 133 | func (s *BaseJsonnetListener) EnterValue(ctx *ValueContext) {} 134 | 135 | // ExitValue is called when production Value is exited. 136 | func (s *BaseJsonnetListener) ExitValue(ctx *ValueContext) {} 137 | 138 | // EnterIndexSuper is called when production IndexSuper is entered. 139 | func (s *BaseJsonnetListener) EnterIndexSuper(ctx *IndexSuperContext) {} 140 | 141 | // ExitIndexSuper is called when production IndexSuper is exited. 142 | func (s *BaseJsonnetListener) ExitIndexSuper(ctx *IndexSuperContext) {} 143 | 144 | // EnterObject is called when production Object is entered. 145 | func (s *BaseJsonnetListener) EnterObject(ctx *ObjectContext) {} 146 | 147 | // ExitObject is called when production Object is exited. 148 | func (s *BaseJsonnetListener) ExitObject(ctx *ObjectContext) {} 149 | 150 | // EnterIfThenElse is called when production IfThenElse is entered. 151 | func (s *BaseJsonnetListener) EnterIfThenElse(ctx *IfThenElseContext) {} 152 | 153 | // ExitIfThenElse is called when production IfThenElse is exited. 154 | func (s *BaseJsonnetListener) ExitIfThenElse(ctx *IfThenElseContext) {} 155 | 156 | // EnterLocalBind is called when production LocalBind is entered. 157 | func (s *BaseJsonnetListener) EnterLocalBind(ctx *LocalBindContext) {} 158 | 159 | // ExitLocalBind is called when production LocalBind is exited. 160 | func (s *BaseJsonnetListener) ExitLocalBind(ctx *LocalBindContext) {} 161 | 162 | // EnterMembers is called when production Members is entered. 163 | func (s *BaseJsonnetListener) EnterMembers(ctx *MembersContext) {} 164 | 165 | // ExitMembers is called when production Members is exited. 166 | func (s *BaseJsonnetListener) ExitMembers(ctx *MembersContext) {} 167 | 168 | // EnterObjectComp is called when production ObjectComp is entered. 169 | func (s *BaseJsonnetListener) EnterObjectComp(ctx *ObjectCompContext) {} 170 | 171 | // ExitObjectComp is called when production ObjectComp is exited. 172 | func (s *BaseJsonnetListener) ExitObjectComp(ctx *ObjectCompContext) {} 173 | 174 | // EnterMember is called when production member is entered. 175 | func (s *BaseJsonnetListener) EnterMember(ctx *MemberContext) {} 176 | 177 | // ExitMember is called when production member is exited. 178 | func (s *BaseJsonnetListener) ExitMember(ctx *MemberContext) {} 179 | 180 | // EnterValueField is called when production ValueField is entered. 181 | func (s *BaseJsonnetListener) EnterValueField(ctx *ValueFieldContext) {} 182 | 183 | // ExitValueField is called when production ValueField is exited. 184 | func (s *BaseJsonnetListener) ExitValueField(ctx *ValueFieldContext) {} 185 | 186 | // EnterFunctionField is called when production FunctionField is entered. 187 | func (s *BaseJsonnetListener) EnterFunctionField(ctx *FunctionFieldContext) {} 188 | 189 | // ExitFunctionField is called when production FunctionField is exited. 190 | func (s *BaseJsonnetListener) ExitFunctionField(ctx *FunctionFieldContext) {} 191 | 192 | // EnterVisibility is called when production visibility is entered. 193 | func (s *BaseJsonnetListener) EnterVisibility(ctx *VisibilityContext) {} 194 | 195 | // ExitVisibility is called when production visibility is exited. 196 | func (s *BaseJsonnetListener) ExitVisibility(ctx *VisibilityContext) {} 197 | 198 | // EnterObjlocal is called when production objlocal is entered. 199 | func (s *BaseJsonnetListener) EnterObjlocal(ctx *ObjlocalContext) {} 200 | 201 | // ExitObjlocal is called when production objlocal is exited. 202 | func (s *BaseJsonnetListener) ExitObjlocal(ctx *ObjlocalContext) {} 203 | 204 | // EnterForspec is called when production forspec is entered. 205 | func (s *BaseJsonnetListener) EnterForspec(ctx *ForspecContext) {} 206 | 207 | // ExitForspec is called when production forspec is exited. 208 | func (s *BaseJsonnetListener) ExitForspec(ctx *ForspecContext) {} 209 | 210 | // EnterIfspec is called when production ifspec is entered. 211 | func (s *BaseJsonnetListener) EnterIfspec(ctx *IfspecContext) {} 212 | 213 | // ExitIfspec is called when production ifspec is exited. 214 | func (s *BaseJsonnetListener) ExitIfspec(ctx *IfspecContext) {} 215 | 216 | // EnterFieldname is called when production fieldname is entered. 217 | func (s *BaseJsonnetListener) EnterFieldname(ctx *FieldnameContext) {} 218 | 219 | // ExitFieldname is called when production fieldname is exited. 220 | func (s *BaseJsonnetListener) ExitFieldname(ctx *FieldnameContext) {} 221 | 222 | // EnterAssertion is called when production assertion is entered. 223 | func (s *BaseJsonnetListener) EnterAssertion(ctx *AssertionContext) {} 224 | 225 | // ExitAssertion is called when production assertion is exited. 226 | func (s *BaseJsonnetListener) ExitAssertion(ctx *AssertionContext) {} 227 | 228 | // EnterValueBind is called when production ValueBind is entered. 229 | func (s *BaseJsonnetListener) EnterValueBind(ctx *ValueBindContext) {} 230 | 231 | // ExitValueBind is called when production ValueBind is exited. 232 | func (s *BaseJsonnetListener) ExitValueBind(ctx *ValueBindContext) {} 233 | 234 | // EnterFunctionBind is called when production FunctionBind is entered. 235 | func (s *BaseJsonnetListener) EnterFunctionBind(ctx *FunctionBindContext) {} 236 | 237 | // ExitFunctionBind is called when production FunctionBind is exited. 238 | func (s *BaseJsonnetListener) ExitFunctionBind(ctx *FunctionBindContext) {} 239 | 240 | // EnterArgs is called when production args is entered. 241 | func (s *BaseJsonnetListener) EnterArgs(ctx *ArgsContext) {} 242 | 243 | // ExitArgs is called when production args is exited. 244 | func (s *BaseJsonnetListener) ExitArgs(ctx *ArgsContext) {} 245 | 246 | // EnterParams is called when production params is entered. 247 | func (s *BaseJsonnetListener) EnterParams(ctx *ParamsContext) {} 248 | 249 | // ExitParams is called when production params is exited. 250 | func (s *BaseJsonnetListener) ExitParams(ctx *ParamsContext) {} 251 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /parser/Jsonnet.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | '(' 4 | ')' 5 | '{' 6 | '}' 7 | '[' 8 | ',' 9 | ']' 10 | '.' 11 | ':' 12 | ';' 13 | '=' 14 | '$' 15 | 'assert' 16 | 'else' 17 | 'error' 18 | 'false' 19 | 'for' 20 | 'function' 21 | 'if' 22 | 'import' 23 | 'importstr' 24 | 'local' 25 | 'null' 26 | 'self' 27 | 'super' 28 | 'tailstrict' 29 | 'then' 30 | 'true' 31 | '==' 32 | '!=' 33 | '+' 34 | '-' 35 | '*' 36 | '/' 37 | '%' 38 | '&&' 39 | '||' 40 | '!' 41 | '>' 42 | '>=' 43 | '<' 44 | '<=' 45 | 'in' 46 | '<<' 47 | '>>' 48 | '~' 49 | '&' 50 | '^' 51 | '|' 52 | null 53 | null 54 | null 55 | null 56 | null 57 | null 58 | null 59 | 60 | token symbolic names: 61 | null 62 | null 63 | null 64 | null 65 | null 66 | null 67 | null 68 | null 69 | null 70 | null 71 | null 72 | null 73 | DOLLAR 74 | ASSERT 75 | ELSE 76 | ERROR 77 | FALSE 78 | FOR 79 | FUNCTION 80 | IF 81 | IMPORT 82 | IMPORTSTR 83 | LOCAL 84 | NULL 85 | SELF 86 | SUPER 87 | TAILSTRICT 88 | THEN 89 | TRUE 90 | EQUALS 91 | NOTEQUALS 92 | PLUS 93 | MINUS 94 | MULTIPLY 95 | DIVIDE 96 | MODULUS 97 | AND 98 | OR 99 | NOT 100 | GT 101 | GE 102 | LT 103 | LE 104 | IN 105 | SHIFTLEFT 106 | SHIFTRIGHT 107 | BITNOT 108 | BITAND 109 | BITXOR 110 | BITOR 111 | STRING 112 | NUMBER 113 | ID 114 | Whitespace 115 | Newline 116 | BlockComment 117 | LineComment 118 | 119 | rule names: 120 | jsonnet 121 | expr 122 | objinside 123 | member 124 | field 125 | visibility 126 | objlocal 127 | forspec 128 | ifspec 129 | fieldname 130 | assertion 131 | bind 132 | args 133 | params 134 | 135 | 136 | atn: 137 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 58, 388, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 42, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 49, 10, 3, 12, 3, 14, 3, 52, 11, 3, 5, 3, 54, 10, 3, 3, 3, 5, 3, 57, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 63, 10, 3, 3, 3, 6, 3, 66, 10, 3, 13, 3, 14, 3, 67, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 87, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 94, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 112, 10, 3, 12, 3, 14, 3, 115, 11, 3, 3, 3, 3, 3, 3, 3, 5, 3, 120, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 163, 10, 3, 3, 3, 3, 3, 5, 3, 167, 10, 3, 3, 3, 3, 3, 5, 3, 171, 10, 3, 5, 3, 173, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 179, 10, 3, 3, 3, 3, 3, 5, 3, 183, 10, 3, 3, 3, 3, 3, 3, 3, 5, 3, 188, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 7, 3, 194, 10, 3, 12, 3, 14, 3, 197, 11, 3, 3, 4, 3, 4, 3, 4, 7, 4, 202, 10, 4, 12, 4, 14, 4, 205, 11, 4, 3, 4, 5, 4, 208, 10, 4, 3, 4, 3, 4, 3, 4, 7, 4, 213, 10, 4, 12, 4, 14, 4, 216, 11, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 7, 4, 225, 10, 4, 12, 4, 14, 4, 228, 11, 4, 3, 4, 5, 4, 231, 10, 4, 3, 4, 6, 4, 234, 10, 4, 13, 4, 14, 4, 235, 5, 4, 238, 10, 4, 3, 5, 3, 5, 3, 5, 5, 5, 243, 10, 5, 3, 6, 3, 6, 5, 6, 247, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 255, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 261, 10, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 5, 7, 269, 10, 7, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 7, 9, 279, 10, 9, 12, 9, 14, 9, 282, 11, 9, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 5, 11, 293, 10, 11, 3, 12, 3, 12, 3, 12, 3, 12, 5, 12, 299, 10, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 5, 13, 307, 10, 13, 3, 13, 3, 13, 3, 13, 5, 13, 312, 10, 13, 3, 14, 3, 14, 3, 14, 7, 14, 317, 10, 14, 12, 14, 14, 14, 320, 11, 14, 3, 14, 3, 14, 3, 14, 3, 14, 7, 14, 326, 10, 14, 12, 14, 14, 14, 329, 11, 14, 3, 14, 5, 14, 332, 10, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 7, 14, 341, 10, 14, 12, 14, 14, 14, 344, 11, 14, 3, 14, 5, 14, 347, 10, 14, 5, 14, 349, 10, 14, 3, 15, 3, 15, 3, 15, 7, 15, 354, 10, 15, 12, 15, 14, 15, 357, 11, 15, 3, 15, 3, 15, 3, 15, 3, 15, 7, 15, 363, 10, 15, 12, 15, 14, 15, 366, 11, 15, 3, 15, 5, 15, 369, 10, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 7, 15, 378, 10, 15, 12, 15, 14, 15, 381, 11, 15, 3, 15, 5, 15, 384, 10, 15, 5, 15, 386, 10, 15, 3, 15, 2, 3, 4, 16, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 2, 9, 7, 2, 14, 14, 18, 18, 25, 26, 30, 30, 52, 53, 5, 2, 33, 34, 40, 40, 48, 48, 3, 2, 35, 37, 3, 2, 33, 34, 3, 2, 46, 47, 3, 2, 41, 45, 3, 2, 31, 32, 2, 452, 2, 30, 3, 2, 2, 2, 4, 119, 3, 2, 2, 2, 6, 237, 3, 2, 2, 2, 8, 242, 3, 2, 2, 2, 10, 260, 3, 2, 2, 2, 12, 268, 3, 2, 2, 2, 14, 270, 3, 2, 2, 2, 16, 273, 3, 2, 2, 2, 18, 283, 3, 2, 2, 2, 20, 292, 3, 2, 2, 2, 22, 294, 3, 2, 2, 2, 24, 311, 3, 2, 2, 2, 26, 348, 3, 2, 2, 2, 28, 385, 3, 2, 2, 2, 30, 31, 5, 4, 3, 2, 31, 32, 7, 2, 2, 3, 32, 3, 3, 2, 2, 2, 33, 34, 8, 3, 1, 2, 34, 120, 9, 2, 2, 2, 35, 36, 7, 3, 2, 2, 36, 37, 5, 4, 3, 2, 37, 38, 7, 4, 2, 2, 38, 120, 3, 2, 2, 2, 39, 41, 7, 5, 2, 2, 40, 42, 5, 6, 4, 2, 41, 40, 3, 2, 2, 2, 41, 42, 3, 2, 2, 2, 42, 43, 3, 2, 2, 2, 43, 120, 7, 6, 2, 2, 44, 53, 7, 7, 2, 2, 45, 50, 5, 4, 3, 2, 46, 47, 7, 8, 2, 2, 47, 49, 5, 4, 3, 2, 48, 46, 3, 2, 2, 2, 49, 52, 3, 2, 2, 2, 50, 48, 3, 2, 2, 2, 50, 51, 3, 2, 2, 2, 51, 54, 3, 2, 2, 2, 52, 50, 3, 2, 2, 2, 53, 45, 3, 2, 2, 2, 53, 54, 3, 2, 2, 2, 54, 56, 3, 2, 2, 2, 55, 57, 7, 8, 2, 2, 56, 55, 3, 2, 2, 2, 56, 57, 3, 2, 2, 2, 57, 58, 3, 2, 2, 2, 58, 120, 7, 9, 2, 2, 59, 60, 7, 7, 2, 2, 60, 62, 5, 4, 3, 2, 61, 63, 7, 8, 2, 2, 62, 61, 3, 2, 2, 2, 62, 63, 3, 2, 2, 2, 63, 65, 3, 2, 2, 2, 64, 66, 5, 16, 9, 2, 65, 64, 3, 2, 2, 2, 66, 67, 3, 2, 2, 2, 67, 65, 3, 2, 2, 2, 67, 68, 3, 2, 2, 2, 68, 69, 3, 2, 2, 2, 69, 70, 7, 9, 2, 2, 70, 120, 3, 2, 2, 2, 71, 72, 7, 27, 2, 2, 72, 73, 11, 2, 2, 2, 73, 120, 7, 54, 2, 2, 74, 75, 7, 27, 2, 2, 75, 76, 7, 7, 2, 2, 76, 77, 5, 4, 3, 2, 77, 78, 7, 9, 2, 2, 78, 120, 3, 2, 2, 2, 79, 120, 7, 54, 2, 2, 80, 81, 7, 21, 2, 2, 81, 82, 5, 4, 3, 2, 82, 83, 7, 29, 2, 2, 83, 86, 5, 4, 3, 2, 84, 85, 7, 16, 2, 2, 85, 87, 5, 4, 3, 2, 86, 84, 3, 2, 2, 2, 86, 87, 3, 2, 2, 2, 87, 120, 3, 2, 2, 2, 88, 89, 9, 3, 2, 2, 89, 120, 5, 4, 3, 21, 90, 91, 7, 20, 2, 2, 91, 93, 7, 3, 2, 2, 92, 94, 5, 28, 15, 2, 93, 92, 3, 2, 2, 2, 93, 94, 3, 2, 2, 2, 94, 95, 3, 2, 2, 2, 95, 96, 7, 4, 2, 2, 96, 120, 5, 4, 3, 9, 97, 98, 5, 22, 12, 2, 98, 99, 7, 12, 2, 2, 99, 100, 5, 4, 3, 8, 100, 120, 3, 2, 2, 2, 101, 102, 7, 22, 2, 2, 102, 120, 7, 52, 2, 2, 103, 104, 7, 23, 2, 2, 104, 120, 7, 52, 2, 2, 105, 106, 7, 17, 2, 2, 106, 120, 5, 4, 3, 5, 107, 108, 7, 24, 2, 2, 108, 113, 5, 24, 13, 2, 109, 110, 7, 8, 2, 2, 110, 112, 5, 24, 13, 2, 111, 109, 3, 2, 2, 2, 112, 115, 3, 2, 2, 2, 113, 111, 3, 2, 2, 2, 113, 114, 3, 2, 2, 2, 114, 116, 3, 2, 2, 2, 115, 113, 3, 2, 2, 2, 116, 117, 7, 12, 2, 2, 117, 118, 5, 4, 3, 3, 118, 120, 3, 2, 2, 2, 119, 33, 3, 2, 2, 2, 119, 35, 3, 2, 2, 2, 119, 39, 3, 2, 2, 2, 119, 44, 3, 2, 2, 2, 119, 59, 3, 2, 2, 2, 119, 71, 3, 2, 2, 2, 119, 74, 3, 2, 2, 2, 119, 79, 3, 2, 2, 2, 119, 80, 3, 2, 2, 2, 119, 88, 3, 2, 2, 2, 119, 90, 3, 2, 2, 2, 119, 97, 3, 2, 2, 2, 119, 101, 3, 2, 2, 2, 119, 103, 3, 2, 2, 2, 119, 105, 3, 2, 2, 2, 119, 107, 3, 2, 2, 2, 120, 195, 3, 2, 2, 2, 121, 122, 12, 20, 2, 2, 122, 123, 9, 4, 2, 2, 123, 194, 5, 4, 3, 21, 124, 125, 12, 19, 2, 2, 125, 126, 9, 5, 2, 2, 126, 194, 5, 4, 3, 20, 127, 128, 12, 18, 2, 2, 128, 129, 9, 6, 2, 2, 129, 194, 5, 4, 3, 19, 130, 131, 12, 17, 2, 2, 131, 132, 9, 7, 2, 2, 132, 194, 5, 4, 3, 18, 133, 134, 12, 16, 2, 2, 134, 135, 9, 8, 2, 2, 135, 194, 5, 4, 3, 17, 136, 137, 12, 15, 2, 2, 137, 138, 7, 49, 2, 2, 138, 194, 5, 4, 3, 16, 139, 140, 12, 14, 2, 2, 140, 141, 7, 50, 2, 2, 141, 194, 5, 4, 3, 15, 142, 143, 12, 13, 2, 2, 143, 144, 7, 51, 2, 2, 144, 194, 5, 4, 3, 14, 145, 146, 12, 12, 2, 2, 146, 147, 7, 38, 2, 2, 147, 194, 5, 4, 3, 13, 148, 149, 12, 11, 2, 2, 149, 150, 7, 39, 2, 2, 150, 194, 5, 4, 3, 12, 151, 152, 12, 29, 2, 2, 152, 153, 7, 10, 2, 2, 153, 194, 7, 54, 2, 2, 154, 155, 12, 28, 2, 2, 155, 156, 7, 7, 2, 2, 156, 157, 5, 4, 3, 2, 157, 158, 7, 9, 2, 2, 158, 194, 3, 2, 2, 2, 159, 160, 12, 27, 2, 2, 160, 162, 7, 7, 2, 2, 161, 163, 5, 4, 3, 2, 162, 161, 3, 2, 2, 2, 162, 163, 3, 2, 2, 2, 163, 164, 3, 2, 2, 2, 164, 166, 7, 11, 2, 2, 165, 167, 5, 4, 3, 2, 166, 165, 3, 2, 2, 2, 166, 167, 3, 2, 2, 2, 167, 172, 3, 2, 2, 2, 168, 170, 7, 11, 2, 2, 169, 171, 5, 4, 3, 2, 170, 169, 3, 2, 2, 2, 170, 171, 3, 2, 2, 2, 171, 173, 3, 2, 2, 2, 172, 168, 3, 2, 2, 2, 172, 173, 3, 2, 2, 2, 173, 174, 3, 2, 2, 2, 174, 194, 7, 9, 2, 2, 175, 176, 12, 24, 2, 2, 176, 178, 7, 3, 2, 2, 177, 179, 5, 26, 14, 2, 178, 177, 3, 2, 2, 2, 178, 179, 3, 2, 2, 2, 179, 180, 3, 2, 2, 2, 180, 182, 7, 4, 2, 2, 181, 183, 7, 28, 2, 2, 182, 181, 3, 2, 2, 2, 182, 183, 3, 2, 2, 2, 183, 194, 3, 2, 2, 2, 184, 185, 12, 10, 2, 2, 185, 187, 7, 5, 2, 2, 186, 188, 5, 6, 4, 2, 187, 186, 3, 2, 2, 2, 187, 188, 3, 2, 2, 2, 188, 189, 3, 2, 2, 2, 189, 194, 7, 6, 2, 2, 190, 191, 12, 4, 2, 2, 191, 192, 7, 45, 2, 2, 192, 194, 7, 27, 2, 2, 193, 121, 3, 2, 2, 2, 193, 124, 3, 2, 2, 2, 193, 127, 3, 2, 2, 2, 193, 130, 3, 2, 2, 2, 193, 133, 3, 2, 2, 2, 193, 136, 3, 2, 2, 2, 193, 139, 3, 2, 2, 2, 193, 142, 3, 2, 2, 2, 193, 145, 3, 2, 2, 2, 193, 148, 3, 2, 2, 2, 193, 151, 3, 2, 2, 2, 193, 154, 3, 2, 2, 2, 193, 159, 3, 2, 2, 2, 193, 175, 3, 2, 2, 2, 193, 184, 3, 2, 2, 2, 193, 190, 3, 2, 2, 2, 194, 197, 3, 2, 2, 2, 195, 193, 3, 2, 2, 2, 195, 196, 3, 2, 2, 2, 196, 5, 3, 2, 2, 2, 197, 195, 3, 2, 2, 2, 198, 203, 5, 8, 5, 2, 199, 200, 7, 8, 2, 2, 200, 202, 5, 8, 5, 2, 201, 199, 3, 2, 2, 2, 202, 205, 3, 2, 2, 2, 203, 201, 3, 2, 2, 2, 203, 204, 3, 2, 2, 2, 204, 207, 3, 2, 2, 2, 205, 203, 3, 2, 2, 2, 206, 208, 7, 8, 2, 2, 207, 206, 3, 2, 2, 2, 207, 208, 3, 2, 2, 2, 208, 238, 3, 2, 2, 2, 209, 210, 5, 14, 8, 2, 210, 211, 7, 8, 2, 2, 211, 213, 3, 2, 2, 2, 212, 209, 3, 2, 2, 2, 213, 216, 3, 2, 2, 2, 214, 212, 3, 2, 2, 2, 214, 215, 3, 2, 2, 2, 215, 217, 3, 2, 2, 2, 216, 214, 3, 2, 2, 2, 217, 218, 7, 7, 2, 2, 218, 219, 5, 4, 3, 2, 219, 220, 7, 9, 2, 2, 220, 221, 7, 11, 2, 2, 221, 226, 5, 4, 3, 2, 222, 223, 7, 8, 2, 2, 223, 225, 5, 14, 8, 2, 224, 222, 3, 2, 2, 2, 225, 228, 3, 2, 2, 2, 226, 224, 3, 2, 2, 2, 226, 227, 3, 2, 2, 2, 227, 230, 3, 2, 2, 2, 228, 226, 3, 2, 2, 2, 229, 231, 7, 8, 2, 2, 230, 229, 3, 2, 2, 2, 230, 231, 3, 2, 2, 2, 231, 233, 3, 2, 2, 2, 232, 234, 5, 16, 9, 2, 233, 232, 3, 2, 2, 2, 234, 235, 3, 2, 2, 2, 235, 233, 3, 2, 2, 2, 235, 236, 3, 2, 2, 2, 236, 238, 3, 2, 2, 2, 237, 198, 3, 2, 2, 2, 237, 214, 3, 2, 2, 2, 238, 7, 3, 2, 2, 2, 239, 243, 5, 14, 8, 2, 240, 243, 5, 22, 12, 2, 241, 243, 5, 10, 6, 2, 242, 239, 3, 2, 2, 2, 242, 240, 3, 2, 2, 2, 242, 241, 3, 2, 2, 2, 243, 9, 3, 2, 2, 2, 244, 246, 5, 20, 11, 2, 245, 247, 7, 33, 2, 2, 246, 245, 3, 2, 2, 2, 246, 247, 3, 2, 2, 2, 247, 248, 3, 2, 2, 2, 248, 249, 5, 12, 7, 2, 249, 250, 5, 4, 3, 2, 250, 261, 3, 2, 2, 2, 251, 252, 5, 20, 11, 2, 252, 254, 7, 3, 2, 2, 253, 255, 5, 28, 15, 2, 254, 253, 3, 2, 2, 2, 254, 255, 3, 2, 2, 2, 255, 256, 3, 2, 2, 2, 256, 257, 7, 4, 2, 2, 257, 258, 5, 12, 7, 2, 258, 259, 5, 4, 3, 2, 259, 261, 3, 2, 2, 2, 260, 244, 3, 2, 2, 2, 260, 251, 3, 2, 2, 2, 261, 11, 3, 2, 2, 2, 262, 269, 7, 11, 2, 2, 263, 264, 7, 11, 2, 2, 264, 269, 7, 11, 2, 2, 265, 266, 7, 11, 2, 2, 266, 267, 7, 11, 2, 2, 267, 269, 7, 11, 2, 2, 268, 262, 3, 2, 2, 2, 268, 263, 3, 2, 2, 2, 268, 265, 3, 2, 2, 2, 269, 13, 3, 2, 2, 2, 270, 271, 7, 24, 2, 2, 271, 272, 5, 24, 13, 2, 272, 15, 3, 2, 2, 2, 273, 274, 7, 19, 2, 2, 274, 275, 7, 54, 2, 2, 275, 276, 7, 45, 2, 2, 276, 280, 5, 4, 3, 2, 277, 279, 5, 18, 10, 2, 278, 277, 3, 2, 2, 2, 279, 282, 3, 2, 2, 2, 280, 278, 3, 2, 2, 2, 280, 281, 3, 2, 2, 2, 281, 17, 3, 2, 2, 2, 282, 280, 3, 2, 2, 2, 283, 284, 7, 21, 2, 2, 284, 285, 5, 4, 3, 2, 285, 19, 3, 2, 2, 2, 286, 293, 7, 54, 2, 2, 287, 293, 7, 52, 2, 2, 288, 289, 7, 7, 2, 2, 289, 290, 5, 4, 3, 2, 290, 291, 7, 9, 2, 2, 291, 293, 3, 2, 2, 2, 292, 286, 3, 2, 2, 2, 292, 287, 3, 2, 2, 2, 292, 288, 3, 2, 2, 2, 293, 21, 3, 2, 2, 2, 294, 295, 7, 15, 2, 2, 295, 298, 5, 4, 3, 2, 296, 297, 7, 11, 2, 2, 297, 299, 5, 4, 3, 2, 298, 296, 3, 2, 2, 2, 298, 299, 3, 2, 2, 2, 299, 23, 3, 2, 2, 2, 300, 301, 7, 54, 2, 2, 301, 302, 7, 13, 2, 2, 302, 312, 5, 4, 3, 2, 303, 304, 7, 54, 2, 2, 304, 306, 7, 3, 2, 2, 305, 307, 5, 28, 15, 2, 306, 305, 3, 2, 2, 2, 306, 307, 3, 2, 2, 2, 307, 308, 3, 2, 2, 2, 308, 309, 7, 4, 2, 2, 309, 310, 7, 13, 2, 2, 310, 312, 5, 4, 3, 2, 311, 300, 3, 2, 2, 2, 311, 303, 3, 2, 2, 2, 312, 25, 3, 2, 2, 2, 313, 318, 5, 4, 3, 2, 314, 315, 7, 8, 2, 2, 315, 317, 5, 4, 3, 2, 316, 314, 3, 2, 2, 2, 317, 320, 3, 2, 2, 2, 318, 316, 3, 2, 2, 2, 318, 319, 3, 2, 2, 2, 319, 327, 3, 2, 2, 2, 320, 318, 3, 2, 2, 2, 321, 322, 7, 8, 2, 2, 322, 323, 7, 54, 2, 2, 323, 324, 7, 13, 2, 2, 324, 326, 5, 4, 3, 2, 325, 321, 3, 2, 2, 2, 326, 329, 3, 2, 2, 2, 327, 325, 3, 2, 2, 2, 327, 328, 3, 2, 2, 2, 328, 331, 3, 2, 2, 2, 329, 327, 3, 2, 2, 2, 330, 332, 7, 8, 2, 2, 331, 330, 3, 2, 2, 2, 331, 332, 3, 2, 2, 2, 332, 349, 3, 2, 2, 2, 333, 334, 7, 54, 2, 2, 334, 335, 7, 13, 2, 2, 335, 342, 5, 4, 3, 2, 336, 337, 7, 8, 2, 2, 337, 338, 7, 54, 2, 2, 338, 339, 7, 13, 2, 2, 339, 341, 5, 4, 3, 2, 340, 336, 3, 2, 2, 2, 341, 344, 3, 2, 2, 2, 342, 340, 3, 2, 2, 2, 342, 343, 3, 2, 2, 2, 343, 346, 3, 2, 2, 2, 344, 342, 3, 2, 2, 2, 345, 347, 7, 8, 2, 2, 346, 345, 3, 2, 2, 2, 346, 347, 3, 2, 2, 2, 347, 349, 3, 2, 2, 2, 348, 313, 3, 2, 2, 2, 348, 333, 3, 2, 2, 2, 349, 27, 3, 2, 2, 2, 350, 355, 7, 54, 2, 2, 351, 352, 7, 8, 2, 2, 352, 354, 7, 54, 2, 2, 353, 351, 3, 2, 2, 2, 354, 357, 3, 2, 2, 2, 355, 353, 3, 2, 2, 2, 355, 356, 3, 2, 2, 2, 356, 364, 3, 2, 2, 2, 357, 355, 3, 2, 2, 2, 358, 359, 7, 8, 2, 2, 359, 360, 7, 54, 2, 2, 360, 361, 7, 13, 2, 2, 361, 363, 5, 4, 3, 2, 362, 358, 3, 2, 2, 2, 363, 366, 3, 2, 2, 2, 364, 362, 3, 2, 2, 2, 364, 365, 3, 2, 2, 2, 365, 368, 3, 2, 2, 2, 366, 364, 3, 2, 2, 2, 367, 369, 7, 8, 2, 2, 368, 367, 3, 2, 2, 2, 368, 369, 3, 2, 2, 2, 369, 386, 3, 2, 2, 2, 370, 371, 7, 54, 2, 2, 371, 372, 7, 13, 2, 2, 372, 379, 5, 4, 3, 2, 373, 374, 7, 8, 2, 2, 374, 375, 7, 54, 2, 2, 375, 376, 7, 13, 2, 2, 376, 378, 5, 4, 3, 2, 377, 373, 3, 2, 2, 2, 378, 381, 3, 2, 2, 2, 379, 377, 3, 2, 2, 2, 379, 380, 3, 2, 2, 2, 380, 383, 3, 2, 2, 2, 381, 379, 3, 2, 2, 2, 382, 384, 7, 8, 2, 2, 383, 382, 3, 2, 2, 2, 383, 384, 3, 2, 2, 2, 384, 386, 3, 2, 2, 2, 385, 350, 3, 2, 2, 2, 385, 370, 3, 2, 2, 2, 386, 29, 3, 2, 2, 2, 50, 41, 50, 53, 56, 62, 67, 86, 93, 113, 119, 162, 166, 170, 172, 178, 182, 187, 193, 195, 203, 207, 214, 226, 230, 235, 237, 242, 246, 254, 260, 268, 280, 292, 298, 306, 311, 318, 327, 331, 342, 346, 348, 355, 364, 368, 379, 383, 385] -------------------------------------------------------------------------------- /parser/JsonnetLexer.interp: -------------------------------------------------------------------------------- 1 | token literal names: 2 | null 3 | '(' 4 | ')' 5 | '{' 6 | '}' 7 | '[' 8 | ',' 9 | ']' 10 | '.' 11 | ':' 12 | ';' 13 | '=' 14 | '$' 15 | 'assert' 16 | 'else' 17 | 'error' 18 | 'false' 19 | 'for' 20 | 'function' 21 | 'if' 22 | 'import' 23 | 'importstr' 24 | 'local' 25 | 'null' 26 | 'self' 27 | 'super' 28 | 'tailstrict' 29 | 'then' 30 | 'true' 31 | '==' 32 | '!=' 33 | '+' 34 | '-' 35 | '*' 36 | '/' 37 | '%' 38 | '&&' 39 | '||' 40 | '!' 41 | '>' 42 | '>=' 43 | '<' 44 | '<=' 45 | 'in' 46 | '<<' 47 | '>>' 48 | '~' 49 | '&' 50 | '^' 51 | '|' 52 | null 53 | null 54 | null 55 | null 56 | null 57 | null 58 | null 59 | 60 | token symbolic names: 61 | null 62 | null 63 | null 64 | null 65 | null 66 | null 67 | null 68 | null 69 | null 70 | null 71 | null 72 | null 73 | DOLLAR 74 | ASSERT 75 | ELSE 76 | ERROR 77 | FALSE 78 | FOR 79 | FUNCTION 80 | IF 81 | IMPORT 82 | IMPORTSTR 83 | LOCAL 84 | NULL 85 | SELF 86 | SUPER 87 | TAILSTRICT 88 | THEN 89 | TRUE 90 | EQUALS 91 | NOTEQUALS 92 | PLUS 93 | MINUS 94 | MULTIPLY 95 | DIVIDE 96 | MODULUS 97 | AND 98 | OR 99 | NOT 100 | GT 101 | GE 102 | LT 103 | LE 104 | IN 105 | SHIFTLEFT 106 | SHIFTRIGHT 107 | BITNOT 108 | BITAND 109 | BITXOR 110 | BITOR 111 | STRING 112 | NUMBER 113 | ID 114 | Whitespace 115 | Newline 116 | BlockComment 117 | LineComment 118 | 119 | rule names: 120 | T__0 121 | T__1 122 | T__2 123 | T__3 124 | T__4 125 | T__5 126 | T__6 127 | T__7 128 | T__8 129 | T__9 130 | T__10 131 | DOLLAR 132 | ASSERT 133 | ELSE 134 | ERROR 135 | FALSE 136 | FOR 137 | FUNCTION 138 | IF 139 | IMPORT 140 | IMPORTSTR 141 | LOCAL 142 | NULL 143 | SELF 144 | SUPER 145 | TAILSTRICT 146 | THEN 147 | TRUE 148 | EQUALS 149 | NOTEQUALS 150 | PLUS 151 | MINUS 152 | MULTIPLY 153 | DIVIDE 154 | MODULUS 155 | AND 156 | OR 157 | NOT 158 | GT 159 | GE 160 | LT 161 | LE 162 | IN 163 | SHIFTLEFT 164 | SHIFTRIGHT 165 | BITNOT 166 | BITAND 167 | BITXOR 168 | BITOR 169 | STRING 170 | NUMBER 171 | ID 172 | ESCAPES 173 | DIGIT 174 | ALPHA 175 | UNICODE 176 | HEX 177 | INT 178 | EXP 179 | Whitespace 180 | Newline 181 | BlockComment 182 | LineComment 183 | 184 | channel names: 185 | DEFAULT_TOKEN_CHANNEL 186 | HIDDEN 187 | 188 | mode names: 189 | DEFAULT_MODE 190 | 191 | atn: 192 | [3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 58, 475, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 4, 47, 9, 47, 4, 48, 9, 48, 4, 49, 9, 49, 4, 50, 9, 50, 4, 51, 9, 51, 4, 52, 9, 52, 4, 53, 9, 53, 4, 54, 9, 54, 4, 55, 9, 55, 4, 56, 9, 56, 4, 57, 9, 57, 4, 58, 9, 58, 4, 59, 9, 59, 4, 60, 9, 60, 4, 61, 9, 61, 4, 62, 9, 62, 4, 63, 9, 63, 4, 64, 9, 64, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 33, 3, 33, 3, 34, 3, 34, 3, 35, 3, 35, 3, 36, 3, 36, 3, 37, 3, 37, 3, 37, 3, 38, 3, 38, 3, 38, 3, 39, 3, 39, 3, 40, 3, 40, 3, 41, 3, 41, 3, 41, 3, 42, 3, 42, 3, 43, 3, 43, 3, 43, 3, 44, 3, 44, 3, 44, 3, 45, 3, 45, 3, 45, 3, 46, 3, 46, 3, 46, 3, 47, 3, 47, 3, 48, 3, 48, 3, 49, 3, 49, 3, 50, 3, 50, 3, 51, 3, 51, 3, 51, 3, 51, 7, 51, 309, 10, 51, 12, 51, 14, 51, 312, 11, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 7, 51, 319, 10, 51, 12, 51, 14, 51, 322, 11, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 7, 51, 330, 10, 51, 12, 51, 14, 51, 333, 11, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 7, 51, 341, 10, 51, 12, 51, 14, 51, 344, 11, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 7, 51, 352, 10, 51, 12, 51, 14, 51, 355, 11, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 7, 51, 369, 10, 51, 12, 51, 14, 51, 372, 11, 51, 3, 51, 3, 51, 3, 51, 5, 51, 377, 10, 51, 3, 52, 3, 52, 3, 52, 6, 52, 382, 10, 52, 13, 52, 14, 52, 383, 5, 52, 386, 10, 52, 3, 52, 5, 52, 389, 10, 52, 3, 53, 3, 53, 3, 53, 7, 53, 394, 10, 53, 12, 53, 14, 53, 397, 11, 53, 3, 54, 3, 54, 3, 54, 3, 55, 3, 55, 3, 56, 3, 56, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 58, 3, 58, 3, 59, 3, 59, 3, 59, 7, 59, 417, 10, 59, 12, 59, 14, 59, 420, 11, 59, 5, 59, 422, 10, 59, 3, 60, 3, 60, 5, 60, 426, 10, 60, 3, 60, 6, 60, 429, 10, 60, 13, 60, 14, 60, 430, 3, 61, 6, 61, 434, 10, 61, 13, 61, 14, 61, 435, 3, 61, 3, 61, 3, 62, 3, 62, 5, 62, 442, 10, 62, 3, 62, 5, 62, 445, 10, 62, 3, 62, 3, 62, 3, 63, 3, 63, 3, 63, 3, 63, 7, 63, 453, 10, 63, 12, 63, 14, 63, 456, 11, 63, 3, 63, 3, 63, 3, 63, 3, 63, 3, 63, 3, 64, 3, 64, 3, 64, 5, 64, 466, 10, 64, 3, 64, 7, 64, 469, 10, 64, 12, 64, 14, 64, 472, 11, 64, 3, 64, 3, 64, 3, 454, 2, 65, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 57, 30, 59, 31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 37, 73, 38, 75, 39, 77, 40, 79, 41, 81, 42, 83, 43, 85, 44, 87, 45, 89, 46, 91, 47, 93, 48, 95, 49, 97, 50, 99, 51, 101, 52, 103, 53, 105, 54, 107, 2, 109, 2, 111, 2, 113, 2, 115, 2, 117, 2, 119, 2, 121, 55, 123, 56, 125, 57, 127, 58, 3, 2, 16, 5, 2, 2, 33, 36, 36, 94, 94, 5, 2, 2, 33, 41, 41, 94, 94, 3, 2, 36, 36, 3, 2, 41, 41, 3, 2, 126, 126, 11, 2, 36, 36, 41, 41, 49, 49, 94, 94, 100, 100, 104, 104, 112, 112, 116, 116, 118, 118, 3, 2, 50, 59, 5, 2, 67, 92, 97, 97, 99, 124, 5, 2, 50, 59, 67, 72, 99, 104, 3, 2, 51, 59, 4, 2, 71, 71, 103, 103, 4, 2, 45, 45, 47, 47, 4, 2, 11, 11, 34, 34, 4, 2, 12, 12, 15, 15, 2, 502, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 2, 77, 3, 2, 2, 2, 2, 79, 3, 2, 2, 2, 2, 81, 3, 2, 2, 2, 2, 83, 3, 2, 2, 2, 2, 85, 3, 2, 2, 2, 2, 87, 3, 2, 2, 2, 2, 89, 3, 2, 2, 2, 2, 91, 3, 2, 2, 2, 2, 93, 3, 2, 2, 2, 2, 95, 3, 2, 2, 2, 2, 97, 3, 2, 2, 2, 2, 99, 3, 2, 2, 2, 2, 101, 3, 2, 2, 2, 2, 103, 3, 2, 2, 2, 2, 105, 3, 2, 2, 2, 2, 121, 3, 2, 2, 2, 2, 123, 3, 2, 2, 2, 2, 125, 3, 2, 2, 2, 2, 127, 3, 2, 2, 2, 3, 129, 3, 2, 2, 2, 5, 131, 3, 2, 2, 2, 7, 133, 3, 2, 2, 2, 9, 135, 3, 2, 2, 2, 11, 137, 3, 2, 2, 2, 13, 139, 3, 2, 2, 2, 15, 141, 3, 2, 2, 2, 17, 143, 3, 2, 2, 2, 19, 145, 3, 2, 2, 2, 21, 147, 3, 2, 2, 2, 23, 149, 3, 2, 2, 2, 25, 151, 3, 2, 2, 2, 27, 153, 3, 2, 2, 2, 29, 160, 3, 2, 2, 2, 31, 165, 3, 2, 2, 2, 33, 171, 3, 2, 2, 2, 35, 177, 3, 2, 2, 2, 37, 181, 3, 2, 2, 2, 39, 190, 3, 2, 2, 2, 41, 193, 3, 2, 2, 2, 43, 200, 3, 2, 2, 2, 45, 210, 3, 2, 2, 2, 47, 216, 3, 2, 2, 2, 49, 221, 3, 2, 2, 2, 51, 226, 3, 2, 2, 2, 53, 232, 3, 2, 2, 2, 55, 243, 3, 2, 2, 2, 57, 248, 3, 2, 2, 2, 59, 253, 3, 2, 2, 2, 61, 256, 3, 2, 2, 2, 63, 259, 3, 2, 2, 2, 65, 261, 3, 2, 2, 2, 67, 263, 3, 2, 2, 2, 69, 265, 3, 2, 2, 2, 71, 267, 3, 2, 2, 2, 73, 269, 3, 2, 2, 2, 75, 272, 3, 2, 2, 2, 77, 275, 3, 2, 2, 2, 79, 277, 3, 2, 2, 2, 81, 279, 3, 2, 2, 2, 83, 282, 3, 2, 2, 2, 85, 284, 3, 2, 2, 2, 87, 287, 3, 2, 2, 2, 89, 290, 3, 2, 2, 2, 91, 293, 3, 2, 2, 2, 93, 296, 3, 2, 2, 2, 95, 298, 3, 2, 2, 2, 97, 300, 3, 2, 2, 2, 99, 302, 3, 2, 2, 2, 101, 376, 3, 2, 2, 2, 103, 378, 3, 2, 2, 2, 105, 390, 3, 2, 2, 2, 107, 398, 3, 2, 2, 2, 109, 401, 3, 2, 2, 2, 111, 403, 3, 2, 2, 2, 113, 405, 3, 2, 2, 2, 115, 411, 3, 2, 2, 2, 117, 421, 3, 2, 2, 2, 119, 423, 3, 2, 2, 2, 121, 433, 3, 2, 2, 2, 123, 444, 3, 2, 2, 2, 125, 448, 3, 2, 2, 2, 127, 465, 3, 2, 2, 2, 129, 130, 7, 42, 2, 2, 130, 4, 3, 2, 2, 2, 131, 132, 7, 43, 2, 2, 132, 6, 3, 2, 2, 2, 133, 134, 7, 125, 2, 2, 134, 8, 3, 2, 2, 2, 135, 136, 7, 127, 2, 2, 136, 10, 3, 2, 2, 2, 137, 138, 7, 93, 2, 2, 138, 12, 3, 2, 2, 2, 139, 140, 7, 46, 2, 2, 140, 14, 3, 2, 2, 2, 141, 142, 7, 95, 2, 2, 142, 16, 3, 2, 2, 2, 143, 144, 7, 48, 2, 2, 144, 18, 3, 2, 2, 2, 145, 146, 7, 60, 2, 2, 146, 20, 3, 2, 2, 2, 147, 148, 7, 61, 2, 2, 148, 22, 3, 2, 2, 2, 149, 150, 7, 63, 2, 2, 150, 24, 3, 2, 2, 2, 151, 152, 7, 38, 2, 2, 152, 26, 3, 2, 2, 2, 153, 154, 7, 99, 2, 2, 154, 155, 7, 117, 2, 2, 155, 156, 7, 117, 2, 2, 156, 157, 7, 103, 2, 2, 157, 158, 7, 116, 2, 2, 158, 159, 7, 118, 2, 2, 159, 28, 3, 2, 2, 2, 160, 161, 7, 103, 2, 2, 161, 162, 7, 110, 2, 2, 162, 163, 7, 117, 2, 2, 163, 164, 7, 103, 2, 2, 164, 30, 3, 2, 2, 2, 165, 166, 7, 103, 2, 2, 166, 167, 7, 116, 2, 2, 167, 168, 7, 116, 2, 2, 168, 169, 7, 113, 2, 2, 169, 170, 7, 116, 2, 2, 170, 32, 3, 2, 2, 2, 171, 172, 7, 104, 2, 2, 172, 173, 7, 99, 2, 2, 173, 174, 7, 110, 2, 2, 174, 175, 7, 117, 2, 2, 175, 176, 7, 103, 2, 2, 176, 34, 3, 2, 2, 2, 177, 178, 7, 104, 2, 2, 178, 179, 7, 113, 2, 2, 179, 180, 7, 116, 2, 2, 180, 36, 3, 2, 2, 2, 181, 182, 7, 104, 2, 2, 182, 183, 7, 119, 2, 2, 183, 184, 7, 112, 2, 2, 184, 185, 7, 101, 2, 2, 185, 186, 7, 118, 2, 2, 186, 187, 7, 107, 2, 2, 187, 188, 7, 113, 2, 2, 188, 189, 7, 112, 2, 2, 189, 38, 3, 2, 2, 2, 190, 191, 7, 107, 2, 2, 191, 192, 7, 104, 2, 2, 192, 40, 3, 2, 2, 2, 193, 194, 7, 107, 2, 2, 194, 195, 7, 111, 2, 2, 195, 196, 7, 114, 2, 2, 196, 197, 7, 113, 2, 2, 197, 198, 7, 116, 2, 2, 198, 199, 7, 118, 2, 2, 199, 42, 3, 2, 2, 2, 200, 201, 7, 107, 2, 2, 201, 202, 7, 111, 2, 2, 202, 203, 7, 114, 2, 2, 203, 204, 7, 113, 2, 2, 204, 205, 7, 116, 2, 2, 205, 206, 7, 118, 2, 2, 206, 207, 7, 117, 2, 2, 207, 208, 7, 118, 2, 2, 208, 209, 7, 116, 2, 2, 209, 44, 3, 2, 2, 2, 210, 211, 7, 110, 2, 2, 211, 212, 7, 113, 2, 2, 212, 213, 7, 101, 2, 2, 213, 214, 7, 99, 2, 2, 214, 215, 7, 110, 2, 2, 215, 46, 3, 2, 2, 2, 216, 217, 7, 112, 2, 2, 217, 218, 7, 119, 2, 2, 218, 219, 7, 110, 2, 2, 219, 220, 7, 110, 2, 2, 220, 48, 3, 2, 2, 2, 221, 222, 7, 117, 2, 2, 222, 223, 7, 103, 2, 2, 223, 224, 7, 110, 2, 2, 224, 225, 7, 104, 2, 2, 225, 50, 3, 2, 2, 2, 226, 227, 7, 117, 2, 2, 227, 228, 7, 119, 2, 2, 228, 229, 7, 114, 2, 2, 229, 230, 7, 103, 2, 2, 230, 231, 7, 116, 2, 2, 231, 52, 3, 2, 2, 2, 232, 233, 7, 118, 2, 2, 233, 234, 7, 99, 2, 2, 234, 235, 7, 107, 2, 2, 235, 236, 7, 110, 2, 2, 236, 237, 7, 117, 2, 2, 237, 238, 7, 118, 2, 2, 238, 239, 7, 116, 2, 2, 239, 240, 7, 107, 2, 2, 240, 241, 7, 101, 2, 2, 241, 242, 7, 118, 2, 2, 242, 54, 3, 2, 2, 2, 243, 244, 7, 118, 2, 2, 244, 245, 7, 106, 2, 2, 245, 246, 7, 103, 2, 2, 246, 247, 7, 112, 2, 2, 247, 56, 3, 2, 2, 2, 248, 249, 7, 118, 2, 2, 249, 250, 7, 116, 2, 2, 250, 251, 7, 119, 2, 2, 251, 252, 7, 103, 2, 2, 252, 58, 3, 2, 2, 2, 253, 254, 7, 63, 2, 2, 254, 255, 7, 63, 2, 2, 255, 60, 3, 2, 2, 2, 256, 257, 7, 35, 2, 2, 257, 258, 7, 63, 2, 2, 258, 62, 3, 2, 2, 2, 259, 260, 7, 45, 2, 2, 260, 64, 3, 2, 2, 2, 261, 262, 7, 47, 2, 2, 262, 66, 3, 2, 2, 2, 263, 264, 7, 44, 2, 2, 264, 68, 3, 2, 2, 2, 265, 266, 7, 49, 2, 2, 266, 70, 3, 2, 2, 2, 267, 268, 7, 39, 2, 2, 268, 72, 3, 2, 2, 2, 269, 270, 7, 40, 2, 2, 270, 271, 7, 40, 2, 2, 271, 74, 3, 2, 2, 2, 272, 273, 7, 126, 2, 2, 273, 274, 7, 126, 2, 2, 274, 76, 3, 2, 2, 2, 275, 276, 7, 35, 2, 2, 276, 78, 3, 2, 2, 2, 277, 278, 7, 64, 2, 2, 278, 80, 3, 2, 2, 2, 279, 280, 7, 64, 2, 2, 280, 281, 7, 63, 2, 2, 281, 82, 3, 2, 2, 2, 282, 283, 7, 62, 2, 2, 283, 84, 3, 2, 2, 2, 284, 285, 7, 62, 2, 2, 285, 286, 7, 63, 2, 2, 286, 86, 3, 2, 2, 2, 287, 288, 7, 107, 2, 2, 288, 289, 7, 112, 2, 2, 289, 88, 3, 2, 2, 2, 290, 291, 7, 62, 2, 2, 291, 292, 7, 62, 2, 2, 292, 90, 3, 2, 2, 2, 293, 294, 7, 64, 2, 2, 294, 295, 7, 64, 2, 2, 295, 92, 3, 2, 2, 2, 296, 297, 7, 128, 2, 2, 297, 94, 3, 2, 2, 2, 298, 299, 7, 40, 2, 2, 299, 96, 3, 2, 2, 2, 300, 301, 7, 96, 2, 2, 301, 98, 3, 2, 2, 2, 302, 303, 7, 126, 2, 2, 303, 100, 3, 2, 2, 2, 304, 310, 7, 36, 2, 2, 305, 309, 5, 107, 54, 2, 306, 309, 5, 113, 57, 2, 307, 309, 10, 2, 2, 2, 308, 305, 3, 2, 2, 2, 308, 306, 3, 2, 2, 2, 308, 307, 3, 2, 2, 2, 309, 312, 3, 2, 2, 2, 310, 308, 3, 2, 2, 2, 310, 311, 3, 2, 2, 2, 311, 313, 3, 2, 2, 2, 312, 310, 3, 2, 2, 2, 313, 377, 7, 36, 2, 2, 314, 320, 7, 41, 2, 2, 315, 319, 5, 107, 54, 2, 316, 319, 5, 113, 57, 2, 317, 319, 10, 3, 2, 2, 318, 315, 3, 2, 2, 2, 318, 316, 3, 2, 2, 2, 318, 317, 3, 2, 2, 2, 319, 322, 3, 2, 2, 2, 320, 318, 3, 2, 2, 2, 320, 321, 3, 2, 2, 2, 321, 323, 3, 2, 2, 2, 322, 320, 3, 2, 2, 2, 323, 377, 7, 41, 2, 2, 324, 325, 7, 66, 2, 2, 325, 331, 7, 36, 2, 2, 326, 327, 7, 36, 2, 2, 327, 330, 7, 36, 2, 2, 328, 330, 10, 4, 2, 2, 329, 326, 3, 2, 2, 2, 329, 328, 3, 2, 2, 2, 330, 333, 3, 2, 2, 2, 331, 329, 3, 2, 2, 2, 331, 332, 3, 2, 2, 2, 332, 334, 3, 2, 2, 2, 333, 331, 3, 2, 2, 2, 334, 377, 7, 36, 2, 2, 335, 336, 7, 66, 2, 2, 336, 342, 7, 41, 2, 2, 337, 338, 7, 41, 2, 2, 338, 341, 7, 41, 2, 2, 339, 341, 10, 5, 2, 2, 340, 337, 3, 2, 2, 2, 340, 339, 3, 2, 2, 2, 341, 344, 3, 2, 2, 2, 342, 340, 3, 2, 2, 2, 342, 343, 3, 2, 2, 2, 343, 345, 3, 2, 2, 2, 344, 342, 3, 2, 2, 2, 345, 377, 7, 41, 2, 2, 346, 347, 7, 66, 2, 2, 347, 353, 7, 41, 2, 2, 348, 349, 7, 41, 2, 2, 349, 352, 7, 41, 2, 2, 350, 352, 10, 5, 2, 2, 351, 348, 3, 2, 2, 2, 351, 350, 3, 2, 2, 2, 352, 355, 3, 2, 2, 2, 353, 351, 3, 2, 2, 2, 353, 354, 3, 2, 2, 2, 354, 356, 3, 2, 2, 2, 355, 353, 3, 2, 2, 2, 356, 377, 7, 41, 2, 2, 357, 358, 7, 126, 2, 2, 358, 359, 7, 126, 2, 2, 359, 360, 7, 126, 2, 2, 360, 370, 3, 2, 2, 2, 361, 369, 10, 6, 2, 2, 362, 363, 7, 126, 2, 2, 363, 369, 10, 6, 2, 2, 364, 365, 7, 126, 2, 2, 365, 366, 7, 126, 2, 2, 366, 367, 3, 2, 2, 2, 367, 369, 10, 6, 2, 2, 368, 361, 3, 2, 2, 2, 368, 362, 3, 2, 2, 2, 368, 364, 3, 2, 2, 2, 369, 372, 3, 2, 2, 2, 370, 368, 3, 2, 2, 2, 370, 371, 3, 2, 2, 2, 371, 373, 3, 2, 2, 2, 372, 370, 3, 2, 2, 2, 373, 374, 7, 126, 2, 2, 374, 375, 7, 126, 2, 2, 375, 377, 7, 126, 2, 2, 376, 304, 3, 2, 2, 2, 376, 314, 3, 2, 2, 2, 376, 324, 3, 2, 2, 2, 376, 335, 3, 2, 2, 2, 376, 346, 3, 2, 2, 2, 376, 357, 3, 2, 2, 2, 377, 102, 3, 2, 2, 2, 378, 385, 5, 117, 59, 2, 379, 381, 7, 48, 2, 2, 380, 382, 5, 109, 55, 2, 381, 380, 3, 2, 2, 2, 382, 383, 3, 2, 2, 2, 383, 381, 3, 2, 2, 2, 383, 384, 3, 2, 2, 2, 384, 386, 3, 2, 2, 2, 385, 379, 3, 2, 2, 2, 385, 386, 3, 2, 2, 2, 386, 388, 3, 2, 2, 2, 387, 389, 5, 119, 60, 2, 388, 387, 3, 2, 2, 2, 388, 389, 3, 2, 2, 2, 389, 104, 3, 2, 2, 2, 390, 395, 5, 111, 56, 2, 391, 394, 5, 111, 56, 2, 392, 394, 5, 109, 55, 2, 393, 391, 3, 2, 2, 2, 393, 392, 3, 2, 2, 2, 394, 397, 3, 2, 2, 2, 395, 393, 3, 2, 2, 2, 395, 396, 3, 2, 2, 2, 396, 106, 3, 2, 2, 2, 397, 395, 3, 2, 2, 2, 398, 399, 7, 94, 2, 2, 399, 400, 9, 7, 2, 2, 400, 108, 3, 2, 2, 2, 401, 402, 9, 8, 2, 2, 402, 110, 3, 2, 2, 2, 403, 404, 9, 9, 2, 2, 404, 112, 3, 2, 2, 2, 405, 406, 7, 119, 2, 2, 406, 407, 5, 115, 58, 2, 407, 408, 5, 115, 58, 2, 408, 409, 5, 115, 58, 2, 409, 410, 5, 115, 58, 2, 410, 114, 3, 2, 2, 2, 411, 412, 9, 10, 2, 2, 412, 116, 3, 2, 2, 2, 413, 422, 7, 50, 2, 2, 414, 418, 9, 11, 2, 2, 415, 417, 5, 109, 55, 2, 416, 415, 3, 2, 2, 2, 417, 420, 3, 2, 2, 2, 418, 416, 3, 2, 2, 2, 418, 419, 3, 2, 2, 2, 419, 422, 3, 2, 2, 2, 420, 418, 3, 2, 2, 2, 421, 413, 3, 2, 2, 2, 421, 414, 3, 2, 2, 2, 422, 118, 3, 2, 2, 2, 423, 425, 9, 12, 2, 2, 424, 426, 9, 13, 2, 2, 425, 424, 3, 2, 2, 2, 425, 426, 3, 2, 2, 2, 426, 428, 3, 2, 2, 2, 427, 429, 5, 109, 55, 2, 428, 427, 3, 2, 2, 2, 429, 430, 3, 2, 2, 2, 430, 428, 3, 2, 2, 2, 430, 431, 3, 2, 2, 2, 431, 120, 3, 2, 2, 2, 432, 434, 9, 14, 2, 2, 433, 432, 3, 2, 2, 2, 434, 435, 3, 2, 2, 2, 435, 433, 3, 2, 2, 2, 435, 436, 3, 2, 2, 2, 436, 437, 3, 2, 2, 2, 437, 438, 8, 61, 2, 2, 438, 122, 3, 2, 2, 2, 439, 441, 7, 15, 2, 2, 440, 442, 7, 12, 2, 2, 441, 440, 3, 2, 2, 2, 441, 442, 3, 2, 2, 2, 442, 445, 3, 2, 2, 2, 443, 445, 7, 12, 2, 2, 444, 439, 3, 2, 2, 2, 444, 443, 3, 2, 2, 2, 445, 446, 3, 2, 2, 2, 446, 447, 8, 62, 2, 2, 447, 124, 3, 2, 2, 2, 448, 449, 7, 49, 2, 2, 449, 450, 7, 44, 2, 2, 450, 454, 3, 2, 2, 2, 451, 453, 11, 2, 2, 2, 452, 451, 3, 2, 2, 2, 453, 456, 3, 2, 2, 2, 454, 455, 3, 2, 2, 2, 454, 452, 3, 2, 2, 2, 455, 457, 3, 2, 2, 2, 456, 454, 3, 2, 2, 2, 457, 458, 7, 44, 2, 2, 458, 459, 7, 49, 2, 2, 459, 460, 3, 2, 2, 2, 460, 461, 8, 63, 2, 2, 461, 126, 3, 2, 2, 2, 462, 463, 7, 49, 2, 2, 463, 466, 7, 49, 2, 2, 464, 466, 7, 37, 2, 2, 465, 462, 3, 2, 2, 2, 465, 464, 3, 2, 2, 2, 466, 470, 3, 2, 2, 2, 467, 469, 10, 15, 2, 2, 468, 467, 3, 2, 2, 2, 469, 472, 3, 2, 2, 2, 470, 468, 3, 2, 2, 2, 470, 471, 3, 2, 2, 2, 471, 473, 3, 2, 2, 2, 472, 470, 3, 2, 2, 2, 473, 474, 8, 64, 2, 2, 474, 128, 3, 2, 2, 2, 31, 2, 308, 310, 318, 320, 329, 331, 340, 342, 351, 353, 368, 370, 376, 383, 385, 388, 393, 395, 418, 421, 425, 430, 435, 441, 444, 454, 465, 470, 3, 8, 2, 2] -------------------------------------------------------------------------------- /protocol/protocol.go: -------------------------------------------------------------------------------- 1 | package protocol 2 | 3 | import ( 4 | "encoding/base64" 5 | "encoding/json" 6 | "strings" 7 | ) 8 | 9 | /* 10 | Reference: https://github.com/microsoft/lsif-node/blob/master/protocol/src/protocol.ts 11 | */ 12 | 13 | const ( 14 | // Version represents the current LSIF version of implementation. 15 | Version = "0.4.0" 16 | // LanguageID is the language ID in LSP, For Go it's "go". 17 | LanguageID = "jsonnet" 18 | // PositionEncoding is the encoding used to compute line and character values in positions and ranges. 19 | PositionEncoding = "utf-16" 20 | ) 21 | 22 | // Element contains basic information of an element in the graph. 23 | type Element struct { 24 | // The unique identifier of this element within the scope of project. 25 | ID int `json:"id"` 26 | // The kind of element in the graph. 27 | Type ElementType `json:"type"` 28 | } 29 | 30 | // ElementType represents the kind of element. 31 | type ElementType string 32 | 33 | const ( 34 | ElementVertex ElementType = "vertex" 35 | ElementEdge ElementType = "edge" 36 | ) 37 | 38 | // Vertex contains information of a vertex in the graph. 39 | type Vertex struct { 40 | Element 41 | // The kind of vertex in the graph. 42 | Label VertexLabel `json:"label"` 43 | } 44 | 45 | // VertexLabel represents the purpose of vertex. 46 | type VertexLabel string 47 | 48 | const ( 49 | VertexMetaData VertexLabel = "metaData" 50 | VertexEvent VertexLabel = "$event" 51 | VertexProject VertexLabel = "project" 52 | VertexRange VertexLabel = "range" 53 | VertexLocation VertexLabel = "location" 54 | VertexDocument VertexLabel = "document" 55 | VertexMoniker VertexLabel = "moniker" 56 | VertexPackageInformation VertexLabel = "packageInformation" 57 | VertexResultSet VertexLabel = "resultSet" 58 | VertexDocumentSymbolResult VertexLabel = "documentSymbolResult" 59 | VertexFoldingRangeResult VertexLabel = "foldingRangeResult" 60 | VertexDocumentLinkResult VertexLabel = "documentLinkResult" 61 | VertexDianosticResult VertexLabel = "diagnosticResult" 62 | VertexDeclarationResult VertexLabel = "declarationResult" 63 | VertexDefinitionResult VertexLabel = "definitionResult" 64 | VertexTypeDefinitionResult VertexLabel = "typeDefinitionResult" 65 | VertexHoverResult VertexLabel = "hoverResult" 66 | VertexReferenceResult VertexLabel = "referenceResult" 67 | VertexImplementationResult VertexLabel = "implementationResult" 68 | ) 69 | 70 | // ToolInfo contains information about the tool that created the dump. 71 | type ToolInfo struct { 72 | // The name of the tool. 73 | Name string `json:"name"` 74 | // The version of the tool. 75 | Version string `json:"version,omitempty"` 76 | // The arguments passed to the tool. 77 | Args []string `json:"args,omitempty"` 78 | } 79 | 80 | // MetaData contains basic information about the dump. 81 | type MetaData struct { 82 | Vertex 83 | // The version of the LSIF format using semver notation. 84 | Version string `json:"version"` 85 | // The project root (in form of an URI) used to compute this dump. 86 | ProjectRoot string `json:"projectRoot"` 87 | // The string encoding used to compute line and character values in 88 | // positions and ranges. Currently only 'utf-16' is support due to the 89 | // limitations in LSP. 90 | PositionEncoding string `json:"positionEncoding"` 91 | // The information about the tool that created the dump. 92 | ToolInfo *ToolInfo `json:"toolInfo"` 93 | } 94 | 95 | // NewMetaData returns a new MetaData object with given ID, project root 96 | // and tool information. 97 | func NewMetaData(id int, root string, info *ToolInfo) *MetaData { 98 | return &MetaData{ 99 | Vertex: Vertex{ 100 | Element: Element{ 101 | ID: id, 102 | Type: ElementVertex, 103 | }, 104 | Label: VertexMetaData, 105 | }, 106 | Version: Version, 107 | ProjectRoot: root, 108 | PositionEncoding: PositionEncoding, 109 | ToolInfo: info, 110 | } 111 | } 112 | 113 | // Event is optional metadata emitted to give hints to consumers about 114 | // the beginning and ending of new "socpes" (e.g. a project or document). 115 | type Event struct { 116 | Vertex 117 | // The kind of event (begin or end). 118 | Kind string `json:"kind"` 119 | // The type of element this event describes (project or document). 120 | Scope string `json:"scope"` 121 | // The identifier of the data beginning or ending. 122 | Data int `json:"data"` 123 | } 124 | 125 | // NewEvent returns a new Event object with the given ID, kind, scope, 126 | // and data information. 127 | func NewEvent(id int, kind, scope string, data int) *Event { 128 | return &Event{ 129 | Vertex: Vertex{ 130 | Element: Element{ 131 | ID: id, 132 | Type: ElementVertex, 133 | }, 134 | Label: VertexEvent, 135 | }, 136 | Kind: kind, 137 | Scope: scope, 138 | Data: data, 139 | } 140 | } 141 | 142 | // Project declares the language of the dump. 143 | type Project struct { 144 | Vertex 145 | // The kind of language of the dump. 146 | Kind string `json:"kind"` 147 | } 148 | 149 | // NewProject returns a new Project object with given ID. 150 | func NewProject(id int) *Project { 151 | return &Project{ 152 | Vertex: Vertex{ 153 | Element: Element{ 154 | ID: id, 155 | Type: ElementVertex, 156 | }, 157 | Label: VertexProject, 158 | }, 159 | Kind: LanguageID, 160 | } 161 | } 162 | 163 | // Document is a vertex of document in the project. 164 | type Document struct { 165 | Vertex 166 | // The URI indicates the location of the document. 167 | URI string `json:"uri"` 168 | // The language identifier of the document. 169 | LanguageID string `json:"languageId"` 170 | // The contents of the the document. 171 | Contents string `json:"contents,omitempty"` 172 | } 173 | 174 | // NewDocument returns a new Document object with given ID, URI and contents. 175 | func NewDocument(id int, uri string, contents []byte) *Document { 176 | d := &Document{ 177 | Vertex: Vertex{ 178 | Element: Element{ 179 | ID: id, 180 | Type: ElementVertex, 181 | }, 182 | Label: VertexDocument, 183 | }, 184 | URI: uri, 185 | LanguageID: LanguageID, 186 | } 187 | 188 | if len(contents) > 0 { 189 | d.Contents = base64.StdEncoding.EncodeToString(contents) 190 | } 191 | 192 | return d 193 | } 194 | 195 | // ResultSet acts as a hub to be able to store information common to a set of ranges. 196 | type ResultSet struct { 197 | Vertex 198 | } 199 | 200 | // NewResultSet returns a new ResultSet object with given ID. 201 | func NewResultSet(id int) *ResultSet { 202 | return &ResultSet{ 203 | Vertex: Vertex{ 204 | Element: Element{ 205 | ID: id, 206 | Type: ElementVertex, 207 | }, 208 | Label: VertexResultSet, 209 | }, 210 | } 211 | } 212 | 213 | // ReferenceResult acts as a hub to be able to store reference information common to a set of ranges. 214 | type ReferenceResult struct { 215 | Vertex 216 | } 217 | 218 | // NewReferenceResult returns a new ReferenceResult object with given ID. 219 | func NewReferenceResult(id int) *ResultSet { 220 | return &ResultSet{ 221 | Vertex: Vertex{ 222 | Element: Element{ 223 | ID: id, 224 | Type: ElementVertex, 225 | }, 226 | Label: VertexReferenceResult, 227 | }, 228 | } 229 | } 230 | 231 | // StartPos contains the precise position information. 232 | type Pos struct { 233 | // The line number (0-based index) 234 | Line int `json:"line"` 235 | // The column of the character (0-based index) 236 | Character int `json:"character"` 237 | } 238 | 239 | // Range contains range information of a vertex object. 240 | type Range struct { 241 | Vertex 242 | // The start position of the range. 243 | Start Pos `json:"start"` 244 | // The end position of the range. 245 | End Pos `json:"end"` 246 | } 247 | 248 | // NewRange returns a new Range object with given ID and position information. 249 | func NewRange(id int, start, end Pos) *Range { 250 | return &Range{ 251 | Vertex: Vertex{ 252 | Element: Element{ 253 | ID: id, 254 | Type: ElementVertex, 255 | }, 256 | Label: VertexRange, 257 | }, 258 | Start: start, 259 | End: end, 260 | } 261 | } 262 | 263 | // DefinitionResult connects a definition that is spread over multiple ranges or multiple documents. 264 | type DefinitionResult struct { 265 | Vertex 266 | } 267 | 268 | // NewDefinitionResult returns a new DefinitionResult object with given ID. 269 | func NewDefinitionResult(id int) *DefinitionResult { 270 | return &DefinitionResult{ 271 | Vertex: Vertex{ 272 | Element: Element{ 273 | ID: id, 274 | Type: ElementVertex, 275 | }, 276 | Label: VertexDefinitionResult, 277 | }, 278 | } 279 | } 280 | 281 | // MarkedString is the object to describe marked string. 282 | type MarkedString markedString 283 | 284 | type markedString struct { 285 | // The language of the marked string. 286 | Language string `json:"language"` 287 | // The value of the marked string. 288 | Value string `json:"value"` 289 | // Indicates whether to marshal JSON as raw string. 290 | isRawString bool 291 | } 292 | 293 | func (m *MarkedString) UnmarshalJSON(data []byte) error { 294 | if d := strings.TrimSpace(string(data)); len(d) > 0 && d[0] == '"' { 295 | // Raw string 296 | var s string 297 | if err := json.Unmarshal(data, &s); err != nil { 298 | return err 299 | } 300 | m.Value = s 301 | m.isRawString = true 302 | return nil 303 | } 304 | // Language string 305 | ms := (*markedString)(m) 306 | return json.Unmarshal(data, ms) 307 | } 308 | 309 | func (m MarkedString) MarshalJSON() ([]byte, error) { 310 | if m.isRawString { 311 | return json.Marshal(m.Value) 312 | } 313 | return json.Marshal((markedString)(m)) 314 | } 315 | 316 | // NewMarkedString returns a MarkedString with given string in language "go". 317 | func NewMarkedString(s string) MarkedString { 318 | return MarkedString{ 319 | Language: LanguageID, 320 | Value: s, 321 | } 322 | } 323 | 324 | // RawMarkedString returns a MarkedString consisting of only a raw string 325 | // (i.e., "foo" instead of {"value":"foo", "language":"bar"}). 326 | func RawMarkedString(s string) MarkedString { 327 | return MarkedString{ 328 | Value: s, 329 | isRawString: true, 330 | } 331 | } 332 | 333 | type hoverResult struct { 334 | Contents []MarkedString `json:"contents"` 335 | } 336 | 337 | // HoverResult connects a hover that is spread over multiple ranges or multiple documents. 338 | type HoverResult struct { 339 | Vertex 340 | // The result contents as the hover information. 341 | Result hoverResult `json:"result"` 342 | } 343 | 344 | // NewHoverResult returns a new HoverResult object with given ID, signature and extra contents. 345 | func NewHoverResult(id int, contents []MarkedString) *HoverResult { 346 | return &HoverResult{ 347 | Vertex: Vertex{ 348 | Element: Element{ 349 | ID: id, 350 | Type: ElementVertex, 351 | }, 352 | Label: VertexHoverResult, 353 | }, 354 | Result: hoverResult{ 355 | Contents: contents, 356 | }, 357 | } 358 | } 359 | 360 | // Moniker describes a unique name for a result set or range. 361 | type Moniker struct { 362 | Vertex 363 | // The kind of moniker (e.g. local, export, import). 364 | Kind string `json:"kind"` 365 | // The kind of moniker, usually a language or package manager. 366 | Scheme string `json:"scheme"` 367 | // The unique moniker identifier. 368 | Identifier string `json:"identifier"` 369 | } 370 | 371 | // NewMoniker returns a new Moniker wtih the given ID, kind, scheme, and identifier. 372 | func NewMoniker(id int, kind, scheme, identifier string) *Moniker { 373 | return &Moniker{ 374 | Vertex: Vertex{ 375 | Element: Element{ 376 | ID: id, 377 | Type: ElementVertex, 378 | }, 379 | Label: VertexMoniker, 380 | }, 381 | Kind: kind, 382 | Scheme: scheme, 383 | Identifier: identifier, 384 | } 385 | } 386 | 387 | // PackageInformation describes a package for a moniker. 388 | type PackageInformation struct { 389 | Vertex 390 | // The name of the package. 391 | Name string `json:"name"` 392 | // The package manager. 393 | Manager string `json:"manager"` 394 | // The version of the package. 395 | Version string `json:"version"` 396 | } 397 | 398 | // NewPackageInformation returns a new PackageInformation with the given ID, name, manager, and version. 399 | func NewPackageInformation(id int, name, manager, version string) *PackageInformation { 400 | return &PackageInformation{ 401 | Vertex: Vertex{ 402 | Element: Element{ 403 | ID: id, 404 | Type: ElementVertex, 405 | }, 406 | Label: VertexPackageInformation, 407 | }, 408 | Name: name, 409 | Manager: manager, 410 | Version: version, 411 | } 412 | } 413 | 414 | // Edge contains information of an edge in the graph. 415 | type Edge struct { 416 | Element 417 | // The kind of edge in the graph. 418 | Label EdgeLabel `json:"label"` 419 | } 420 | 421 | // EdgeLabel represents the purpose of an edge. 422 | type EdgeLabel string 423 | 424 | const ( 425 | EdgeContains EdgeLabel = "contains" 426 | EdgeItem EdgeLabel = "item" 427 | EdgeNext EdgeLabel = "next" 428 | EdgeMoniker EdgeLabel = "moniker" 429 | EdgeNextMoniker EdgeLabel = "nextMoniker" 430 | EdgePackageInformation EdgeLabel = "packageInformation" 431 | EdgeTextDocumentDocumentSymbol EdgeLabel = "textDocument/documentSymbol" 432 | EdgeTextDocumentFoldingRange EdgeLabel = "textDocument/foldingRange" 433 | EdgeTextDocumentDocumentLink EdgeLabel = "textDocument/documentLink" 434 | EdgeTextDocumentDiagnostic EdgeLabel = "textDocument/diagnostic" 435 | EdgeTextDocumentDefinition EdgeLabel = "textDocument/definition" 436 | EdgeTextDocumentDeclaration EdgeLabel = "textDocument/declaration" 437 | EdgeTextDocumentTypeDefinition EdgeLabel = "textDocument/typeDefinition" 438 | EdgeTextDocumentHover EdgeLabel = "textDocument/hover" 439 | EdgeTextDocumentReferences EdgeLabel = "textDocument/references" 440 | EdgeTextDocumentImplementation EdgeLabel = "textDocument/implementation" 441 | ) 442 | 443 | // Next is an edge object that represents "next" relation. 444 | type Next struct { 445 | Edge 446 | OutV int `json:"outV"` 447 | InV int `json:"inV"` 448 | } 449 | 450 | // NewNext returns a new Next object with given ID and vertices information. 451 | func NewNext(id, outV, inV int) *Next { 452 | return &Next{ 453 | Edge: Edge{ 454 | Element: Element{ 455 | ID: id, 456 | Type: ElementEdge, 457 | }, 458 | Label: EdgeNext, 459 | }, 460 | OutV: outV, 461 | InV: inV, 462 | } 463 | } 464 | 465 | // Contains is an edge object that represents 1:n "contains" relation. 466 | type Contains struct { 467 | Edge 468 | OutV int `json:"outV"` 469 | InVs []int `json:"inVs"` 470 | } 471 | 472 | // NewContains returns a new Contains object with given ID and vertices information. 473 | func NewContains(id, outV int, inVs []int) *Contains { 474 | return &Contains{ 475 | Edge: Edge{ 476 | Element: Element{ 477 | ID: id, 478 | Type: ElementEdge, 479 | }, 480 | Label: EdgeContains, 481 | }, 482 | OutV: outV, 483 | InVs: inVs, 484 | } 485 | } 486 | 487 | // TextDocumentDefinition is an edge object that represents "textDocument/definition" relation. 488 | type TextDocumentDefinition struct { 489 | Edge 490 | OutV int `json:"outV"` 491 | InV int `json:"inV"` 492 | } 493 | 494 | // NewTextDocumentDefinition returns a new TextDocumentDefinition object with given ID and 495 | // vertices information. 496 | func NewTextDocumentDefinition(id, outV, inV int) *TextDocumentDefinition { 497 | return &TextDocumentDefinition{ 498 | Edge: Edge{ 499 | Element: Element{ 500 | ID: id, 501 | Type: ElementEdge, 502 | }, 503 | Label: EdgeTextDocumentDefinition, 504 | }, 505 | OutV: outV, 506 | InV: inV, 507 | } 508 | } 509 | 510 | // TextDocumentHover is an edge object that represents "textDocument/hover" relation. 511 | type TextDocumentHover struct { 512 | Edge 513 | OutV int `json:"outV"` 514 | InV int `json:"inV"` 515 | } 516 | 517 | // NewTextDocumentHover returns a new TextDocumentHover object with given ID and 518 | // vertices information. 519 | func NewTextDocumentHover(id, outV, inV int) *TextDocumentHover { 520 | return &TextDocumentHover{ 521 | Edge: Edge{ 522 | Element: Element{ 523 | ID: id, 524 | Type: ElementEdge, 525 | }, 526 | Label: EdgeTextDocumentHover, 527 | }, 528 | OutV: outV, 529 | InV: inV, 530 | } 531 | } 532 | 533 | // TextDocumentReferences is an edge object that represents "textDocument/references" relation. 534 | type TextDocumentReferences struct { 535 | Edge 536 | OutV int `json:"outV"` 537 | InV int `json:"inV"` 538 | } 539 | 540 | // NewTextDocumentReferences returns a new TextDocumentReferences object with given ID and 541 | // vertices information. 542 | func NewTextDocumentReferences(id, outV, inV int) *TextDocumentReferences { 543 | return &TextDocumentReferences{ 544 | Edge: Edge{ 545 | Element: Element{ 546 | ID: id, 547 | Type: ElementEdge, 548 | }, 549 | Label: EdgeTextDocumentReferences, 550 | }, 551 | OutV: outV, 552 | InV: inV, 553 | } 554 | } 555 | 556 | // Item is an edge object that represents "item" relation. 557 | type Item struct { 558 | Edge 559 | OutV int `json:"outV"` 560 | InVs []int `json:"inVs"` 561 | // The document the item belongs to. 562 | Document int `json:"document"` 563 | // The relationship property of the item. 564 | Property string `json:"property,omitempty"` 565 | } 566 | 567 | // NewItem returns a new Item object with given ID and vertices information. 568 | func NewItem(id, outV int, inVs []int, document int) *Item { 569 | return &Item{ 570 | Edge: Edge{ 571 | Element: Element{ 572 | ID: id, 573 | Type: ElementEdge, 574 | }, 575 | Label: EdgeItem, 576 | }, 577 | OutV: outV, 578 | InVs: inVs, 579 | Document: document, 580 | } 581 | } 582 | 583 | // NewItemWithProperty returns a new Item object with given ID, vertices, document and 584 | // property information. 585 | func NewItemWithProperty(id, outV int, inVs []int, document int, property string) *Item { 586 | i := NewItem(id, outV, inVs, document) 587 | i.Property = property 588 | return i 589 | } 590 | 591 | // NewItemOfDefinitions returns a new Item object with given ID, vertices and document 592 | // informationand in "definitions" relationship. 593 | func NewItemOfDefinitions(id, outV int, inVs []int, document int) *Item { 594 | return NewItemWithProperty(id, outV, inVs, document, "definitions") 595 | } 596 | 597 | // NewItemOfReferences returns a new Item object with given ID, vertices and document 598 | // informationand in "references" relationship. 599 | func NewItemOfReferences(id, outV int, inVs []int, document int) *Item { 600 | return NewItemWithProperty(id, outV, inVs, document, "references") 601 | } 602 | 603 | // MonikerEdge connects a moniker to a range or result set. 604 | type MonikerEdge struct { 605 | Edge 606 | OutV int `json:"outV"` 607 | InV int `json:"inV"` 608 | } 609 | 610 | // NewMonikerEdge returns a new MonikerEdge with the given ID and vertices. 611 | func NewMonikerEdge(id, outV, inV int) *MonikerEdge { 612 | return &MonikerEdge{ 613 | Edge: Edge{ 614 | Element: Element{ 615 | ID: id, 616 | Type: ElementEdge, 617 | }, 618 | Label: EdgeMoniker, 619 | }, 620 | OutV: outV, 621 | InV: inV, 622 | } 623 | } 624 | 625 | // NextMonikerEdge connects a moniker to another moniker. 626 | type NextMonikerEdge struct { 627 | Edge 628 | OutV int `json:"outV"` 629 | InV int `json:"inV"` 630 | } 631 | 632 | // NewNextMonikerEdge returns a new NextMonikerEdge with the given ID and vertices. 633 | func NewNextMonikerEdge(id, outV, inV int) *NextMonikerEdge { 634 | return &NextMonikerEdge{ 635 | Edge: Edge{ 636 | Element: Element{ 637 | ID: id, 638 | Type: ElementEdge, 639 | }, 640 | Label: EdgeNextMoniker, 641 | }, 642 | OutV: outV, 643 | InV: inV, 644 | } 645 | } 646 | 647 | // PackageInformationEdge connects a moniker and a package information vertex. 648 | type PackageInformationEdge struct { 649 | Edge 650 | OutV int `json:"outV"` 651 | InV int `json:"inV"` 652 | } 653 | 654 | // NewPackageInformationEdge returns a new PackageInformationEdge with the given ID and vertices. 655 | func NewPackageInformationEdge(id, outV, inV int) *PackageInformationEdge { 656 | return &PackageInformationEdge{ 657 | Edge: Edge{ 658 | Element: Element{ 659 | ID: id, 660 | Type: ElementEdge, 661 | }, 662 | Label: EdgePackageInformation, 663 | }, 664 | OutV: outV, 665 | InV: inV, 666 | } 667 | } 668 | -------------------------------------------------------------------------------- /parser/jsonnet_lexer.go: -------------------------------------------------------------------------------- 1 | // Code generated from Jsonnet.g4 by ANTLR 4.8. DO NOT EDIT. 2 | 3 | package parser 4 | 5 | import ( 6 | "fmt" 7 | "unicode" 8 | 9 | "github.com/antlr/antlr4/runtime/Go/antlr" 10 | ) 11 | 12 | // Suppress unused import error 13 | var _ = fmt.Printf 14 | var _ = unicode.IsLetter 15 | 16 | var serializedLexerAtn = []uint16{ 17 | 3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 58, 475, 18 | 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 19 | 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 20 | 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 21 | 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 22 | 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 23 | 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 24 | 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 25 | 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 26 | 9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 4, 47, 9, 47, 4, 48, 9, 48, 4, 49, 9, 27 | 49, 4, 50, 9, 50, 4, 51, 9, 51, 4, 52, 9, 52, 4, 53, 9, 53, 4, 54, 9, 54, 28 | 4, 55, 9, 55, 4, 56, 9, 56, 4, 57, 9, 57, 4, 58, 9, 58, 4, 59, 9, 59, 4, 29 | 60, 9, 60, 4, 61, 9, 61, 4, 62, 9, 62, 4, 63, 9, 63, 4, 64, 9, 64, 3, 2, 30 | 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 5, 3, 5, 3, 6, 3, 6, 3, 7, 3, 7, 3, 8, 31 | 3, 8, 3, 9, 3, 9, 3, 10, 3, 10, 3, 11, 3, 11, 3, 12, 3, 12, 3, 13, 3, 13, 32 | 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 33 | 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 34 | 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 35 | 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 21, 3, 21, 36 | 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 37 | 22, 3, 22, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 38 | 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 39 | 26, 3, 26, 3, 26, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 40 | 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 28, 3, 41 | 28, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 42 | 3, 31, 3, 32, 3, 32, 3, 33, 3, 33, 3, 34, 3, 34, 3, 35, 3, 35, 3, 36, 3, 43 | 36, 3, 37, 3, 37, 3, 37, 3, 38, 3, 38, 3, 38, 3, 39, 3, 39, 3, 40, 3, 40, 44 | 3, 41, 3, 41, 3, 41, 3, 42, 3, 42, 3, 43, 3, 43, 3, 43, 3, 44, 3, 44, 3, 45 | 44, 3, 45, 3, 45, 3, 45, 3, 46, 3, 46, 3, 46, 3, 47, 3, 47, 3, 48, 3, 48, 46 | 3, 49, 3, 49, 3, 50, 3, 50, 3, 51, 3, 51, 3, 51, 3, 51, 7, 51, 309, 10, 47 | 51, 12, 51, 14, 51, 312, 11, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 7, 48 | 51, 319, 10, 51, 12, 51, 14, 51, 322, 11, 51, 3, 51, 3, 51, 3, 51, 3, 51, 49 | 3, 51, 3, 51, 7, 51, 330, 10, 51, 12, 51, 14, 51, 333, 11, 51, 3, 51, 3, 50 | 51, 3, 51, 3, 51, 3, 51, 3, 51, 7, 51, 341, 10, 51, 12, 51, 14, 51, 344, 51 | 11, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 7, 51, 352, 10, 51, 12, 52 | 51, 14, 51, 355, 11, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 53 | 3, 51, 3, 51, 3, 51, 3, 51, 3, 51, 7, 51, 369, 10, 51, 12, 51, 14, 51, 54 | 372, 11, 51, 3, 51, 3, 51, 3, 51, 5, 51, 377, 10, 51, 3, 52, 3, 52, 3, 55 | 52, 6, 52, 382, 10, 52, 13, 52, 14, 52, 383, 5, 52, 386, 10, 52, 3, 52, 56 | 5, 52, 389, 10, 52, 3, 53, 3, 53, 3, 53, 7, 53, 394, 10, 53, 12, 53, 14, 57 | 53, 397, 11, 53, 3, 54, 3, 54, 3, 54, 3, 55, 3, 55, 3, 56, 3, 56, 3, 57, 58 | 3, 57, 3, 57, 3, 57, 3, 57, 3, 57, 3, 58, 3, 58, 3, 59, 3, 59, 3, 59, 7, 59 | 59, 417, 10, 59, 12, 59, 14, 59, 420, 11, 59, 5, 59, 422, 10, 59, 3, 60, 60 | 3, 60, 5, 60, 426, 10, 60, 3, 60, 6, 60, 429, 10, 60, 13, 60, 14, 60, 430, 61 | 3, 61, 6, 61, 434, 10, 61, 13, 61, 14, 61, 435, 3, 61, 3, 61, 3, 62, 3, 62 | 62, 5, 62, 442, 10, 62, 3, 62, 5, 62, 445, 10, 62, 3, 62, 3, 62, 3, 63, 63 | 3, 63, 3, 63, 3, 63, 7, 63, 453, 10, 63, 12, 63, 14, 63, 456, 11, 63, 3, 64 | 63, 3, 63, 3, 63, 3, 63, 3, 63, 3, 64, 3, 64, 3, 64, 5, 64, 466, 10, 64, 65 | 3, 64, 7, 64, 469, 10, 64, 12, 64, 14, 64, 472, 11, 64, 3, 64, 3, 64, 3, 66 | 454, 2, 65, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 67 | 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 68 | 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 69 | 57, 30, 59, 31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 37, 73, 38, 70 | 75, 39, 77, 40, 79, 41, 81, 42, 83, 43, 85, 44, 87, 45, 89, 46, 91, 47, 71 | 93, 48, 95, 49, 97, 50, 99, 51, 101, 52, 103, 53, 105, 54, 107, 2, 109, 72 | 2, 111, 2, 113, 2, 115, 2, 117, 2, 119, 2, 121, 55, 123, 56, 125, 57, 127, 73 | 58, 3, 2, 16, 5, 2, 2, 33, 36, 36, 94, 94, 5, 2, 2, 33, 41, 41, 94, 94, 74 | 3, 2, 36, 36, 3, 2, 41, 41, 3, 2, 126, 126, 11, 2, 36, 36, 41, 41, 49, 75 | 49, 94, 94, 100, 100, 104, 104, 112, 112, 116, 116, 118, 118, 3, 2, 50, 76 | 59, 5, 2, 67, 92, 97, 97, 99, 124, 5, 2, 50, 59, 67, 72, 99, 104, 3, 2, 77 | 51, 59, 4, 2, 71, 71, 103, 103, 4, 2, 45, 45, 47, 47, 4, 2, 11, 11, 34, 78 | 34, 4, 2, 12, 12, 15, 15, 2, 502, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 79 | 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 80 | 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 81 | 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 82 | 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 83 | 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 84 | 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 85 | 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 86 | 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 87 | 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 88 | 2, 2, 2, 77, 3, 2, 2, 2, 2, 79, 3, 2, 2, 2, 2, 81, 3, 2, 2, 2, 2, 83, 3, 89 | 2, 2, 2, 2, 85, 3, 2, 2, 2, 2, 87, 3, 2, 2, 2, 2, 89, 3, 2, 2, 2, 2, 91, 90 | 3, 2, 2, 2, 2, 93, 3, 2, 2, 2, 2, 95, 3, 2, 2, 2, 2, 97, 3, 2, 2, 2, 2, 91 | 99, 3, 2, 2, 2, 2, 101, 3, 2, 2, 2, 2, 103, 3, 2, 2, 2, 2, 105, 3, 2, 2, 92 | 2, 2, 121, 3, 2, 2, 2, 2, 123, 3, 2, 2, 2, 2, 125, 3, 2, 2, 2, 2, 127, 93 | 3, 2, 2, 2, 3, 129, 3, 2, 2, 2, 5, 131, 3, 2, 2, 2, 7, 133, 3, 2, 2, 2, 94 | 9, 135, 3, 2, 2, 2, 11, 137, 3, 2, 2, 2, 13, 139, 3, 2, 2, 2, 15, 141, 95 | 3, 2, 2, 2, 17, 143, 3, 2, 2, 2, 19, 145, 3, 2, 2, 2, 21, 147, 3, 2, 2, 96 | 2, 23, 149, 3, 2, 2, 2, 25, 151, 3, 2, 2, 2, 27, 153, 3, 2, 2, 2, 29, 160, 97 | 3, 2, 2, 2, 31, 165, 3, 2, 2, 2, 33, 171, 3, 2, 2, 2, 35, 177, 3, 2, 2, 98 | 2, 37, 181, 3, 2, 2, 2, 39, 190, 3, 2, 2, 2, 41, 193, 3, 2, 2, 2, 43, 200, 99 | 3, 2, 2, 2, 45, 210, 3, 2, 2, 2, 47, 216, 3, 2, 2, 2, 49, 221, 3, 2, 2, 100 | 2, 51, 226, 3, 2, 2, 2, 53, 232, 3, 2, 2, 2, 55, 243, 3, 2, 2, 2, 57, 248, 101 | 3, 2, 2, 2, 59, 253, 3, 2, 2, 2, 61, 256, 3, 2, 2, 2, 63, 259, 3, 2, 2, 102 | 2, 65, 261, 3, 2, 2, 2, 67, 263, 3, 2, 2, 2, 69, 265, 3, 2, 2, 2, 71, 267, 103 | 3, 2, 2, 2, 73, 269, 3, 2, 2, 2, 75, 272, 3, 2, 2, 2, 77, 275, 3, 2, 2, 104 | 2, 79, 277, 3, 2, 2, 2, 81, 279, 3, 2, 2, 2, 83, 282, 3, 2, 2, 2, 85, 284, 105 | 3, 2, 2, 2, 87, 287, 3, 2, 2, 2, 89, 290, 3, 2, 2, 2, 91, 293, 3, 2, 2, 106 | 2, 93, 296, 3, 2, 2, 2, 95, 298, 3, 2, 2, 2, 97, 300, 3, 2, 2, 2, 99, 302, 107 | 3, 2, 2, 2, 101, 376, 3, 2, 2, 2, 103, 378, 3, 2, 2, 2, 105, 390, 3, 2, 108 | 2, 2, 107, 398, 3, 2, 2, 2, 109, 401, 3, 2, 2, 2, 111, 403, 3, 2, 2, 2, 109 | 113, 405, 3, 2, 2, 2, 115, 411, 3, 2, 2, 2, 117, 421, 3, 2, 2, 2, 119, 110 | 423, 3, 2, 2, 2, 121, 433, 3, 2, 2, 2, 123, 444, 3, 2, 2, 2, 125, 448, 111 | 3, 2, 2, 2, 127, 465, 3, 2, 2, 2, 129, 130, 7, 42, 2, 2, 130, 4, 3, 2, 112 | 2, 2, 131, 132, 7, 43, 2, 2, 132, 6, 3, 2, 2, 2, 133, 134, 7, 125, 2, 2, 113 | 134, 8, 3, 2, 2, 2, 135, 136, 7, 127, 2, 2, 136, 10, 3, 2, 2, 2, 137, 138, 114 | 7, 93, 2, 2, 138, 12, 3, 2, 2, 2, 139, 140, 7, 46, 2, 2, 140, 14, 3, 2, 115 | 2, 2, 141, 142, 7, 95, 2, 2, 142, 16, 3, 2, 2, 2, 143, 144, 7, 48, 2, 2, 116 | 144, 18, 3, 2, 2, 2, 145, 146, 7, 60, 2, 2, 146, 20, 3, 2, 2, 2, 147, 148, 117 | 7, 61, 2, 2, 148, 22, 3, 2, 2, 2, 149, 150, 7, 63, 2, 2, 150, 24, 3, 2, 118 | 2, 2, 151, 152, 7, 38, 2, 2, 152, 26, 3, 2, 2, 2, 153, 154, 7, 99, 2, 2, 119 | 154, 155, 7, 117, 2, 2, 155, 156, 7, 117, 2, 2, 156, 157, 7, 103, 2, 2, 120 | 157, 158, 7, 116, 2, 2, 158, 159, 7, 118, 2, 2, 159, 28, 3, 2, 2, 2, 160, 121 | 161, 7, 103, 2, 2, 161, 162, 7, 110, 2, 2, 162, 163, 7, 117, 2, 2, 163, 122 | 164, 7, 103, 2, 2, 164, 30, 3, 2, 2, 2, 165, 166, 7, 103, 2, 2, 166, 167, 123 | 7, 116, 2, 2, 167, 168, 7, 116, 2, 2, 168, 169, 7, 113, 2, 2, 169, 170, 124 | 7, 116, 2, 2, 170, 32, 3, 2, 2, 2, 171, 172, 7, 104, 2, 2, 172, 173, 7, 125 | 99, 2, 2, 173, 174, 7, 110, 2, 2, 174, 175, 7, 117, 2, 2, 175, 176, 7, 126 | 103, 2, 2, 176, 34, 3, 2, 2, 2, 177, 178, 7, 104, 2, 2, 178, 179, 7, 113, 127 | 2, 2, 179, 180, 7, 116, 2, 2, 180, 36, 3, 2, 2, 2, 181, 182, 7, 104, 2, 128 | 2, 182, 183, 7, 119, 2, 2, 183, 184, 7, 112, 2, 2, 184, 185, 7, 101, 2, 129 | 2, 185, 186, 7, 118, 2, 2, 186, 187, 7, 107, 2, 2, 187, 188, 7, 113, 2, 130 | 2, 188, 189, 7, 112, 2, 2, 189, 38, 3, 2, 2, 2, 190, 191, 7, 107, 2, 2, 131 | 191, 192, 7, 104, 2, 2, 192, 40, 3, 2, 2, 2, 193, 194, 7, 107, 2, 2, 194, 132 | 195, 7, 111, 2, 2, 195, 196, 7, 114, 2, 2, 196, 197, 7, 113, 2, 2, 197, 133 | 198, 7, 116, 2, 2, 198, 199, 7, 118, 2, 2, 199, 42, 3, 2, 2, 2, 200, 201, 134 | 7, 107, 2, 2, 201, 202, 7, 111, 2, 2, 202, 203, 7, 114, 2, 2, 203, 204, 135 | 7, 113, 2, 2, 204, 205, 7, 116, 2, 2, 205, 206, 7, 118, 2, 2, 206, 207, 136 | 7, 117, 2, 2, 207, 208, 7, 118, 2, 2, 208, 209, 7, 116, 2, 2, 209, 44, 137 | 3, 2, 2, 2, 210, 211, 7, 110, 2, 2, 211, 212, 7, 113, 2, 2, 212, 213, 7, 138 | 101, 2, 2, 213, 214, 7, 99, 2, 2, 214, 215, 7, 110, 2, 2, 215, 46, 3, 2, 139 | 2, 2, 216, 217, 7, 112, 2, 2, 217, 218, 7, 119, 2, 2, 218, 219, 7, 110, 140 | 2, 2, 219, 220, 7, 110, 2, 2, 220, 48, 3, 2, 2, 2, 221, 222, 7, 117, 2, 141 | 2, 222, 223, 7, 103, 2, 2, 223, 224, 7, 110, 2, 2, 224, 225, 7, 104, 2, 142 | 2, 225, 50, 3, 2, 2, 2, 226, 227, 7, 117, 2, 2, 227, 228, 7, 119, 2, 2, 143 | 228, 229, 7, 114, 2, 2, 229, 230, 7, 103, 2, 2, 230, 231, 7, 116, 2, 2, 144 | 231, 52, 3, 2, 2, 2, 232, 233, 7, 118, 2, 2, 233, 234, 7, 99, 2, 2, 234, 145 | 235, 7, 107, 2, 2, 235, 236, 7, 110, 2, 2, 236, 237, 7, 117, 2, 2, 237, 146 | 238, 7, 118, 2, 2, 238, 239, 7, 116, 2, 2, 239, 240, 7, 107, 2, 2, 240, 147 | 241, 7, 101, 2, 2, 241, 242, 7, 118, 2, 2, 242, 54, 3, 2, 2, 2, 243, 244, 148 | 7, 118, 2, 2, 244, 245, 7, 106, 2, 2, 245, 246, 7, 103, 2, 2, 246, 247, 149 | 7, 112, 2, 2, 247, 56, 3, 2, 2, 2, 248, 249, 7, 118, 2, 2, 249, 250, 7, 150 | 116, 2, 2, 250, 251, 7, 119, 2, 2, 251, 252, 7, 103, 2, 2, 252, 58, 3, 151 | 2, 2, 2, 253, 254, 7, 63, 2, 2, 254, 255, 7, 63, 2, 2, 255, 60, 3, 2, 2, 152 | 2, 256, 257, 7, 35, 2, 2, 257, 258, 7, 63, 2, 2, 258, 62, 3, 2, 2, 2, 259, 153 | 260, 7, 45, 2, 2, 260, 64, 3, 2, 2, 2, 261, 262, 7, 47, 2, 2, 262, 66, 154 | 3, 2, 2, 2, 263, 264, 7, 44, 2, 2, 264, 68, 3, 2, 2, 2, 265, 266, 7, 49, 155 | 2, 2, 266, 70, 3, 2, 2, 2, 267, 268, 7, 39, 2, 2, 268, 72, 3, 2, 2, 2, 156 | 269, 270, 7, 40, 2, 2, 270, 271, 7, 40, 2, 2, 271, 74, 3, 2, 2, 2, 272, 157 | 273, 7, 126, 2, 2, 273, 274, 7, 126, 2, 2, 274, 76, 3, 2, 2, 2, 275, 276, 158 | 7, 35, 2, 2, 276, 78, 3, 2, 2, 2, 277, 278, 7, 64, 2, 2, 278, 80, 3, 2, 159 | 2, 2, 279, 280, 7, 64, 2, 2, 280, 281, 7, 63, 2, 2, 281, 82, 3, 2, 2, 2, 160 | 282, 283, 7, 62, 2, 2, 283, 84, 3, 2, 2, 2, 284, 285, 7, 62, 2, 2, 285, 161 | 286, 7, 63, 2, 2, 286, 86, 3, 2, 2, 2, 287, 288, 7, 107, 2, 2, 288, 289, 162 | 7, 112, 2, 2, 289, 88, 3, 2, 2, 2, 290, 291, 7, 62, 2, 2, 291, 292, 7, 163 | 62, 2, 2, 292, 90, 3, 2, 2, 2, 293, 294, 7, 64, 2, 2, 294, 295, 7, 64, 164 | 2, 2, 295, 92, 3, 2, 2, 2, 296, 297, 7, 128, 2, 2, 297, 94, 3, 2, 2, 2, 165 | 298, 299, 7, 40, 2, 2, 299, 96, 3, 2, 2, 2, 300, 301, 7, 96, 2, 2, 301, 166 | 98, 3, 2, 2, 2, 302, 303, 7, 126, 2, 2, 303, 100, 3, 2, 2, 2, 304, 310, 167 | 7, 36, 2, 2, 305, 309, 5, 107, 54, 2, 306, 309, 5, 113, 57, 2, 307, 309, 168 | 10, 2, 2, 2, 308, 305, 3, 2, 2, 2, 308, 306, 3, 2, 2, 2, 308, 307, 3, 2, 169 | 2, 2, 309, 312, 3, 2, 2, 2, 310, 308, 3, 2, 2, 2, 310, 311, 3, 2, 2, 2, 170 | 311, 313, 3, 2, 2, 2, 312, 310, 3, 2, 2, 2, 313, 377, 7, 36, 2, 2, 314, 171 | 320, 7, 41, 2, 2, 315, 319, 5, 107, 54, 2, 316, 319, 5, 113, 57, 2, 317, 172 | 319, 10, 3, 2, 2, 318, 315, 3, 2, 2, 2, 318, 316, 3, 2, 2, 2, 318, 317, 173 | 3, 2, 2, 2, 319, 322, 3, 2, 2, 2, 320, 318, 3, 2, 2, 2, 320, 321, 3, 2, 174 | 2, 2, 321, 323, 3, 2, 2, 2, 322, 320, 3, 2, 2, 2, 323, 377, 7, 41, 2, 2, 175 | 324, 325, 7, 66, 2, 2, 325, 331, 7, 36, 2, 2, 326, 327, 7, 36, 2, 2, 327, 176 | 330, 7, 36, 2, 2, 328, 330, 10, 4, 2, 2, 329, 326, 3, 2, 2, 2, 329, 328, 177 | 3, 2, 2, 2, 330, 333, 3, 2, 2, 2, 331, 329, 3, 2, 2, 2, 331, 332, 3, 2, 178 | 2, 2, 332, 334, 3, 2, 2, 2, 333, 331, 3, 2, 2, 2, 334, 377, 7, 36, 2, 2, 179 | 335, 336, 7, 66, 2, 2, 336, 342, 7, 41, 2, 2, 337, 338, 7, 41, 2, 2, 338, 180 | 341, 7, 41, 2, 2, 339, 341, 10, 5, 2, 2, 340, 337, 3, 2, 2, 2, 340, 339, 181 | 3, 2, 2, 2, 341, 344, 3, 2, 2, 2, 342, 340, 3, 2, 2, 2, 342, 343, 3, 2, 182 | 2, 2, 343, 345, 3, 2, 2, 2, 344, 342, 3, 2, 2, 2, 345, 377, 7, 41, 2, 2, 183 | 346, 347, 7, 66, 2, 2, 347, 353, 7, 41, 2, 2, 348, 349, 7, 41, 2, 2, 349, 184 | 352, 7, 41, 2, 2, 350, 352, 10, 5, 2, 2, 351, 348, 3, 2, 2, 2, 351, 350, 185 | 3, 2, 2, 2, 352, 355, 3, 2, 2, 2, 353, 351, 3, 2, 2, 2, 353, 354, 3, 2, 186 | 2, 2, 354, 356, 3, 2, 2, 2, 355, 353, 3, 2, 2, 2, 356, 377, 7, 41, 2, 2, 187 | 357, 358, 7, 126, 2, 2, 358, 359, 7, 126, 2, 2, 359, 360, 7, 126, 2, 2, 188 | 360, 370, 3, 2, 2, 2, 361, 369, 10, 6, 2, 2, 362, 363, 7, 126, 2, 2, 363, 189 | 369, 10, 6, 2, 2, 364, 365, 7, 126, 2, 2, 365, 366, 7, 126, 2, 2, 366, 190 | 367, 3, 2, 2, 2, 367, 369, 10, 6, 2, 2, 368, 361, 3, 2, 2, 2, 368, 362, 191 | 3, 2, 2, 2, 368, 364, 3, 2, 2, 2, 369, 372, 3, 2, 2, 2, 370, 368, 3, 2, 192 | 2, 2, 370, 371, 3, 2, 2, 2, 371, 373, 3, 2, 2, 2, 372, 370, 3, 2, 2, 2, 193 | 373, 374, 7, 126, 2, 2, 374, 375, 7, 126, 2, 2, 375, 377, 7, 126, 2, 2, 194 | 376, 304, 3, 2, 2, 2, 376, 314, 3, 2, 2, 2, 376, 324, 3, 2, 2, 2, 376, 195 | 335, 3, 2, 2, 2, 376, 346, 3, 2, 2, 2, 376, 357, 3, 2, 2, 2, 377, 102, 196 | 3, 2, 2, 2, 378, 385, 5, 117, 59, 2, 379, 381, 7, 48, 2, 2, 380, 382, 5, 197 | 109, 55, 2, 381, 380, 3, 2, 2, 2, 382, 383, 3, 2, 2, 2, 383, 381, 3, 2, 198 | 2, 2, 383, 384, 3, 2, 2, 2, 384, 386, 3, 2, 2, 2, 385, 379, 3, 2, 2, 2, 199 | 385, 386, 3, 2, 2, 2, 386, 388, 3, 2, 2, 2, 387, 389, 5, 119, 60, 2, 388, 200 | 387, 3, 2, 2, 2, 388, 389, 3, 2, 2, 2, 389, 104, 3, 2, 2, 2, 390, 395, 201 | 5, 111, 56, 2, 391, 394, 5, 111, 56, 2, 392, 394, 5, 109, 55, 2, 393, 391, 202 | 3, 2, 2, 2, 393, 392, 3, 2, 2, 2, 394, 397, 3, 2, 2, 2, 395, 393, 3, 2, 203 | 2, 2, 395, 396, 3, 2, 2, 2, 396, 106, 3, 2, 2, 2, 397, 395, 3, 2, 2, 2, 204 | 398, 399, 7, 94, 2, 2, 399, 400, 9, 7, 2, 2, 400, 108, 3, 2, 2, 2, 401, 205 | 402, 9, 8, 2, 2, 402, 110, 3, 2, 2, 2, 403, 404, 9, 9, 2, 2, 404, 112, 206 | 3, 2, 2, 2, 405, 406, 7, 119, 2, 2, 406, 407, 5, 115, 58, 2, 407, 408, 207 | 5, 115, 58, 2, 408, 409, 5, 115, 58, 2, 409, 410, 5, 115, 58, 2, 410, 114, 208 | 3, 2, 2, 2, 411, 412, 9, 10, 2, 2, 412, 116, 3, 2, 2, 2, 413, 422, 7, 50, 209 | 2, 2, 414, 418, 9, 11, 2, 2, 415, 417, 5, 109, 55, 2, 416, 415, 3, 2, 2, 210 | 2, 417, 420, 3, 2, 2, 2, 418, 416, 3, 2, 2, 2, 418, 419, 3, 2, 2, 2, 419, 211 | 422, 3, 2, 2, 2, 420, 418, 3, 2, 2, 2, 421, 413, 3, 2, 2, 2, 421, 414, 212 | 3, 2, 2, 2, 422, 118, 3, 2, 2, 2, 423, 425, 9, 12, 2, 2, 424, 426, 9, 13, 213 | 2, 2, 425, 424, 3, 2, 2, 2, 425, 426, 3, 2, 2, 2, 426, 428, 3, 2, 2, 2, 214 | 427, 429, 5, 109, 55, 2, 428, 427, 3, 2, 2, 2, 429, 430, 3, 2, 2, 2, 430, 215 | 428, 3, 2, 2, 2, 430, 431, 3, 2, 2, 2, 431, 120, 3, 2, 2, 2, 432, 434, 216 | 9, 14, 2, 2, 433, 432, 3, 2, 2, 2, 434, 435, 3, 2, 2, 2, 435, 433, 3, 2, 217 | 2, 2, 435, 436, 3, 2, 2, 2, 436, 437, 3, 2, 2, 2, 437, 438, 8, 61, 2, 2, 218 | 438, 122, 3, 2, 2, 2, 439, 441, 7, 15, 2, 2, 440, 442, 7, 12, 2, 2, 441, 219 | 440, 3, 2, 2, 2, 441, 442, 3, 2, 2, 2, 442, 445, 3, 2, 2, 2, 443, 445, 220 | 7, 12, 2, 2, 444, 439, 3, 2, 2, 2, 444, 443, 3, 2, 2, 2, 445, 446, 3, 2, 221 | 2, 2, 446, 447, 8, 62, 2, 2, 447, 124, 3, 2, 2, 2, 448, 449, 7, 49, 2, 222 | 2, 449, 450, 7, 44, 2, 2, 450, 454, 3, 2, 2, 2, 451, 453, 11, 2, 2, 2, 223 | 452, 451, 3, 2, 2, 2, 453, 456, 3, 2, 2, 2, 454, 455, 3, 2, 2, 2, 454, 224 | 452, 3, 2, 2, 2, 455, 457, 3, 2, 2, 2, 456, 454, 3, 2, 2, 2, 457, 458, 225 | 7, 44, 2, 2, 458, 459, 7, 49, 2, 2, 459, 460, 3, 2, 2, 2, 460, 461, 8, 226 | 63, 2, 2, 461, 126, 3, 2, 2, 2, 462, 463, 7, 49, 2, 2, 463, 466, 7, 49, 227 | 2, 2, 464, 466, 7, 37, 2, 2, 465, 462, 3, 2, 2, 2, 465, 464, 3, 2, 2, 2, 228 | 466, 470, 3, 2, 2, 2, 467, 469, 10, 15, 2, 2, 468, 467, 3, 2, 2, 2, 469, 229 | 472, 3, 2, 2, 2, 470, 468, 3, 2, 2, 2, 470, 471, 3, 2, 2, 2, 471, 473, 230 | 3, 2, 2, 2, 472, 470, 3, 2, 2, 2, 473, 474, 8, 64, 2, 2, 474, 128, 3, 2, 231 | 2, 2, 31, 2, 308, 310, 318, 320, 329, 331, 340, 342, 351, 353, 368, 370, 232 | 376, 383, 385, 388, 393, 395, 418, 421, 425, 430, 435, 441, 444, 454, 465, 233 | 470, 3, 8, 2, 2, 234 | } 235 | 236 | var lexerDeserializer = antlr.NewATNDeserializer(nil) 237 | var lexerAtn = lexerDeserializer.DeserializeFromUInt16(serializedLexerAtn) 238 | 239 | var lexerChannelNames = []string{ 240 | "DEFAULT_TOKEN_CHANNEL", "HIDDEN", 241 | } 242 | 243 | var lexerModeNames = []string{ 244 | "DEFAULT_MODE", 245 | } 246 | 247 | var lexerLiteralNames = []string{ 248 | "", "'('", "')'", "'{'", "'}'", "'['", "','", "']'", "'.'", "':'", "';'", 249 | "'='", "'$'", "'assert'", "'else'", "'error'", "'false'", "'for'", "'function'", 250 | "'if'", "'import'", "'importstr'", "'local'", "'null'", "'self'", "'super'", 251 | "'tailstrict'", "'then'", "'true'", "'=='", "'!='", "'+'", "'-'", "'*'", 252 | "'/'", "'%'", "'&&'", "'||'", "'!'", "'>'", "'>='", "'<'", "'<='", "'in'", 253 | "'<<'", "'>>'", "'~'", "'&'", "'^'", "'|'", 254 | } 255 | 256 | var lexerSymbolicNames = []string{ 257 | "", "", "", "", "", "", "", "", "", "", "", "", "DOLLAR", "ASSERT", "ELSE", 258 | "ERROR", "FALSE", "FOR", "FUNCTION", "IF", "IMPORT", "IMPORTSTR", "LOCAL", 259 | "NULL", "SELF", "SUPER", "TAILSTRICT", "THEN", "TRUE", "EQUALS", "NOTEQUALS", 260 | "PLUS", "MINUS", "MULTIPLY", "DIVIDE", "MODULUS", "AND", "OR", "NOT", "GT", 261 | "GE", "LT", "LE", "IN", "SHIFTLEFT", "SHIFTRIGHT", "BITNOT", "BITAND", 262 | "BITXOR", "BITOR", "STRING", "NUMBER", "ID", "Whitespace", "Newline", "BlockComment", 263 | "LineComment", 264 | } 265 | 266 | var lexerRuleNames = []string{ 267 | "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8", 268 | "T__9", "T__10", "DOLLAR", "ASSERT", "ELSE", "ERROR", "FALSE", "FOR", "FUNCTION", 269 | "IF", "IMPORT", "IMPORTSTR", "LOCAL", "NULL", "SELF", "SUPER", "TAILSTRICT", 270 | "THEN", "TRUE", "EQUALS", "NOTEQUALS", "PLUS", "MINUS", "MULTIPLY", "DIVIDE", 271 | "MODULUS", "AND", "OR", "NOT", "GT", "GE", "LT", "LE", "IN", "SHIFTLEFT", 272 | "SHIFTRIGHT", "BITNOT", "BITAND", "BITXOR", "BITOR", "STRING", "NUMBER", 273 | "ID", "ESCAPES", "DIGIT", "ALPHA", "UNICODE", "HEX", "INT", "EXP", "Whitespace", 274 | "Newline", "BlockComment", "LineComment", 275 | } 276 | 277 | type JsonnetLexer struct { 278 | *antlr.BaseLexer 279 | channelNames []string 280 | modeNames []string 281 | // TODO: EOF string 282 | } 283 | 284 | var lexerDecisionToDFA = make([]*antlr.DFA, len(lexerAtn.DecisionToState)) 285 | 286 | func init() { 287 | for index, ds := range lexerAtn.DecisionToState { 288 | lexerDecisionToDFA[index] = antlr.NewDFA(ds, index) 289 | } 290 | } 291 | 292 | func NewJsonnetLexer(input antlr.CharStream) *JsonnetLexer { 293 | 294 | l := new(JsonnetLexer) 295 | 296 | l.BaseLexer = antlr.NewBaseLexer(input) 297 | l.Interpreter = antlr.NewLexerATNSimulator(l, lexerAtn, lexerDecisionToDFA, antlr.NewPredictionContextCache()) 298 | 299 | l.channelNames = lexerChannelNames 300 | l.modeNames = lexerModeNames 301 | l.RuleNames = lexerRuleNames 302 | l.LiteralNames = lexerLiteralNames 303 | l.SymbolicNames = lexerSymbolicNames 304 | l.GrammarFileName = "Jsonnet.g4" 305 | // TODO: l.EOF = antlr.TokenEOF 306 | 307 | return l 308 | } 309 | 310 | // JsonnetLexer tokens. 311 | const ( 312 | JsonnetLexerT__0 = 1 313 | JsonnetLexerT__1 = 2 314 | JsonnetLexerT__2 = 3 315 | JsonnetLexerT__3 = 4 316 | JsonnetLexerT__4 = 5 317 | JsonnetLexerT__5 = 6 318 | JsonnetLexerT__6 = 7 319 | JsonnetLexerT__7 = 8 320 | JsonnetLexerT__8 = 9 321 | JsonnetLexerT__9 = 10 322 | JsonnetLexerT__10 = 11 323 | JsonnetLexerDOLLAR = 12 324 | JsonnetLexerASSERT = 13 325 | JsonnetLexerELSE = 14 326 | JsonnetLexerERROR = 15 327 | JsonnetLexerFALSE = 16 328 | JsonnetLexerFOR = 17 329 | JsonnetLexerFUNCTION = 18 330 | JsonnetLexerIF = 19 331 | JsonnetLexerIMPORT = 20 332 | JsonnetLexerIMPORTSTR = 21 333 | JsonnetLexerLOCAL = 22 334 | JsonnetLexerNULL = 23 335 | JsonnetLexerSELF = 24 336 | JsonnetLexerSUPER = 25 337 | JsonnetLexerTAILSTRICT = 26 338 | JsonnetLexerTHEN = 27 339 | JsonnetLexerTRUE = 28 340 | JsonnetLexerEQUALS = 29 341 | JsonnetLexerNOTEQUALS = 30 342 | JsonnetLexerPLUS = 31 343 | JsonnetLexerMINUS = 32 344 | JsonnetLexerMULTIPLY = 33 345 | JsonnetLexerDIVIDE = 34 346 | JsonnetLexerMODULUS = 35 347 | JsonnetLexerAND = 36 348 | JsonnetLexerOR = 37 349 | JsonnetLexerNOT = 38 350 | JsonnetLexerGT = 39 351 | JsonnetLexerGE = 40 352 | JsonnetLexerLT = 41 353 | JsonnetLexerLE = 42 354 | JsonnetLexerIN = 43 355 | JsonnetLexerSHIFTLEFT = 44 356 | JsonnetLexerSHIFTRIGHT = 45 357 | JsonnetLexerBITNOT = 46 358 | JsonnetLexerBITAND = 47 359 | JsonnetLexerBITXOR = 48 360 | JsonnetLexerBITOR = 49 361 | JsonnetLexerSTRING = 50 362 | JsonnetLexerNUMBER = 51 363 | JsonnetLexerID = 52 364 | JsonnetLexerWhitespace = 53 365 | JsonnetLexerNewline = 54 366 | JsonnetLexerBlockComment = 55 367 | JsonnetLexerLineComment = 56 368 | ) 369 | --------------------------------------------------------------------------------