├── queries ├── highlights.scm └── injections.scm ├── .gitattributes ├── .github ├── example.png └── workflows │ ├── ci.yml │ └── generate-parser.yml ├── .gitignore ├── binding.gyp ├── README.md ├── bindings ├── node │ ├── index.js │ └── binding.cc └── rust │ ├── build.rs │ └── lib.rs ├── Cargo.toml ├── package.json ├── grammar.js ├── src ├── node-types.json ├── grammar.json ├── tree_sitter │ └── parser.h └── parser.c ├── test └── corpus │ └── main.txt └── LICENSE /queries/highlights.scm: -------------------------------------------------------------------------------- 1 | (prompt) @comment 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | /src/**/* linguist-generated=true 2 | /bindings/**/* linguist-generated=true 3 | -------------------------------------------------------------------------------- /.github/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/elixir-lang/tree-sitter-iex/HEAD/.github/example.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Deps 2 | /node_modules/ 3 | 4 | # Temporary files 5 | /tmp/ 6 | 7 | # Temporary files generated by Tree-sitter 8 | /build/ 9 | log.html 10 | tree-sitter-iex.wasm 11 | -------------------------------------------------------------------------------- /queries/injections.scm: -------------------------------------------------------------------------------- 1 | ((evaluation_block (prompt_line (expression) @injection.content)) 2 | (#set! injection.language "elixir") 3 | (#set! injection.combined)) 4 | 5 | ((result) @injection.content 6 | (#set! injection.language "elixir")) 7 | -------------------------------------------------------------------------------- /binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | { 4 | "target_name": "tree_sitter_iex_binding", 5 | "include_dirs": [ 6 | " 12 | -------------------------------------------------------------------------------- /bindings/node/index.js: -------------------------------------------------------------------------------- 1 | try { 2 | module.exports = require("../../build/Release/tree_sitter_iex_binding"); 3 | } catch (error1) { 4 | if (error1.code !== 'MODULE_NOT_FOUND') { 5 | throw error1; 6 | } 7 | try { 8 | module.exports = require("../../build/Debug/tree_sitter_iex_binding"); 9 | } catch (error2) { 10 | if (error2.code !== 'MODULE_NOT_FOUND') { 11 | throw error2; 12 | } 13 | throw error1 14 | } 15 | } 16 | 17 | try { 18 | module.exports.nodeTypeInfo = require("../../src/node-types.json"); 19 | } catch (_) {} 20 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tree-sitter-iex" 3 | description = "iex grammar for the tree-sitter parsing library" 4 | version = "0.0.1" 5 | keywords = ["incremental", "parsing", "iex"] 6 | categories = ["parsing", "text-editors"] 7 | repository = "https://github.com/tree-sitter/tree-sitter-iex" 8 | edition = "2018" 9 | license = "MIT" 10 | 11 | build = "bindings/rust/build.rs" 12 | include = [ 13 | "bindings/rust/*", 14 | "grammar.js", 15 | "queries/*", 16 | "src/*", 17 | ] 18 | 19 | [lib] 20 | path = "bindings/rust/lib.rs" 21 | 22 | [dependencies] 23 | tree-sitter = "~0.20" 24 | 25 | [build-dependencies] 26 | cc = "1.0" 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tree-sitter-iex", 3 | "version": "0.0.1", 4 | "description": "Interactive Elixir (IEx) grammar for tree-sitter", 5 | "main": "bindings/node", 6 | 7 | "scripts": { 8 | "test": "tree-sitter test", 9 | "format": "prettier --trailing-comma es5 --write grammar.js", 10 | "format-check": "prettier --trailing-comma es5 --check grammar.js" 11 | }, 12 | "keywords": [ 13 | "parser", 14 | "lexer", 15 | "elixir", 16 | "iex", 17 | "tree-sitter" 18 | ], 19 | "license": "Apache-2.0", 20 | "dependencies": { 21 | "nan": "^2.15.0" 22 | }, 23 | "devDependencies": { 24 | "prettier": "^2.5.1", 25 | "tree-sitter-cli": "^0.20.1" 26 | }, 27 | "tree-sitter": [ 28 | { 29 | "scope": "source.iex", 30 | "file-types": [ 31 | "iex" 32 | ], 33 | "injection-regex": "^iex$" 34 | } 35 | ] 36 | } 37 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | bless: 7 | name: Bless 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - name: Checkout 12 | uses: actions/checkout@v2 13 | 14 | - name: Install Node 15 | uses: actions/setup-node@v2 16 | with: 17 | node-version: "14.x" 18 | 19 | - name: Cache npm dependencies 20 | uses: actions/cache@v2 21 | with: 22 | path: ~/.npm 23 | key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} 24 | restore-keys: | 25 | ${{ runner.os }}-node- 26 | 27 | - name: Install npm dependencies 28 | run: npm ci 29 | 30 | - name: Ensure generated parser files are up to date 31 | run: npx tree-sitter generate 32 | 33 | - name: Run tree-sitter tests 34 | run: npx tree-sitter test 35 | 36 | - name: Check formatting 37 | run: npm run format-check 38 | -------------------------------------------------------------------------------- /bindings/node/binding.cc: -------------------------------------------------------------------------------- 1 | #include "tree_sitter/parser.h" 2 | #include 3 | #include "nan.h" 4 | 5 | using namespace v8; 6 | 7 | extern "C" TSLanguage * tree_sitter_iex(); 8 | 9 | namespace { 10 | 11 | NAN_METHOD(New) {} 12 | 13 | void Init(Local exports, Local module) { 14 | Local tpl = Nan::New(New); 15 | tpl->SetClassName(Nan::New("Language").ToLocalChecked()); 16 | tpl->InstanceTemplate()->SetInternalFieldCount(1); 17 | 18 | Local constructor = Nan::GetFunction(tpl).ToLocalChecked(); 19 | Local instance = constructor->NewInstance(Nan::GetCurrentContext()).ToLocalChecked(); 20 | Nan::SetInternalFieldPointer(instance, 0, tree_sitter_iex()); 21 | 22 | Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("iex").ToLocalChecked()); 23 | Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance); 24 | } 25 | 26 | NODE_MODULE(tree_sitter_iex_binding, Init) 27 | 28 | } // namespace 29 | -------------------------------------------------------------------------------- /grammar.js: -------------------------------------------------------------------------------- 1 | const WHITE_SPACE = /[ \f\t\v]+/; 2 | const NEWLINE = /\r?\n/; 3 | const ANYTHING = /[^\r\n]+/; 4 | 5 | module.exports = grammar({ 6 | name: "iex", 7 | 8 | extras: ($) => [WHITE_SPACE], 9 | 10 | rules: { 11 | source: ($) => repeat(choice($.evaluation_block, NEWLINE)), 12 | 13 | evaluation_block: ($) => 14 | seq( 15 | alias($._default_prompt_line, $.prompt_line), 16 | repeat(alias($._cont_prompt_line, $.prompt_line)), 17 | optional($.result) 18 | ), 19 | 20 | _default_prompt_line: ($) => 21 | seq(alias(/iex(\([^\)]+\)\d*)?>/, $.prompt), optional($.expression)), 22 | 23 | _cont_prompt_line: ($) => 24 | seq(alias(/\.\.\.(\([^\)]+\)\d*)?>/, $.prompt), optional($.expression)), 25 | 26 | expression: ($) => seq(ANYTHING, NEWLINE), 27 | 28 | result: ($) => 29 | prec.right( 30 | seq(sep1(token(prec(-1, ANYTHING)), NEWLINE), optional(NEWLINE)) 31 | ), 32 | }, 33 | }); 34 | 35 | function sep1(rule, separator) { 36 | return seq(rule, repeat(seq(separator, rule))); 37 | } 38 | -------------------------------------------------------------------------------- /.github/workflows/generate-parser.yml: -------------------------------------------------------------------------------- 1 | # generates the parser with 'tree-sitter generate' if the parser is out of date 2 | name: Generate Parser 3 | 4 | on: 5 | push: 6 | branches: 7 | - main 8 | jobs: 9 | generate: 10 | name: Generate Parser 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v2 16 | 17 | - name: Install Node 18 | uses: actions/setup-node@v2 19 | with: 20 | node-version: "14.x" 21 | 22 | - name: Cache npm dependencies 23 | uses: actions/cache@v2 24 | with: 25 | path: ~/.npm 26 | key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} 27 | restore-keys: | 28 | ${{ runner.os }}-node- 29 | 30 | - name: Install npm dependencies 31 | run: npm ci 32 | 33 | - name: Generate parser files 34 | run: | 35 | npx tree-sitter generate 36 | npx tree-sitter build-wasm 37 | 38 | - name: Commit generated parser files 39 | uses: stefanzweifel/git-auto-commit-action@v4 40 | with: 41 | commit_message: Generate parser 42 | file_pattern: src *.wasm 43 | -------------------------------------------------------------------------------- /src/node-types.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "evaluation_block", 4 | "named": true, 5 | "fields": {}, 6 | "children": { 7 | "multiple": true, 8 | "required": true, 9 | "types": [ 10 | { 11 | "type": "prompt_line", 12 | "named": true 13 | }, 14 | { 15 | "type": "result", 16 | "named": true 17 | } 18 | ] 19 | } 20 | }, 21 | { 22 | "type": "expression", 23 | "named": true, 24 | "fields": {} 25 | }, 26 | { 27 | "type": "prompt_line", 28 | "named": true, 29 | "fields": {}, 30 | "children": { 31 | "multiple": true, 32 | "required": true, 33 | "types": [ 34 | { 35 | "type": "expression", 36 | "named": true 37 | }, 38 | { 39 | "type": "prompt", 40 | "named": true 41 | } 42 | ] 43 | } 44 | }, 45 | { 46 | "type": "result", 47 | "named": true, 48 | "fields": {} 49 | }, 50 | { 51 | "type": "source", 52 | "named": true, 53 | "fields": {}, 54 | "children": { 55 | "multiple": true, 56 | "required": false, 57 | "types": [ 58 | { 59 | "type": "evaluation_block", 60 | "named": true 61 | } 62 | ] 63 | } 64 | }, 65 | { 66 | "type": "prompt", 67 | "named": true 68 | } 69 | ] -------------------------------------------------------------------------------- /bindings/rust/build.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let src_dir = std::path::Path::new("src"); 3 | 4 | let mut c_config = cc::Build::new(); 5 | c_config.include(&src_dir); 6 | c_config 7 | .flag_if_supported("-Wno-unused-parameter") 8 | .flag_if_supported("-Wno-unused-but-set-variable") 9 | .flag_if_supported("-Wno-trigraphs"); 10 | let parser_path = src_dir.join("parser.c"); 11 | c_config.file(&parser_path); 12 | 13 | // If your language uses an external scanner written in C, 14 | // then include this block of code: 15 | 16 | /* 17 | let scanner_path = src_dir.join("scanner.c"); 18 | c_config.file(&scanner_path); 19 | println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap()); 20 | */ 21 | 22 | c_config.compile("parser"); 23 | println!("cargo:rerun-if-changed={}", parser_path.to_str().unwrap()); 24 | 25 | // If your language uses an external scanner written in C++, 26 | // then include this block of code: 27 | 28 | /* 29 | let mut cpp_config = cc::Build::new(); 30 | cpp_config.cpp(true); 31 | cpp_config.include(&src_dir); 32 | cpp_config 33 | .flag_if_supported("-Wno-unused-parameter") 34 | .flag_if_supported("-Wno-unused-but-set-variable"); 35 | let scanner_path = src_dir.join("scanner.cc"); 36 | cpp_config.file(&scanner_path); 37 | cpp_config.compile("scanner"); 38 | println!("cargo:rerun-if-changed={}", scanner_path.to_str().unwrap()); 39 | */ 40 | } 41 | -------------------------------------------------------------------------------- /bindings/rust/lib.rs: -------------------------------------------------------------------------------- 1 | //! This crate provides iex language support for the [tree-sitter][] parsing library. 2 | //! 3 | //! Typically, you will use the [language][language func] function to add this language to a 4 | //! tree-sitter [Parser][], and then use the parser to parse some code: 5 | //! 6 | //! ``` 7 | //! let code = ""; 8 | //! let mut parser = tree_sitter::Parser::new(); 9 | //! parser.set_language(tree_sitter_iex::language()).expect("Error loading iex grammar"); 10 | //! let tree = parser.parse(code, None).unwrap(); 11 | //! ``` 12 | //! 13 | //! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html 14 | //! [language func]: fn.language.html 15 | //! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html 16 | //! [tree-sitter]: https://tree-sitter.github.io/ 17 | 18 | use tree_sitter::Language; 19 | 20 | extern "C" { 21 | fn tree_sitter_iex() -> Language; 22 | } 23 | 24 | /// Get the tree-sitter [Language][] for this grammar. 25 | /// 26 | /// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html 27 | pub fn language() -> Language { 28 | unsafe { tree_sitter_iex() } 29 | } 30 | 31 | /// The content of the [`node-types.json`][] file for this grammar. 32 | /// 33 | /// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types 34 | pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json"); 35 | 36 | // Uncomment these to include any queries that this grammar contains 37 | 38 | // pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm"); 39 | // pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm"); 40 | // pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm"); 41 | // pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm"); 42 | 43 | #[cfg(test)] 44 | mod tests { 45 | #[test] 46 | fn test_can_load_grammar() { 47 | let mut parser = tree_sitter::Parser::new(); 48 | parser 49 | .set_language(super::language()) 50 | .expect("Error loading iex language"); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/grammar.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "iex", 3 | "rules": { 4 | "source": { 5 | "type": "REPEAT", 6 | "content": { 7 | "type": "CHOICE", 8 | "members": [ 9 | { 10 | "type": "SYMBOL", 11 | "name": "evaluation_block" 12 | }, 13 | { 14 | "type": "PATTERN", 15 | "value": "\\r?\\n" 16 | } 17 | ] 18 | } 19 | }, 20 | "evaluation_block": { 21 | "type": "SEQ", 22 | "members": [ 23 | { 24 | "type": "ALIAS", 25 | "content": { 26 | "type": "SYMBOL", 27 | "name": "_default_prompt_line" 28 | }, 29 | "named": true, 30 | "value": "prompt_line" 31 | }, 32 | { 33 | "type": "REPEAT", 34 | "content": { 35 | "type": "ALIAS", 36 | "content": { 37 | "type": "SYMBOL", 38 | "name": "_cont_prompt_line" 39 | }, 40 | "named": true, 41 | "value": "prompt_line" 42 | } 43 | }, 44 | { 45 | "type": "CHOICE", 46 | "members": [ 47 | { 48 | "type": "SYMBOL", 49 | "name": "result" 50 | }, 51 | { 52 | "type": "BLANK" 53 | } 54 | ] 55 | } 56 | ] 57 | }, 58 | "_default_prompt_line": { 59 | "type": "SEQ", 60 | "members": [ 61 | { 62 | "type": "ALIAS", 63 | "content": { 64 | "type": "PATTERN", 65 | "value": "iex(\\([^\\)]+\\)\\d*)?>" 66 | }, 67 | "named": true, 68 | "value": "prompt" 69 | }, 70 | { 71 | "type": "CHOICE", 72 | "members": [ 73 | { 74 | "type": "SYMBOL", 75 | "name": "expression" 76 | }, 77 | { 78 | "type": "BLANK" 79 | } 80 | ] 81 | } 82 | ] 83 | }, 84 | "_cont_prompt_line": { 85 | "type": "SEQ", 86 | "members": [ 87 | { 88 | "type": "ALIAS", 89 | "content": { 90 | "type": "PATTERN", 91 | "value": "\\.\\.\\.(\\([^\\)]+\\)\\d*)?>" 92 | }, 93 | "named": true, 94 | "value": "prompt" 95 | }, 96 | { 97 | "type": "CHOICE", 98 | "members": [ 99 | { 100 | "type": "SYMBOL", 101 | "name": "expression" 102 | }, 103 | { 104 | "type": "BLANK" 105 | } 106 | ] 107 | } 108 | ] 109 | }, 110 | "expression": { 111 | "type": "SEQ", 112 | "members": [ 113 | { 114 | "type": "PATTERN", 115 | "value": "[^\\r\\n]+" 116 | }, 117 | { 118 | "type": "PATTERN", 119 | "value": "\\r?\\n" 120 | } 121 | ] 122 | }, 123 | "result": { 124 | "type": "PREC_RIGHT", 125 | "value": 0, 126 | "content": { 127 | "type": "SEQ", 128 | "members": [ 129 | { 130 | "type": "SEQ", 131 | "members": [ 132 | { 133 | "type": "TOKEN", 134 | "content": { 135 | "type": "PREC", 136 | "value": -1, 137 | "content": { 138 | "type": "PATTERN", 139 | "value": "[^\\r\\n]+" 140 | } 141 | } 142 | }, 143 | { 144 | "type": "REPEAT", 145 | "content": { 146 | "type": "SEQ", 147 | "members": [ 148 | { 149 | "type": "PATTERN", 150 | "value": "\\r?\\n" 151 | }, 152 | { 153 | "type": "TOKEN", 154 | "content": { 155 | "type": "PREC", 156 | "value": -1, 157 | "content": { 158 | "type": "PATTERN", 159 | "value": "[^\\r\\n]+" 160 | } 161 | } 162 | } 163 | ] 164 | } 165 | } 166 | ] 167 | }, 168 | { 169 | "type": "CHOICE", 170 | "members": [ 171 | { 172 | "type": "PATTERN", 173 | "value": "\\r?\\n" 174 | }, 175 | { 176 | "type": "BLANK" 177 | } 178 | ] 179 | } 180 | ] 181 | } 182 | } 183 | }, 184 | "extras": [ 185 | { 186 | "type": "PATTERN", 187 | "value": "[ \\f\\t\\v]+" 188 | } 189 | ], 190 | "conflicts": [], 191 | "precedences": [], 192 | "externals": [], 193 | "inline": [], 194 | "supertypes": [] 195 | } 196 | 197 | -------------------------------------------------------------------------------- /src/tree_sitter/parser.h: -------------------------------------------------------------------------------- 1 | #ifndef TREE_SITTER_PARSER_H_ 2 | #define TREE_SITTER_PARSER_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define ts_builtin_sym_error ((TSSymbol)-1) 13 | #define ts_builtin_sym_end 0 14 | #define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024 15 | 16 | typedef uint16_t TSStateId; 17 | 18 | #ifndef TREE_SITTER_API_H_ 19 | typedef uint16_t TSSymbol; 20 | typedef uint16_t TSFieldId; 21 | typedef struct TSLanguage TSLanguage; 22 | #endif 23 | 24 | typedef struct { 25 | TSFieldId field_id; 26 | uint8_t child_index; 27 | bool inherited; 28 | } TSFieldMapEntry; 29 | 30 | typedef struct { 31 | uint16_t index; 32 | uint16_t length; 33 | } TSFieldMapSlice; 34 | 35 | typedef struct { 36 | bool visible; 37 | bool named; 38 | bool supertype; 39 | } TSSymbolMetadata; 40 | 41 | typedef struct TSLexer TSLexer; 42 | 43 | struct TSLexer { 44 | int32_t lookahead; 45 | TSSymbol result_symbol; 46 | void (*advance)(TSLexer *, bool); 47 | void (*mark_end)(TSLexer *); 48 | uint32_t (*get_column)(TSLexer *); 49 | bool (*is_at_included_range_start)(const TSLexer *); 50 | bool (*eof)(const TSLexer *); 51 | }; 52 | 53 | typedef enum { 54 | TSParseActionTypeShift, 55 | TSParseActionTypeReduce, 56 | TSParseActionTypeAccept, 57 | TSParseActionTypeRecover, 58 | } TSParseActionType; 59 | 60 | typedef union { 61 | struct { 62 | uint8_t type; 63 | TSStateId state; 64 | bool extra; 65 | bool repetition; 66 | } shift; 67 | struct { 68 | uint8_t type; 69 | uint8_t child_count; 70 | TSSymbol symbol; 71 | int16_t dynamic_precedence; 72 | uint16_t production_id; 73 | } reduce; 74 | uint8_t type; 75 | } TSParseAction; 76 | 77 | typedef struct { 78 | uint16_t lex_state; 79 | uint16_t external_lex_state; 80 | } TSLexMode; 81 | 82 | typedef union { 83 | TSParseAction action; 84 | struct { 85 | uint8_t count; 86 | bool reusable; 87 | } entry; 88 | } TSParseActionEntry; 89 | 90 | struct TSLanguage { 91 | uint32_t version; 92 | uint32_t symbol_count; 93 | uint32_t alias_count; 94 | uint32_t token_count; 95 | uint32_t external_token_count; 96 | uint32_t state_count; 97 | uint32_t large_state_count; 98 | uint32_t production_id_count; 99 | uint32_t field_count; 100 | uint16_t max_alias_sequence_length; 101 | const uint16_t *parse_table; 102 | const uint16_t *small_parse_table; 103 | const uint32_t *small_parse_table_map; 104 | const TSParseActionEntry *parse_actions; 105 | const char * const *symbol_names; 106 | const char * const *field_names; 107 | const TSFieldMapSlice *field_map_slices; 108 | const TSFieldMapEntry *field_map_entries; 109 | const TSSymbolMetadata *symbol_metadata; 110 | const TSSymbol *public_symbol_map; 111 | const uint16_t *alias_map; 112 | const TSSymbol *alias_sequences; 113 | const TSLexMode *lex_modes; 114 | bool (*lex_fn)(TSLexer *, TSStateId); 115 | bool (*keyword_lex_fn)(TSLexer *, TSStateId); 116 | TSSymbol keyword_capture_token; 117 | struct { 118 | const bool *states; 119 | const TSSymbol *symbol_map; 120 | void *(*create)(void); 121 | void (*destroy)(void *); 122 | bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist); 123 | unsigned (*serialize)(void *, char *); 124 | void (*deserialize)(void *, const char *, unsigned); 125 | } external_scanner; 126 | }; 127 | 128 | /* 129 | * Lexer Macros 130 | */ 131 | 132 | #define START_LEXER() \ 133 | bool result = false; \ 134 | bool skip = false; \ 135 | bool eof = false; \ 136 | int32_t lookahead; \ 137 | goto start; \ 138 | next_state: \ 139 | lexer->advance(lexer, skip); \ 140 | start: \ 141 | skip = false; \ 142 | lookahead = lexer->lookahead; 143 | 144 | #define ADVANCE(state_value) \ 145 | { \ 146 | state = state_value; \ 147 | goto next_state; \ 148 | } 149 | 150 | #define SKIP(state_value) \ 151 | { \ 152 | skip = true; \ 153 | state = state_value; \ 154 | goto next_state; \ 155 | } 156 | 157 | #define ACCEPT_TOKEN(symbol_value) \ 158 | result = true; \ 159 | lexer->result_symbol = symbol_value; \ 160 | lexer->mark_end(lexer); 161 | 162 | #define END_STATE() return result; 163 | 164 | /* 165 | * Parse Table Macros 166 | */ 167 | 168 | #define SMALL_STATE(id) id - LARGE_STATE_COUNT 169 | 170 | #define STATE(id) id 171 | 172 | #define ACTIONS(id) id 173 | 174 | #define SHIFT(state_value) \ 175 | {{ \ 176 | .shift = { \ 177 | .type = TSParseActionTypeShift, \ 178 | .state = state_value \ 179 | } \ 180 | }} 181 | 182 | #define SHIFT_REPEAT(state_value) \ 183 | {{ \ 184 | .shift = { \ 185 | .type = TSParseActionTypeShift, \ 186 | .state = state_value, \ 187 | .repetition = true \ 188 | } \ 189 | }} 190 | 191 | #define SHIFT_EXTRA() \ 192 | {{ \ 193 | .shift = { \ 194 | .type = TSParseActionTypeShift, \ 195 | .extra = true \ 196 | } \ 197 | }} 198 | 199 | #define REDUCE(symbol_val, child_count_val, ...) \ 200 | {{ \ 201 | .reduce = { \ 202 | .type = TSParseActionTypeReduce, \ 203 | .symbol = symbol_val, \ 204 | .child_count = child_count_val, \ 205 | __VA_ARGS__ \ 206 | }, \ 207 | }} 208 | 209 | #define RECOVER() \ 210 | {{ \ 211 | .type = TSParseActionTypeRecover \ 212 | }} 213 | 214 | #define ACCEPT_INPUT() \ 215 | {{ \ 216 | .type = TSParseActionTypeAccept \ 217 | }} 218 | 219 | #ifdef __cplusplus 220 | } 221 | #endif 222 | 223 | #endif // TREE_SITTER_PARSER_H_ 224 | -------------------------------------------------------------------------------- /test/corpus/main.txt: -------------------------------------------------------------------------------- 1 | ================================================================================ 2 | Empty prompt with parens 3 | ================================================================================ 4 | 5 | iex(1)> 6 | 7 | -------------------------------------------------------------------------------- 8 | 9 | (source 10 | (evaluation_block 11 | (prompt_line 12 | (prompt)))) 13 | 14 | ================================================================================ 15 | Multiple empty prompts without parens 16 | ================================================================================ 17 | 18 | iex> 19 | iex> 20 | 21 | -------------------------------------------------------------------------------- 22 | 23 | (source 24 | (evaluation_block 25 | (prompt_line 26 | (prompt))) 27 | (evaluation_block 28 | (prompt_line 29 | (prompt)))) 30 | 31 | ================================================================================ 32 | Prompts with elixir expressions but no result 33 | ================================================================================ 34 | 35 | iex(1)> File.read("f.txt") 36 | iex> send self(), :hello 37 | 38 | -------------------------------------------------------------------------------- 39 | 40 | (source 41 | (evaluation_block 42 | (prompt_line 43 | (prompt) 44 | (expression))) 45 | (evaluation_block 46 | (prompt_line 47 | (prompt) 48 | (expression)))) 49 | 50 | ================================================================================ 51 | Prompts with elixir expressions and results 52 | ================================================================================ 53 | 54 | iex(1)> System.version() 55 | "1.13.1" 56 | iex(1)> System.otp_release() 57 | "24" 58 | 59 | -------------------------------------------------------------------------------- 60 | 61 | (source 62 | (evaluation_block 63 | (prompt_line 64 | (prompt) 65 | (expression)) 66 | (result)) 67 | (evaluation_block 68 | (prompt_line 69 | (prompt) 70 | (expression)) 71 | (result))) 72 | 73 | ================================================================================ 74 | Prompts with elixir expressions and one final results 75 | ================================================================================ 76 | 77 | iex(1)> System.version() 78 | iex(1)> System.otp_release() 79 | "24" 80 | 81 | -------------------------------------------------------------------------------- 82 | 83 | (source 84 | (evaluation_block 85 | (prompt_line 86 | (prompt) 87 | (expression))) 88 | (evaluation_block 89 | (prompt_line 90 | (prompt) 91 | (expression)) 92 | (result))) 93 | 94 | ================================================================================ 95 | A continued prompt 96 | ================================================================================ 97 | 98 | iex> quote do 99 | ...> end 100 | iex(1)> quote do 101 | ...(1)> end 102 | 103 | -------------------------------------------------------------------------------- 104 | 105 | (source 106 | (evaluation_block 107 | (prompt_line 108 | (prompt) 109 | (expression)) 110 | (prompt_line 111 | (prompt) 112 | (expression))) 113 | (evaluation_block 114 | (prompt_line 115 | (prompt) 116 | (expression)) 117 | (prompt_line 118 | (prompt) 119 | (expression)))) 120 | 121 | ================================================================================ 122 | Continued prompts and results 123 | ================================================================================ 124 | 125 | iex> quote do 126 | ...> end 127 | {:__block__, [], []} 128 | iex(1)> quote do 129 | ...(1)> end 130 | {:__block__, [], []} 131 | 132 | -------------------------------------------------------------------------------- 133 | 134 | (source 135 | (evaluation_block 136 | (prompt_line 137 | (prompt) 138 | (expression)) 139 | (prompt_line 140 | (prompt) 141 | (expression)) 142 | (result)) 143 | (evaluation_block 144 | (prompt_line 145 | (prompt) 146 | (expression)) 147 | (prompt_line 148 | (prompt) 149 | (expression)) 150 | (result))) 151 | 152 | ================================================================================ 153 | Multi-line results 154 | ================================================================================ 155 | 156 | iex> quote do 157 | ...> Enum.map(x, &(&1 + 1)) 158 | ...> end 159 | {{:., [], [{:__aliases__, [alias: false], [:Enum]}, :map]}, [], 160 | [ 161 | {:x, [if_undefined: :apply], Elixir}, 162 | {:&, [], [{:+, [context: Elixir, import: Kernel], [{:&, [], [1]}, 1]}]} 163 | ]} 164 | iex(1)> IO.puts("Hello world") 165 | Hello world 166 | :ok 167 | 168 | -------------------------------------------------------------------------------- 169 | 170 | (source 171 | (evaluation_block 172 | (prompt_line 173 | (prompt) 174 | (expression)) 175 | (prompt_line 176 | (prompt) 177 | (expression)) 178 | (prompt_line 179 | (prompt) 180 | (expression)) 181 | (result)) 182 | (evaluation_block 183 | (prompt_line 184 | (prompt) 185 | (expression)) 186 | (result))) 187 | 188 | ================================================================================ 189 | Missing newline on a result 190 | ================================================================================ 191 | 192 | iex> x 193 | 1 194 | -------------------------------------------------------------------------------- 195 | 196 | (source 197 | (evaluation_block 198 | (prompt_line 199 | (prompt) 200 | (expression)) 201 | (result))) 202 | 203 | ================================================================================ 204 | Prompt with node name 205 | ================================================================================ 206 | 207 | iex(foo@127.0.0.1)1> " 208 | ...(foo@127.0.0.1)1> " 209 | "\n" 210 | 211 | -------------------------------------------------------------------------------- 212 | 213 | (source 214 | (evaluation_block 215 | (prompt_line 216 | (prompt) 217 | (expression)) 218 | (prompt_line 219 | (prompt) 220 | (expression)) 221 | (result))) 222 | 223 | ================================================================================ 224 | Prompt-like expression after prompt 225 | ================================================================================ 226 | iex(1)> abs(1)>1 227 | false 228 | iex(1)> #(1)> 229 | 230 | -------------------------------------------------------------------------------- 231 | 232 | (source 233 | (evaluation_block 234 | (prompt_line 235 | (prompt) 236 | (expression)) 237 | (result)) 238 | (evaluation_block 239 | (prompt_line 240 | (prompt) 241 | (expression)))) 242 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/parser.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #if defined(__GNUC__) || defined(__clang__) 4 | #pragma GCC diagnostic push 5 | #pragma GCC diagnostic ignored "-Wmissing-field-initializers" 6 | #endif 7 | 8 | #define LANGUAGE_VERSION 13 9 | #define STATE_COUNT 23 10 | #define LARGE_STATE_COUNT 4 11 | #define SYMBOL_COUNT 15 12 | #define ALIAS_COUNT 0 13 | #define TOKEN_COUNT 6 14 | #define EXTERNAL_TOKEN_COUNT 0 15 | #define FIELD_COUNT 0 16 | #define MAX_ALIAS_SEQUENCE_LENGTH 3 17 | #define PRODUCTION_ID_COUNT 1 18 | 19 | enum { 20 | aux_sym_source_token1 = 1, 21 | aux_sym__default_prompt_line_token1 = 2, 22 | aux_sym__cont_prompt_line_token1 = 3, 23 | aux_sym_expression_token1 = 4, 24 | aux_sym_result_token1 = 5, 25 | sym_source = 6, 26 | sym_evaluation_block = 7, 27 | sym__default_prompt_line = 8, 28 | sym__cont_prompt_line = 9, 29 | sym_expression = 10, 30 | sym_result = 11, 31 | aux_sym_source_repeat1 = 12, 32 | aux_sym_evaluation_block_repeat1 = 13, 33 | aux_sym_result_repeat1 = 14, 34 | }; 35 | 36 | static const char * const ts_symbol_names[] = { 37 | [ts_builtin_sym_end] = "end", 38 | [aux_sym_source_token1] = "source_token1", 39 | [aux_sym__default_prompt_line_token1] = "prompt", 40 | [aux_sym__cont_prompt_line_token1] = "prompt", 41 | [aux_sym_expression_token1] = "expression_token1", 42 | [aux_sym_result_token1] = "result_token1", 43 | [sym_source] = "source", 44 | [sym_evaluation_block] = "evaluation_block", 45 | [sym__default_prompt_line] = "prompt_line", 46 | [sym__cont_prompt_line] = "prompt_line", 47 | [sym_expression] = "expression", 48 | [sym_result] = "result", 49 | [aux_sym_source_repeat1] = "source_repeat1", 50 | [aux_sym_evaluation_block_repeat1] = "evaluation_block_repeat1", 51 | [aux_sym_result_repeat1] = "result_repeat1", 52 | }; 53 | 54 | static const TSSymbol ts_symbol_map[] = { 55 | [ts_builtin_sym_end] = ts_builtin_sym_end, 56 | [aux_sym_source_token1] = aux_sym_source_token1, 57 | [aux_sym__default_prompt_line_token1] = aux_sym__default_prompt_line_token1, 58 | [aux_sym__cont_prompt_line_token1] = aux_sym__default_prompt_line_token1, 59 | [aux_sym_expression_token1] = aux_sym_expression_token1, 60 | [aux_sym_result_token1] = aux_sym_result_token1, 61 | [sym_source] = sym_source, 62 | [sym_evaluation_block] = sym_evaluation_block, 63 | [sym__default_prompt_line] = sym__default_prompt_line, 64 | [sym__cont_prompt_line] = sym__default_prompt_line, 65 | [sym_expression] = sym_expression, 66 | [sym_result] = sym_result, 67 | [aux_sym_source_repeat1] = aux_sym_source_repeat1, 68 | [aux_sym_evaluation_block_repeat1] = aux_sym_evaluation_block_repeat1, 69 | [aux_sym_result_repeat1] = aux_sym_result_repeat1, 70 | }; 71 | 72 | static const TSSymbolMetadata ts_symbol_metadata[] = { 73 | [ts_builtin_sym_end] = { 74 | .visible = false, 75 | .named = true, 76 | }, 77 | [aux_sym_source_token1] = { 78 | .visible = false, 79 | .named = false, 80 | }, 81 | [aux_sym__default_prompt_line_token1] = { 82 | .visible = true, 83 | .named = true, 84 | }, 85 | [aux_sym__cont_prompt_line_token1] = { 86 | .visible = true, 87 | .named = true, 88 | }, 89 | [aux_sym_expression_token1] = { 90 | .visible = false, 91 | .named = false, 92 | }, 93 | [aux_sym_result_token1] = { 94 | .visible = false, 95 | .named = false, 96 | }, 97 | [sym_source] = { 98 | .visible = true, 99 | .named = true, 100 | }, 101 | [sym_evaluation_block] = { 102 | .visible = true, 103 | .named = true, 104 | }, 105 | [sym__default_prompt_line] = { 106 | .visible = true, 107 | .named = true, 108 | }, 109 | [sym__cont_prompt_line] = { 110 | .visible = true, 111 | .named = true, 112 | }, 113 | [sym_expression] = { 114 | .visible = true, 115 | .named = true, 116 | }, 117 | [sym_result] = { 118 | .visible = true, 119 | .named = true, 120 | }, 121 | [aux_sym_source_repeat1] = { 122 | .visible = false, 123 | .named = false, 124 | }, 125 | [aux_sym_evaluation_block_repeat1] = { 126 | .visible = false, 127 | .named = false, 128 | }, 129 | [aux_sym_result_repeat1] = { 130 | .visible = false, 131 | .named = false, 132 | }, 133 | }; 134 | 135 | static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = { 136 | [0] = {0}, 137 | }; 138 | 139 | static const uint16_t ts_non_terminal_alias_map[] = { 140 | 0, 141 | }; 142 | 143 | static bool ts_lex(TSLexer *lexer, TSStateId state) { 144 | START_LEXER(); 145 | eof = lexer->eof(lexer); 146 | switch (state) { 147 | case 0: 148 | if (eof) ADVANCE(14); 149 | if (lookahead == '\n') ADVANCE(15); 150 | if (lookahead == '\r') ADVANCE(1); 151 | if (lookahead == '.') ADVANCE(28); 152 | if (lookahead == 'i') ADVANCE(31); 153 | if (('\t' <= lookahead && lookahead <= '\f') || 154 | lookahead == ' ') ADVANCE(26); 155 | if (lookahead != 0) ADVANCE(33); 156 | END_STATE(); 157 | case 1: 158 | if (lookahead == '\n') ADVANCE(15); 159 | END_STATE(); 160 | case 2: 161 | if (lookahead == '(') ADVANCE(10); 162 | if (lookahead == '>') ADVANCE(16); 163 | END_STATE(); 164 | case 3: 165 | if (lookahead == ')') ADVANCE(5); 166 | if (lookahead != 0) ADVANCE(3); 167 | END_STATE(); 168 | case 4: 169 | if (lookahead == ')') ADVANCE(6); 170 | if (lookahead != 0) ADVANCE(4); 171 | END_STATE(); 172 | case 5: 173 | if (lookahead == '>') ADVANCE(18); 174 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(5); 175 | END_STATE(); 176 | case 6: 177 | if (lookahead == '>') ADVANCE(16); 178 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(6); 179 | END_STATE(); 180 | case 7: 181 | if (lookahead == 'e') ADVANCE(8); 182 | END_STATE(); 183 | case 8: 184 | if (lookahead == 'x') ADVANCE(2); 185 | END_STATE(); 186 | case 9: 187 | if (lookahead == '\t' || 188 | lookahead == 11 || 189 | lookahead == '\f' || 190 | lookahead == ' ') ADVANCE(48); 191 | if (lookahead != 0 && 192 | (lookahead < '\n' || '\r' < lookahead)) ADVANCE(49); 193 | END_STATE(); 194 | case 10: 195 | if (lookahead != 0 && 196 | lookahead != ')') ADVANCE(4); 197 | END_STATE(); 198 | case 11: 199 | if (eof) ADVANCE(14); 200 | if (lookahead == '\n') ADVANCE(15); 201 | if (lookahead == '\r') ADVANCE(1); 202 | if (lookahead == '.') ADVANCE(43); 203 | if (lookahead == 'i') ADVANCE(46); 204 | if (('\t' <= lookahead && lookahead <= '\f') || 205 | lookahead == ' ') ADVANCE(34); 206 | if (lookahead != 0) ADVANCE(49); 207 | END_STATE(); 208 | case 12: 209 | if (eof) ADVANCE(14); 210 | if (lookahead == '\n') ADVANCE(15); 211 | if (lookahead == '\r') ADVANCE(1); 212 | if (lookahead == 'i') ADVANCE(7); 213 | if (('\t' <= lookahead && lookahead <= '\f') || 214 | lookahead == ' ') SKIP(12) 215 | END_STATE(); 216 | case 13: 217 | if (eof) ADVANCE(14); 218 | if (lookahead == '\n') ADVANCE(15); 219 | if (lookahead == '\r') ADVANCE(1); 220 | if (lookahead == 'i') ADVANCE(46); 221 | if (('\t' <= lookahead && lookahead <= '\f') || 222 | lookahead == ' ') ADVANCE(35); 223 | if (lookahead != 0) ADVANCE(49); 224 | END_STATE(); 225 | case 14: 226 | ACCEPT_TOKEN(ts_builtin_sym_end); 227 | END_STATE(); 228 | case 15: 229 | ACCEPT_TOKEN(aux_sym_source_token1); 230 | END_STATE(); 231 | case 16: 232 | ACCEPT_TOKEN(aux_sym__default_prompt_line_token1); 233 | END_STATE(); 234 | case 17: 235 | ACCEPT_TOKEN(aux_sym__default_prompt_line_token1); 236 | if (lookahead != 0 && 237 | lookahead != '\n' && 238 | lookahead != '\r') ADVANCE(33); 239 | END_STATE(); 240 | case 18: 241 | ACCEPT_TOKEN(aux_sym__cont_prompt_line_token1); 242 | END_STATE(); 243 | case 19: 244 | ACCEPT_TOKEN(aux_sym__cont_prompt_line_token1); 245 | if (lookahead != 0 && 246 | lookahead != '\n' && 247 | lookahead != '\r') ADVANCE(33); 248 | END_STATE(); 249 | case 20: 250 | ACCEPT_TOKEN(aux_sym_expression_token1); 251 | if (lookahead == '(') ADVANCE(22); 252 | if (lookahead == '>') ADVANCE(19); 253 | if (lookahead != 0 && 254 | lookahead != '\n' && 255 | lookahead != '\r') ADVANCE(33); 256 | END_STATE(); 257 | case 21: 258 | ACCEPT_TOKEN(aux_sym_expression_token1); 259 | if (lookahead == '(') ADVANCE(23); 260 | if (lookahead == '>') ADVANCE(17); 261 | if (lookahead != 0 && 262 | lookahead != '\n' && 263 | lookahead != '\r') ADVANCE(33); 264 | END_STATE(); 265 | case 22: 266 | ACCEPT_TOKEN(aux_sym_expression_token1); 267 | if (lookahead == ')') ADVANCE(33); 268 | if (lookahead == '\n' || 269 | lookahead == '\r') ADVANCE(3); 270 | if (lookahead != 0) ADVANCE(24); 271 | END_STATE(); 272 | case 23: 273 | ACCEPT_TOKEN(aux_sym_expression_token1); 274 | if (lookahead == ')') ADVANCE(33); 275 | if (lookahead == '\n' || 276 | lookahead == '\r') ADVANCE(4); 277 | if (lookahead != 0) ADVANCE(25); 278 | END_STATE(); 279 | case 24: 280 | ACCEPT_TOKEN(aux_sym_expression_token1); 281 | if (lookahead == ')') ADVANCE(29); 282 | if (lookahead == '\n' || 283 | lookahead == '\r') ADVANCE(3); 284 | if (lookahead != 0) ADVANCE(24); 285 | END_STATE(); 286 | case 25: 287 | ACCEPT_TOKEN(aux_sym_expression_token1); 288 | if (lookahead == ')') ADVANCE(30); 289 | if (lookahead == '\n' || 290 | lookahead == '\r') ADVANCE(4); 291 | if (lookahead != 0) ADVANCE(25); 292 | END_STATE(); 293 | case 26: 294 | ACCEPT_TOKEN(aux_sym_expression_token1); 295 | if (lookahead == '.') ADVANCE(28); 296 | if (lookahead == 'i') ADVANCE(31); 297 | if (lookahead == '\t' || 298 | lookahead == 11 || 299 | lookahead == '\f' || 300 | lookahead == ' ') ADVANCE(26); 301 | if (lookahead != 0 && 302 | (lookahead < '\n' || '\r' < lookahead)) ADVANCE(33); 303 | END_STATE(); 304 | case 27: 305 | ACCEPT_TOKEN(aux_sym_expression_token1); 306 | if (lookahead == '.') ADVANCE(20); 307 | if (lookahead != 0 && 308 | lookahead != '\n' && 309 | lookahead != '\r') ADVANCE(33); 310 | END_STATE(); 311 | case 28: 312 | ACCEPT_TOKEN(aux_sym_expression_token1); 313 | if (lookahead == '.') ADVANCE(27); 314 | if (lookahead != 0 && 315 | lookahead != '\n' && 316 | lookahead != '\r') ADVANCE(33); 317 | END_STATE(); 318 | case 29: 319 | ACCEPT_TOKEN(aux_sym_expression_token1); 320 | if (lookahead == '>') ADVANCE(19); 321 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(29); 322 | if (lookahead != 0 && 323 | lookahead != '\n' && 324 | lookahead != '\r') ADVANCE(33); 325 | END_STATE(); 326 | case 30: 327 | ACCEPT_TOKEN(aux_sym_expression_token1); 328 | if (lookahead == '>') ADVANCE(17); 329 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(30); 330 | if (lookahead != 0 && 331 | lookahead != '\n' && 332 | lookahead != '\r') ADVANCE(33); 333 | END_STATE(); 334 | case 31: 335 | ACCEPT_TOKEN(aux_sym_expression_token1); 336 | if (lookahead == 'e') ADVANCE(32); 337 | if (lookahead != 0 && 338 | lookahead != '\n' && 339 | lookahead != '\r') ADVANCE(33); 340 | END_STATE(); 341 | case 32: 342 | ACCEPT_TOKEN(aux_sym_expression_token1); 343 | if (lookahead == 'x') ADVANCE(21); 344 | if (lookahead != 0 && 345 | lookahead != '\n' && 346 | lookahead != '\r') ADVANCE(33); 347 | END_STATE(); 348 | case 33: 349 | ACCEPT_TOKEN(aux_sym_expression_token1); 350 | if (lookahead != 0 && 351 | lookahead != '\n' && 352 | lookahead != '\r') ADVANCE(33); 353 | END_STATE(); 354 | case 34: 355 | ACCEPT_TOKEN(aux_sym_result_token1); 356 | if (lookahead == '\n') ADVANCE(15); 357 | if (lookahead == '\r') ADVANCE(1); 358 | if (lookahead == '.') ADVANCE(43); 359 | if (lookahead == 'i') ADVANCE(46); 360 | if (('\t' <= lookahead && lookahead <= '\f') || 361 | lookahead == ' ') ADVANCE(34); 362 | if (lookahead != 0) ADVANCE(49); 363 | END_STATE(); 364 | case 35: 365 | ACCEPT_TOKEN(aux_sym_result_token1); 366 | if (lookahead == '\n') ADVANCE(15); 367 | if (lookahead == '\r') ADVANCE(1); 368 | if (lookahead == 'i') ADVANCE(46); 369 | if (('\t' <= lookahead && lookahead <= '\f') || 370 | lookahead == ' ') ADVANCE(35); 371 | if (lookahead != 0) ADVANCE(49); 372 | END_STATE(); 373 | case 36: 374 | ACCEPT_TOKEN(aux_sym_result_token1); 375 | if (lookahead == '(') ADVANCE(38); 376 | if (lookahead == '>') ADVANCE(18); 377 | if (lookahead != 0 && 378 | lookahead != '\n' && 379 | lookahead != '\r') ADVANCE(49); 380 | END_STATE(); 381 | case 37: 382 | ACCEPT_TOKEN(aux_sym_result_token1); 383 | if (lookahead == '(') ADVANCE(39); 384 | if (lookahead == '>') ADVANCE(16); 385 | if (lookahead != 0 && 386 | lookahead != '\n' && 387 | lookahead != '\r') ADVANCE(49); 388 | END_STATE(); 389 | case 38: 390 | ACCEPT_TOKEN(aux_sym_result_token1); 391 | if (lookahead == ')') ADVANCE(49); 392 | if (lookahead == '\n' || 393 | lookahead == '\r') ADVANCE(3); 394 | if (lookahead != 0) ADVANCE(40); 395 | END_STATE(); 396 | case 39: 397 | ACCEPT_TOKEN(aux_sym_result_token1); 398 | if (lookahead == ')') ADVANCE(49); 399 | if (lookahead == '\n' || 400 | lookahead == '\r') ADVANCE(4); 401 | if (lookahead != 0) ADVANCE(41); 402 | END_STATE(); 403 | case 40: 404 | ACCEPT_TOKEN(aux_sym_result_token1); 405 | if (lookahead == ')') ADVANCE(44); 406 | if (lookahead == '\n' || 407 | lookahead == '\r') ADVANCE(3); 408 | if (lookahead != 0) ADVANCE(40); 409 | END_STATE(); 410 | case 41: 411 | ACCEPT_TOKEN(aux_sym_result_token1); 412 | if (lookahead == ')') ADVANCE(45); 413 | if (lookahead == '\n' || 414 | lookahead == '\r') ADVANCE(4); 415 | if (lookahead != 0) ADVANCE(41); 416 | END_STATE(); 417 | case 42: 418 | ACCEPT_TOKEN(aux_sym_result_token1); 419 | if (lookahead == '.') ADVANCE(36); 420 | if (lookahead != 0 && 421 | lookahead != '\n' && 422 | lookahead != '\r') ADVANCE(49); 423 | END_STATE(); 424 | case 43: 425 | ACCEPT_TOKEN(aux_sym_result_token1); 426 | if (lookahead == '.') ADVANCE(42); 427 | if (lookahead != 0 && 428 | lookahead != '\n' && 429 | lookahead != '\r') ADVANCE(49); 430 | END_STATE(); 431 | case 44: 432 | ACCEPT_TOKEN(aux_sym_result_token1); 433 | if (lookahead == '>') ADVANCE(18); 434 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(44); 435 | if (lookahead != 0 && 436 | lookahead != '\n' && 437 | lookahead != '\r') ADVANCE(49); 438 | END_STATE(); 439 | case 45: 440 | ACCEPT_TOKEN(aux_sym_result_token1); 441 | if (lookahead == '>') ADVANCE(16); 442 | if (('0' <= lookahead && lookahead <= '9')) ADVANCE(45); 443 | if (lookahead != 0 && 444 | lookahead != '\n' && 445 | lookahead != '\r') ADVANCE(49); 446 | END_STATE(); 447 | case 46: 448 | ACCEPT_TOKEN(aux_sym_result_token1); 449 | if (lookahead == 'e') ADVANCE(47); 450 | if (lookahead != 0 && 451 | lookahead != '\n' && 452 | lookahead != '\r') ADVANCE(49); 453 | END_STATE(); 454 | case 47: 455 | ACCEPT_TOKEN(aux_sym_result_token1); 456 | if (lookahead == 'x') ADVANCE(37); 457 | if (lookahead != 0 && 458 | lookahead != '\n' && 459 | lookahead != '\r') ADVANCE(49); 460 | END_STATE(); 461 | case 48: 462 | ACCEPT_TOKEN(aux_sym_result_token1); 463 | if (lookahead == '\t' || 464 | lookahead == 11 || 465 | lookahead == '\f' || 466 | lookahead == ' ') ADVANCE(48); 467 | if (lookahead != 0 && 468 | (lookahead < '\n' || '\r' < lookahead)) ADVANCE(49); 469 | END_STATE(); 470 | case 49: 471 | ACCEPT_TOKEN(aux_sym_result_token1); 472 | if (lookahead != 0 && 473 | lookahead != '\n' && 474 | lookahead != '\r') ADVANCE(49); 475 | END_STATE(); 476 | default: 477 | return false; 478 | } 479 | } 480 | 481 | static const TSLexMode ts_lex_modes[STATE_COUNT] = { 482 | [0] = {.lex_state = 0}, 483 | [1] = {.lex_state = 12}, 484 | [2] = {.lex_state = 11}, 485 | [3] = {.lex_state = 11}, 486 | [4] = {.lex_state = 0}, 487 | [5] = {.lex_state = 11}, 488 | [6] = {.lex_state = 0}, 489 | [7] = {.lex_state = 12}, 490 | [8] = {.lex_state = 12}, 491 | [9] = {.lex_state = 11}, 492 | [10] = {.lex_state = 11}, 493 | [11] = {.lex_state = 11}, 494 | [12] = {.lex_state = 13}, 495 | [13] = {.lex_state = 12}, 496 | [14] = {.lex_state = 12}, 497 | [15] = {.lex_state = 13}, 498 | [16] = {.lex_state = 12}, 499 | [17] = {.lex_state = 12}, 500 | [18] = {.lex_state = 12}, 501 | [19] = {.lex_state = 12}, 502 | [20] = {.lex_state = 0}, 503 | [21] = {.lex_state = 12}, 504 | [22] = {.lex_state = 9}, 505 | }; 506 | 507 | static const uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { 508 | [0] = { 509 | [ts_builtin_sym_end] = ACTIONS(1), 510 | [aux_sym_source_token1] = ACTIONS(1), 511 | [aux_sym__default_prompt_line_token1] = ACTIONS(1), 512 | [aux_sym__cont_prompt_line_token1] = ACTIONS(1), 513 | [aux_sym_expression_token1] = ACTIONS(1), 514 | [aux_sym_result_token1] = ACTIONS(1), 515 | }, 516 | [1] = { 517 | [sym_source] = STATE(20), 518 | [sym_evaluation_block] = STATE(8), 519 | [sym__default_prompt_line] = STATE(2), 520 | [aux_sym_source_repeat1] = STATE(8), 521 | [ts_builtin_sym_end] = ACTIONS(3), 522 | [aux_sym_source_token1] = ACTIONS(5), 523 | [aux_sym__default_prompt_line_token1] = ACTIONS(7), 524 | }, 525 | [2] = { 526 | [sym__cont_prompt_line] = STATE(3), 527 | [sym_result] = STATE(17), 528 | [aux_sym_evaluation_block_repeat1] = STATE(3), 529 | [ts_builtin_sym_end] = ACTIONS(9), 530 | [aux_sym_source_token1] = ACTIONS(11), 531 | [aux_sym__default_prompt_line_token1] = ACTIONS(11), 532 | [aux_sym__cont_prompt_line_token1] = ACTIONS(13), 533 | [aux_sym_result_token1] = ACTIONS(15), 534 | }, 535 | [3] = { 536 | [sym__cont_prompt_line] = STATE(5), 537 | [sym_result] = STATE(18), 538 | [aux_sym_evaluation_block_repeat1] = STATE(5), 539 | [ts_builtin_sym_end] = ACTIONS(17), 540 | [aux_sym_source_token1] = ACTIONS(19), 541 | [aux_sym__default_prompt_line_token1] = ACTIONS(19), 542 | [aux_sym__cont_prompt_line_token1] = ACTIONS(13), 543 | [aux_sym_result_token1] = ACTIONS(15), 544 | }, 545 | }; 546 | 547 | static const uint16_t ts_small_parse_table[] = { 548 | [0] = 4, 549 | ACTIONS(21), 1, 550 | ts_builtin_sym_end, 551 | ACTIONS(25), 1, 552 | aux_sym_expression_token1, 553 | STATE(9), 1, 554 | sym_expression, 555 | ACTIONS(23), 4, 556 | aux_sym_source_token1, 557 | aux_sym__default_prompt_line_token1, 558 | aux_sym__cont_prompt_line_token1, 559 | aux_sym_result_token1, 560 | [16] = 4, 561 | ACTIONS(27), 1, 562 | ts_builtin_sym_end, 563 | ACTIONS(31), 1, 564 | aux_sym__cont_prompt_line_token1, 565 | STATE(5), 2, 566 | sym__cont_prompt_line, 567 | aux_sym_evaluation_block_repeat1, 568 | ACTIONS(29), 3, 569 | aux_sym_source_token1, 570 | aux_sym__default_prompt_line_token1, 571 | aux_sym_result_token1, 572 | [32] = 4, 573 | ACTIONS(25), 1, 574 | aux_sym_expression_token1, 575 | ACTIONS(34), 1, 576 | ts_builtin_sym_end, 577 | STATE(10), 1, 578 | sym_expression, 579 | ACTIONS(36), 4, 580 | aux_sym_source_token1, 581 | aux_sym__default_prompt_line_token1, 582 | aux_sym__cont_prompt_line_token1, 583 | aux_sym_result_token1, 584 | [48] = 5, 585 | ACTIONS(38), 1, 586 | ts_builtin_sym_end, 587 | ACTIONS(40), 1, 588 | aux_sym_source_token1, 589 | ACTIONS(43), 1, 590 | aux_sym__default_prompt_line_token1, 591 | STATE(2), 1, 592 | sym__default_prompt_line, 593 | STATE(7), 2, 594 | sym_evaluation_block, 595 | aux_sym_source_repeat1, 596 | [65] = 5, 597 | ACTIONS(7), 1, 598 | aux_sym__default_prompt_line_token1, 599 | ACTIONS(46), 1, 600 | ts_builtin_sym_end, 601 | ACTIONS(48), 1, 602 | aux_sym_source_token1, 603 | STATE(2), 1, 604 | sym__default_prompt_line, 605 | STATE(7), 2, 606 | sym_evaluation_block, 607 | aux_sym_source_repeat1, 608 | [82] = 2, 609 | ACTIONS(50), 1, 610 | ts_builtin_sym_end, 611 | ACTIONS(52), 4, 612 | aux_sym_source_token1, 613 | aux_sym__default_prompt_line_token1, 614 | aux_sym__cont_prompt_line_token1, 615 | aux_sym_result_token1, 616 | [92] = 2, 617 | ACTIONS(54), 1, 618 | ts_builtin_sym_end, 619 | ACTIONS(56), 4, 620 | aux_sym_source_token1, 621 | aux_sym__default_prompt_line_token1, 622 | aux_sym__cont_prompt_line_token1, 623 | aux_sym_result_token1, 624 | [102] = 2, 625 | ACTIONS(58), 1, 626 | ts_builtin_sym_end, 627 | ACTIONS(60), 4, 628 | aux_sym_source_token1, 629 | aux_sym__default_prompt_line_token1, 630 | aux_sym__cont_prompt_line_token1, 631 | aux_sym_result_token1, 632 | [112] = 3, 633 | ACTIONS(62), 1, 634 | ts_builtin_sym_end, 635 | ACTIONS(66), 1, 636 | aux_sym_result_token1, 637 | ACTIONS(64), 2, 638 | aux_sym_source_token1, 639 | aux_sym__default_prompt_line_token1, 640 | [123] = 3, 641 | ACTIONS(70), 1, 642 | aux_sym_source_token1, 643 | STATE(14), 1, 644 | aux_sym_result_repeat1, 645 | ACTIONS(68), 2, 646 | ts_builtin_sym_end, 647 | aux_sym__default_prompt_line_token1, 648 | [134] = 3, 649 | ACTIONS(72), 1, 650 | aux_sym_source_token1, 651 | STATE(16), 1, 652 | aux_sym_result_repeat1, 653 | ACTIONS(62), 2, 654 | ts_builtin_sym_end, 655 | aux_sym__default_prompt_line_token1, 656 | [145] = 3, 657 | ACTIONS(66), 1, 658 | aux_sym_result_token1, 659 | ACTIONS(74), 1, 660 | ts_builtin_sym_end, 661 | ACTIONS(76), 2, 662 | aux_sym_source_token1, 663 | aux_sym__default_prompt_line_token1, 664 | [156] = 3, 665 | ACTIONS(80), 1, 666 | aux_sym_source_token1, 667 | STATE(16), 1, 668 | aux_sym_result_repeat1, 669 | ACTIONS(78), 2, 670 | ts_builtin_sym_end, 671 | aux_sym__default_prompt_line_token1, 672 | [167] = 1, 673 | ACTIONS(17), 3, 674 | ts_builtin_sym_end, 675 | aux_sym_source_token1, 676 | aux_sym__default_prompt_line_token1, 677 | [173] = 1, 678 | ACTIONS(83), 3, 679 | ts_builtin_sym_end, 680 | aux_sym_source_token1, 681 | aux_sym__default_prompt_line_token1, 682 | [179] = 1, 683 | ACTIONS(78), 3, 684 | ts_builtin_sym_end, 685 | aux_sym_source_token1, 686 | aux_sym__default_prompt_line_token1, 687 | [185] = 1, 688 | ACTIONS(85), 1, 689 | ts_builtin_sym_end, 690 | [189] = 1, 691 | ACTIONS(87), 1, 692 | aux_sym_source_token1, 693 | [193] = 1, 694 | ACTIONS(89), 1, 695 | aux_sym_result_token1, 696 | }; 697 | 698 | static const uint32_t ts_small_parse_table_map[] = { 699 | [SMALL_STATE(4)] = 0, 700 | [SMALL_STATE(5)] = 16, 701 | [SMALL_STATE(6)] = 32, 702 | [SMALL_STATE(7)] = 48, 703 | [SMALL_STATE(8)] = 65, 704 | [SMALL_STATE(9)] = 82, 705 | [SMALL_STATE(10)] = 92, 706 | [SMALL_STATE(11)] = 102, 707 | [SMALL_STATE(12)] = 112, 708 | [SMALL_STATE(13)] = 123, 709 | [SMALL_STATE(14)] = 134, 710 | [SMALL_STATE(15)] = 145, 711 | [SMALL_STATE(16)] = 156, 712 | [SMALL_STATE(17)] = 167, 713 | [SMALL_STATE(18)] = 173, 714 | [SMALL_STATE(19)] = 179, 715 | [SMALL_STATE(20)] = 185, 716 | [SMALL_STATE(21)] = 189, 717 | [SMALL_STATE(22)] = 193, 718 | }; 719 | 720 | static const TSParseActionEntry ts_parse_actions[] = { 721 | [0] = {.entry = {.count = 0, .reusable = false}}, 722 | [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(), 723 | [3] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source, 0), 724 | [5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(8), 725 | [7] = {.entry = {.count = 1, .reusable = true}}, SHIFT(4), 726 | [9] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_evaluation_block, 1), 727 | [11] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_evaluation_block, 1), 728 | [13] = {.entry = {.count = 1, .reusable = false}}, SHIFT(6), 729 | [15] = {.entry = {.count = 1, .reusable = false}}, SHIFT(13), 730 | [17] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_evaluation_block, 2), 731 | [19] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_evaluation_block, 2), 732 | [21] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__default_prompt_line, 1), 733 | [23] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__default_prompt_line, 1), 734 | [25] = {.entry = {.count = 1, .reusable = false}}, SHIFT(21), 735 | [27] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_evaluation_block_repeat1, 2), 736 | [29] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_evaluation_block_repeat1, 2), 737 | [31] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_evaluation_block_repeat1, 2), SHIFT_REPEAT(6), 738 | [34] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__cont_prompt_line, 1), 739 | [36] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__cont_prompt_line, 1), 740 | [38] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_source_repeat1, 2), 741 | [40] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_repeat1, 2), SHIFT_REPEAT(7), 742 | [43] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_source_repeat1, 2), SHIFT_REPEAT(4), 743 | [46] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_source, 1), 744 | [48] = {.entry = {.count = 1, .reusable = true}}, SHIFT(7), 745 | [50] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__default_prompt_line, 2), 746 | [52] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__default_prompt_line, 2), 747 | [54] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym__cont_prompt_line, 2), 748 | [56] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym__cont_prompt_line, 2), 749 | [58] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_expression, 2), 750 | [60] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_expression, 2), 751 | [62] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_result, 2), 752 | [64] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_result, 2), 753 | [66] = {.entry = {.count = 1, .reusable = false}}, SHIFT(19), 754 | [68] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_result, 1), 755 | [70] = {.entry = {.count = 1, .reusable = true}}, SHIFT(12), 756 | [72] = {.entry = {.count = 1, .reusable = true}}, SHIFT(15), 757 | [74] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_result, 3), 758 | [76] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_result, 3), 759 | [78] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_result_repeat1, 2), 760 | [80] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_result_repeat1, 2), SHIFT_REPEAT(22), 761 | [83] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_evaluation_block, 3), 762 | [85] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), 763 | [87] = {.entry = {.count = 1, .reusable = true}}, SHIFT(11), 764 | [89] = {.entry = {.count = 1, .reusable = true}}, SHIFT(19), 765 | }; 766 | 767 | #ifdef __cplusplus 768 | extern "C" { 769 | #endif 770 | #ifdef _WIN32 771 | #define extern __declspec(dllexport) 772 | #endif 773 | 774 | extern const TSLanguage *tree_sitter_iex(void) { 775 | static const TSLanguage language = { 776 | .version = LANGUAGE_VERSION, 777 | .symbol_count = SYMBOL_COUNT, 778 | .alias_count = ALIAS_COUNT, 779 | .token_count = TOKEN_COUNT, 780 | .external_token_count = EXTERNAL_TOKEN_COUNT, 781 | .state_count = STATE_COUNT, 782 | .large_state_count = LARGE_STATE_COUNT, 783 | .production_id_count = PRODUCTION_ID_COUNT, 784 | .field_count = FIELD_COUNT, 785 | .max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH, 786 | .parse_table = &ts_parse_table[0][0], 787 | .small_parse_table = ts_small_parse_table, 788 | .small_parse_table_map = ts_small_parse_table_map, 789 | .parse_actions = ts_parse_actions, 790 | .symbol_names = ts_symbol_names, 791 | .symbol_metadata = ts_symbol_metadata, 792 | .public_symbol_map = ts_symbol_map, 793 | .alias_map = ts_non_terminal_alias_map, 794 | .alias_sequences = &ts_alias_sequences[0][0], 795 | .lex_modes = ts_lex_modes, 796 | .lex_fn = ts_lex, 797 | }; 798 | return &language; 799 | } 800 | #ifdef __cplusplus 801 | } 802 | #endif 803 | --------------------------------------------------------------------------------