├── .ccls ├── .clang-format ├── .github └── workflows │ └── test.yml ├── .gitignore ├── COPYING ├── README.md ├── binding.gyp ├── grammar.js ├── index.js ├── manifest.scm ├── package-lock.json ├── package.json ├── shell.nix ├── src ├── binding.cc ├── grammar.json ├── node-types.json ├── parser.c ├── scanner.cc └── tree_sitter │ └── parser.h └── test ├── .gitignore └── corpus └── headline.txt /.ccls: -------------------------------------------------------------------------------- 1 | clang 2 | %c -std=c99 3 | %cpp -std=c++17 4 | -Isrc 5 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | # BasedOnStyle: Google 4 | AccessModifierOffset: -1 5 | AlignAfterOpenBracket: Align 6 | AlignConsecutiveMacros: false 7 | AlignConsecutiveAssignments: false 8 | AlignConsecutiveDeclarations: false 9 | AlignEscapedNewlines: Left 10 | AlignOperands: true 11 | AlignTrailingComments: true 12 | AllowAllArgumentsOnNextLine: true 13 | AllowAllConstructorInitializersOnNextLine: true 14 | AllowAllParametersOfDeclarationOnNextLine: true 15 | AllowShortBlocksOnASingleLine: Never 16 | AllowShortCaseLabelsOnASingleLine: false 17 | AllowShortFunctionsOnASingleLine: All 18 | AllowShortLambdasOnASingleLine: All 19 | AllowShortIfStatementsOnASingleLine: WithoutElse 20 | AllowShortLoopsOnASingleLine: true 21 | AlwaysBreakAfterDefinitionReturnType: None 22 | AlwaysBreakAfterReturnType: None 23 | AlwaysBreakBeforeMultilineStrings: true 24 | AlwaysBreakTemplateDeclarations: Yes 25 | BinPackArguments: true 26 | BinPackParameters: true 27 | BraceWrapping: 28 | AfterCaseLabel: false 29 | AfterClass: false 30 | AfterControlStatement: false 31 | AfterEnum: false 32 | AfterFunction: false 33 | AfterNamespace: false 34 | AfterObjCDeclaration: false 35 | AfterStruct: false 36 | AfterUnion: false 37 | AfterExternBlock: false 38 | BeforeCatch: false 39 | BeforeElse: false 40 | IndentBraces: false 41 | SplitEmptyFunction: true 42 | SplitEmptyRecord: true 43 | SplitEmptyNamespace: true 44 | BreakBeforeBinaryOperators: None 45 | BreakBeforeBraces: Attach 46 | BreakBeforeInheritanceComma: false 47 | BreakInheritanceList: BeforeColon 48 | BreakBeforeTernaryOperators: true 49 | BreakConstructorInitializersBeforeComma: false 50 | BreakConstructorInitializers: BeforeColon 51 | BreakAfterJavaFieldAnnotations: false 52 | BreakStringLiterals: true 53 | ColumnLimit: 80 54 | CommentPragmas: '^ IWYU pragma:' 55 | CompactNamespaces: false 56 | ConstructorInitializerAllOnOneLineOrOnePerLine: true 57 | ConstructorInitializerIndentWidth: 4 58 | ContinuationIndentWidth: 4 59 | Cpp11BracedListStyle: true 60 | DeriveLineEnding: true 61 | DerivePointerAlignment: true 62 | DisableFormat: false 63 | ExperimentalAutoDetectBinPacking: false 64 | FixNamespaceComments: true 65 | ForEachMacros: 66 | - foreach 67 | - Q_FOREACH 68 | - BOOST_FOREACH 69 | IncludeBlocks: Regroup 70 | IncludeCategories: 71 | - Regex: '^' 72 | Priority: 2 73 | SortPriority: 0 74 | - Regex: '^<.*\.h>' 75 | Priority: 1 76 | SortPriority: 0 77 | - Regex: '^<.*' 78 | Priority: 2 79 | SortPriority: 0 80 | - Regex: '.*' 81 | Priority: 3 82 | SortPriority: 0 83 | IncludeIsMainRegex: '([-_](test|unittest))?$' 84 | IncludeIsMainSourceRegex: '' 85 | IndentCaseLabels: true 86 | IndentGotoLabels: true 87 | IndentPPDirectives: None 88 | IndentWidth: 2 89 | IndentWrappedFunctionNames: false 90 | JavaScriptQuotes: Leave 91 | JavaScriptWrapImports: true 92 | KeepEmptyLinesAtTheStartOfBlocks: false 93 | MacroBlockBegin: '' 94 | MacroBlockEnd: '' 95 | MaxEmptyLinesToKeep: 1 96 | NamespaceIndentation: None 97 | ObjCBinPackProtocolList: Never 98 | ObjCBlockIndentWidth: 2 99 | ObjCSpaceAfterProperty: false 100 | ObjCSpaceBeforeProtocolList: true 101 | PenaltyBreakAssignment: 2 102 | PenaltyBreakBeforeFirstCallParameter: 1 103 | PenaltyBreakComment: 300 104 | PenaltyBreakFirstLessLess: 120 105 | PenaltyBreakString: 1000 106 | PenaltyBreakTemplateDeclaration: 10 107 | PenaltyExcessCharacter: 1000000 108 | PenaltyReturnTypeOnItsOwnLine: 200 109 | PointerAlignment: Left 110 | RawStringFormats: 111 | - Language: Cpp 112 | Delimiters: 113 | - cc 114 | - CC 115 | - cpp 116 | - Cpp 117 | - CPP 118 | - 'c++' 119 | - 'C++' 120 | CanonicalDelimiter: '' 121 | BasedOnStyle: google 122 | - Language: TextProto 123 | Delimiters: 124 | - pb 125 | - PB 126 | - proto 127 | - PROTO 128 | EnclosingFunctions: 129 | - EqualsProto 130 | - EquivToProto 131 | - PARSE_PARTIAL_TEXT_PROTO 132 | - PARSE_TEST_PROTO 133 | - PARSE_TEXT_PROTO 134 | - ParseTextOrDie 135 | - ParseTextProtoOrDie 136 | CanonicalDelimiter: '' 137 | BasedOnStyle: google 138 | ReflowComments: true 139 | SortIncludes: true 140 | SortUsingDeclarations: true 141 | SpaceAfterCStyleCast: false 142 | SpaceAfterLogicalNot: false 143 | SpaceAfterTemplateKeyword: true 144 | SpaceBeforeAssignmentOperators: true 145 | SpaceBeforeCpp11BracedList: false 146 | SpaceBeforeCtorInitializerColon: true 147 | SpaceBeforeInheritanceColon: true 148 | SpaceBeforeParens: ControlStatements 149 | SpaceBeforeRangeBasedForLoopColon: true 150 | SpaceInEmptyBlock: false 151 | SpaceInEmptyParentheses: false 152 | SpacesBeforeTrailingComments: 2 153 | SpacesInAngles: false 154 | SpacesInConditionalStatement: false 155 | SpacesInContainerLiterals: true 156 | SpacesInCStyleCastParentheses: false 157 | SpacesInParentheses: false 158 | SpacesInSquareBrackets: false 159 | SpaceBeforeSquareBrackets: false 160 | Standard: Auto 161 | StatementMacros: 162 | - Q_UNUSED 163 | - QT_REQUIRE_VERSION 164 | TabWidth: 8 165 | UseCRLF: false 166 | UseTab: Never 167 | ... 168 | 169 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Build and test 2 | 3 | on: 4 | - push 5 | - pull_request 6 | 7 | jobs: 8 | test_parser: 9 | name: Test Parser 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | - uses: actions/setup-node@v1 14 | with: 15 | node-version: '14' 16 | - run: npm install 17 | - run: npm test 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### Tree Sitter ### 2 | # Example file 3 | example-file 4 | 5 | ### CCLS ### 6 | # CCLS is in the Nix env for completion 7 | .ccls-cache 8 | 9 | ### Node ### 10 | # Logs 11 | logs 12 | *.log 13 | npm-debug.log* 14 | yarn-debug.log* 15 | yarn-error.log* 16 | 17 | # Diagnostic reports (https://nodejs.org/api/report.html) 18 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 19 | 20 | # Runtime data 21 | pids 22 | *.pid 23 | *.seed 24 | *.pid.lock 25 | 26 | # Compiled binary addons (https://nodejs.org/api/addons.html) 27 | build/ 28 | 29 | # Dependency directories 30 | node_modules/ 31 | 32 | # Optional npm cache directory 33 | .npm 34 | 35 | # Output of 'npm pack' 36 | *.tgz 37 | 38 | # Yarn Integrity file 39 | .yarn-integrity 40 | 41 | # dotenv environment variables file 42 | .env 43 | .env.test 44 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Tentative Org-mode parser for Tree Sitter 2 | 3 | I have no idea what I'm doing. 4 | 5 | # Status 6 | 7 | The `stable` branch aims to have green tests all the time, so you can easily 8 | check in those tests which syntax is currently parsed. 9 | 10 | You can easily see what I am working on by checking the tests that fail in 11 | the `develop` branch 12 | -------------------------------------------------------------------------------- /binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | { 4 | "target_name": "tree_sitter_org_binding", 5 | "include_dirs": [ 6 | " [$.org_headline], 7 | 8 | rules: { 9 | // TODO: add the metadata header 10 | org_file: ($) => repeat($._section), 11 | 12 | _section: ($) => 13 | choice( 14 | $.headline 15 | // TODO: add other kinds 16 | ), 17 | 18 | headline: ($) => 19 | seq( 20 | field("level", $.stars), 21 | field("todo", optional($.todo)), 22 | field("prio", optional($.priority)), 23 | field("comment", optional($.comment)), 24 | field("title", optional($.title)), 25 | field("tags", optional($.tags)), 26 | field("end_title", $.line_ending) 27 | ), 28 | 29 | // text: ($) => /[^\r\n]+/, 30 | line_ending: ($) => token(choice(/\r\n/, /\n/)), 31 | // whitespace: ($) => /\s+/, 32 | 33 | stars: ($) => /\*+/, 34 | 35 | priority: ($) => /\[#[A-Ca-c]\]/, 36 | todo: ($) => choice("TODO", "NEXT", "DONE", "WAITING", "CANCELLED"), 37 | comment: ($) => /COMMENT/, 38 | tag: ($) => /[a-zA-Z0-9#%]+/, 39 | tags: ($) => seq(":", repeat1(seq($.tag, ":"))), 40 | title: ($) => token(prec(-25, /[^\r\n]+/)), 41 | }, 42 | }); 43 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | try { 2 | module.exports = require("./build/Release/tree_sitter_YOUR_LANGUAGE_NAME_binding"); 3 | } catch (error) { 4 | try { 5 | module.exports = require("./build/Debug/tree_sitter_YOUR_LANGUAGE_NAME_binding"); 6 | } catch (_) { 7 | throw error; 8 | } 9 | } 10 | 11 | try { 12 | module.exports.nodeTypeInfo = require("./src/node-types.json"); 13 | } catch (_) {} 14 | -------------------------------------------------------------------------------- /manifest.scm: -------------------------------------------------------------------------------- 1 | ;; Use guix environment -m manifest.scm 2 | ;; Or with direnv: 3 | ;; use_guix -m manifest.scm 4 | (specifications->manifest 5 | '("node" 6 | "ccls" 7 | "gcc-toolchain@10.2.0")) 8 | 9 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tree-sitter-org", 3 | "version": "0.1.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "nan": { 8 | "version": "2.14.1", 9 | "resolved": "https://registry.npmjs.org/nan/-/nan-2.14.1.tgz", 10 | "integrity": "sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw==" 11 | }, 12 | "prettier": { 13 | "version": "2.1.2", 14 | "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.2.tgz", 15 | "integrity": "sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg==", 16 | "dev": true 17 | }, 18 | "tree-sitter-cli": { 19 | "version": "0.16.9", 20 | "resolved": "https://registry.npmjs.org/tree-sitter-cli/-/tree-sitter-cli-0.16.9.tgz", 21 | "integrity": "sha512-Aguz2Ns7qG6t71MP9odhh4t9q3+f29BAmZq8XsTDMtoi5o/e9k+Umeqz6brNngCAz3vMBl1OX95ozdnYzhJWIA==", 22 | "dev": true 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tree-sitter-org", 3 | "version": "0.1.0", 4 | "description": "Tree-sitter parser for the Org markup language", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "tree-sitter generate && tree-sitter test", 8 | "lint": "prettier -w grammar.js" 9 | }, 10 | "author": "Gerry Agbobada", 11 | "license": "GPL-3.0-only", 12 | "dependencies": { 13 | "nan": "^2.14.2" 14 | }, 15 | "devDependencies": { 16 | "prettier": "^2.1.2", 17 | "tree-sitter-cli": "^0.19.4" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /shell.nix: -------------------------------------------------------------------------------- 1 | # Use nix-shell 2 | # Or with direnv: 3 | # use_nix 4 | { pkgs ? import {} }: 5 | pkgs.gcc10Stdenv.mkDerivation { 6 | name="treesitter_org_shell"; 7 | buildInputs = [ 8 | pkgs.nodejs-14_x 9 | pkgs.gcc10 10 | pkgs.ccls 11 | pkgs.clang-tools 12 | ]; 13 | } 14 | -------------------------------------------------------------------------------- /src/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_YOUR_LANGUAGE_NAME(); 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_YOUR_LANGUAGE_NAME()); 21 | 22 | Nan::Set(instance, Nan::New("name").ToLocalChecked(), Nan::New("YOUR_LANGUAGE_NAME").ToLocalChecked()); 23 | Nan::Set(module, Nan::New("exports").ToLocalChecked(), instance); 24 | } 25 | 26 | NODE_MODULE(tree_sitter_YOUR_LANGUAGE_NAME_binding, Init) 27 | 28 | } // namespace 29 | -------------------------------------------------------------------------------- /src/grammar.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "org", 3 | "rules": { 4 | "org_file": { 5 | "type": "REPEAT", 6 | "content": { 7 | "type": "SYMBOL", 8 | "name": "_section" 9 | } 10 | }, 11 | "_section": { 12 | "type": "CHOICE", 13 | "members": [ 14 | { 15 | "type": "SYMBOL", 16 | "name": "headline" 17 | } 18 | ] 19 | }, 20 | "headline": { 21 | "type": "SEQ", 22 | "members": [ 23 | { 24 | "type": "FIELD", 25 | "name": "level", 26 | "content": { 27 | "type": "SYMBOL", 28 | "name": "stars" 29 | } 30 | }, 31 | { 32 | "type": "FIELD", 33 | "name": "todo", 34 | "content": { 35 | "type": "CHOICE", 36 | "members": [ 37 | { 38 | "type": "SYMBOL", 39 | "name": "todo" 40 | }, 41 | { 42 | "type": "BLANK" 43 | } 44 | ] 45 | } 46 | }, 47 | { 48 | "type": "FIELD", 49 | "name": "prio", 50 | "content": { 51 | "type": "CHOICE", 52 | "members": [ 53 | { 54 | "type": "SYMBOL", 55 | "name": "priority" 56 | }, 57 | { 58 | "type": "BLANK" 59 | } 60 | ] 61 | } 62 | }, 63 | { 64 | "type": "FIELD", 65 | "name": "comment", 66 | "content": { 67 | "type": "CHOICE", 68 | "members": [ 69 | { 70 | "type": "SYMBOL", 71 | "name": "comment" 72 | }, 73 | { 74 | "type": "BLANK" 75 | } 76 | ] 77 | } 78 | }, 79 | { 80 | "type": "FIELD", 81 | "name": "title", 82 | "content": { 83 | "type": "CHOICE", 84 | "members": [ 85 | { 86 | "type": "SYMBOL", 87 | "name": "title" 88 | }, 89 | { 90 | "type": "BLANK" 91 | } 92 | ] 93 | } 94 | }, 95 | { 96 | "type": "FIELD", 97 | "name": "tags", 98 | "content": { 99 | "type": "CHOICE", 100 | "members": [ 101 | { 102 | "type": "SYMBOL", 103 | "name": "tags" 104 | }, 105 | { 106 | "type": "BLANK" 107 | } 108 | ] 109 | } 110 | }, 111 | { 112 | "type": "FIELD", 113 | "name": "end_title", 114 | "content": { 115 | "type": "SYMBOL", 116 | "name": "line_ending" 117 | } 118 | } 119 | ] 120 | }, 121 | "line_ending": { 122 | "type": "TOKEN", 123 | "content": { 124 | "type": "CHOICE", 125 | "members": [ 126 | { 127 | "type": "PATTERN", 128 | "value": "\\r\\n" 129 | }, 130 | { 131 | "type": "PATTERN", 132 | "value": "\\n" 133 | } 134 | ] 135 | } 136 | }, 137 | "stars": { 138 | "type": "PATTERN", 139 | "value": "\\*+" 140 | }, 141 | "priority": { 142 | "type": "PATTERN", 143 | "value": "\\[#[A-Ca-c]\\]" 144 | }, 145 | "todo": { 146 | "type": "CHOICE", 147 | "members": [ 148 | { 149 | "type": "STRING", 150 | "value": "TODO" 151 | }, 152 | { 153 | "type": "STRING", 154 | "value": "NEXT" 155 | }, 156 | { 157 | "type": "STRING", 158 | "value": "DONE" 159 | }, 160 | { 161 | "type": "STRING", 162 | "value": "WAITING" 163 | }, 164 | { 165 | "type": "STRING", 166 | "value": "CANCELLED" 167 | } 168 | ] 169 | }, 170 | "comment": { 171 | "type": "PATTERN", 172 | "value": "COMMENT" 173 | }, 174 | "tag": { 175 | "type": "PATTERN", 176 | "value": "[a-zA-Z0-9#%]+" 177 | }, 178 | "tags": { 179 | "type": "SEQ", 180 | "members": [ 181 | { 182 | "type": "STRING", 183 | "value": ":" 184 | }, 185 | { 186 | "type": "REPEAT1", 187 | "content": { 188 | "type": "SEQ", 189 | "members": [ 190 | { 191 | "type": "SYMBOL", 192 | "name": "tag" 193 | }, 194 | { 195 | "type": "STRING", 196 | "value": ":" 197 | } 198 | ] 199 | } 200 | } 201 | ] 202 | }, 203 | "title": { 204 | "type": "TOKEN", 205 | "content": { 206 | "type": "PREC", 207 | "value": -25, 208 | "content": { 209 | "type": "PATTERN", 210 | "value": "[^\\r\\n]+" 211 | } 212 | } 213 | } 214 | }, 215 | "extras": [ 216 | { 217 | "type": "PATTERN", 218 | "value": "\\s" 219 | } 220 | ], 221 | "conflicts": [], 222 | "externals": [ 223 | { 224 | "type": "SYMBOL", 225 | "name": "org_headline" 226 | } 227 | ], 228 | "inline": [], 229 | "supertypes": [] 230 | } 231 | 232 | -------------------------------------------------------------------------------- /src/node-types.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type": "headline", 4 | "named": true, 5 | "fields": { 6 | "comment": { 7 | "multiple": false, 8 | "required": false, 9 | "types": [ 10 | { 11 | "type": "comment", 12 | "named": true 13 | } 14 | ] 15 | }, 16 | "end_title": { 17 | "multiple": false, 18 | "required": true, 19 | "types": [ 20 | { 21 | "type": "line_ending", 22 | "named": true 23 | } 24 | ] 25 | }, 26 | "level": { 27 | "multiple": false, 28 | "required": true, 29 | "types": [ 30 | { 31 | "type": "stars", 32 | "named": true 33 | } 34 | ] 35 | }, 36 | "prio": { 37 | "multiple": false, 38 | "required": false, 39 | "types": [ 40 | { 41 | "type": "priority", 42 | "named": true 43 | } 44 | ] 45 | }, 46 | "tags": { 47 | "multiple": false, 48 | "required": false, 49 | "types": [ 50 | { 51 | "type": "tags", 52 | "named": true 53 | } 54 | ] 55 | }, 56 | "title": { 57 | "multiple": false, 58 | "required": false, 59 | "types": [ 60 | { 61 | "type": "title", 62 | "named": true 63 | } 64 | ] 65 | }, 66 | "todo": { 67 | "multiple": false, 68 | "required": false, 69 | "types": [ 70 | { 71 | "type": "todo", 72 | "named": true 73 | } 74 | ] 75 | } 76 | } 77 | }, 78 | { 79 | "type": "org_file", 80 | "named": true, 81 | "fields": {}, 82 | "children": { 83 | "multiple": true, 84 | "required": false, 85 | "types": [ 86 | { 87 | "type": "headline", 88 | "named": true 89 | } 90 | ] 91 | } 92 | }, 93 | { 94 | "type": "tags", 95 | "named": true, 96 | "fields": {}, 97 | "children": { 98 | "multiple": true, 99 | "required": true, 100 | "types": [ 101 | { 102 | "type": "tag", 103 | "named": true 104 | } 105 | ] 106 | } 107 | }, 108 | { 109 | "type": "todo", 110 | "named": true, 111 | "fields": {} 112 | }, 113 | { 114 | "type": ":", 115 | "named": false 116 | }, 117 | { 118 | "type": "CANCELLED", 119 | "named": false 120 | }, 121 | { 122 | "type": "DONE", 123 | "named": false 124 | }, 125 | { 126 | "type": "NEXT", 127 | "named": false 128 | }, 129 | { 130 | "type": "TODO", 131 | "named": false 132 | }, 133 | { 134 | "type": "WAITING", 135 | "named": false 136 | }, 137 | { 138 | "type": "comment", 139 | "named": true 140 | }, 141 | { 142 | "type": "line_ending", 143 | "named": true 144 | }, 145 | { 146 | "type": "priority", 147 | "named": true 148 | }, 149 | { 150 | "type": "stars", 151 | "named": true 152 | }, 153 | { 154 | "type": "tag", 155 | "named": true 156 | }, 157 | { 158 | "type": "title", 159 | "named": true 160 | } 161 | ] -------------------------------------------------------------------------------- /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 11 9 | #define STATE_COUNT 75 10 | #define LARGE_STATE_COUNT 3 11 | #define SYMBOL_COUNT 21 12 | #define ALIAS_COUNT 0 13 | #define TOKEN_COUNT 14 14 | #define EXTERNAL_TOKEN_COUNT 1 15 | #define FIELD_COUNT 7 16 | #define MAX_ALIAS_SEQUENCE_LENGTH 7 17 | 18 | enum { 19 | sym_line_ending = 1, 20 | sym_stars = 2, 21 | sym_priority = 3, 22 | anon_sym_TODO = 4, 23 | anon_sym_NEXT = 5, 24 | anon_sym_DONE = 6, 25 | anon_sym_WAITING = 7, 26 | anon_sym_CANCELLED = 8, 27 | sym_comment = 9, 28 | sym_tag = 10, 29 | anon_sym_COLON = 11, 30 | sym_title = 12, 31 | sym_org_headline = 13, 32 | sym_org_file = 14, 33 | sym__section = 15, 34 | sym_headline = 16, 35 | sym_todo = 17, 36 | sym_tags = 18, 37 | aux_sym_org_file_repeat1 = 19, 38 | aux_sym_tags_repeat1 = 20, 39 | }; 40 | 41 | static const char *ts_symbol_names[] = { 42 | [ts_builtin_sym_end] = "end", 43 | [sym_line_ending] = "line_ending", 44 | [sym_stars] = "stars", 45 | [sym_priority] = "priority", 46 | [anon_sym_TODO] = "TODO", 47 | [anon_sym_NEXT] = "NEXT", 48 | [anon_sym_DONE] = "DONE", 49 | [anon_sym_WAITING] = "WAITING", 50 | [anon_sym_CANCELLED] = "CANCELLED", 51 | [sym_comment] = "comment", 52 | [sym_tag] = "tag", 53 | [anon_sym_COLON] = ":", 54 | [sym_title] = "title", 55 | [sym_org_headline] = "org_headline", 56 | [sym_org_file] = "org_file", 57 | [sym__section] = "_section", 58 | [sym_headline] = "headline", 59 | [sym_todo] = "todo", 60 | [sym_tags] = "tags", 61 | [aux_sym_org_file_repeat1] = "org_file_repeat1", 62 | [aux_sym_tags_repeat1] = "tags_repeat1", 63 | }; 64 | 65 | static TSSymbol ts_symbol_map[] = { 66 | [ts_builtin_sym_end] = ts_builtin_sym_end, 67 | [sym_line_ending] = sym_line_ending, 68 | [sym_stars] = sym_stars, 69 | [sym_priority] = sym_priority, 70 | [anon_sym_TODO] = anon_sym_TODO, 71 | [anon_sym_NEXT] = anon_sym_NEXT, 72 | [anon_sym_DONE] = anon_sym_DONE, 73 | [anon_sym_WAITING] = anon_sym_WAITING, 74 | [anon_sym_CANCELLED] = anon_sym_CANCELLED, 75 | [sym_comment] = sym_comment, 76 | [sym_tag] = sym_tag, 77 | [anon_sym_COLON] = anon_sym_COLON, 78 | [sym_title] = sym_title, 79 | [sym_org_headline] = sym_org_headline, 80 | [sym_org_file] = sym_org_file, 81 | [sym__section] = sym__section, 82 | [sym_headline] = sym_headline, 83 | [sym_todo] = sym_todo, 84 | [sym_tags] = sym_tags, 85 | [aux_sym_org_file_repeat1] = aux_sym_org_file_repeat1, 86 | [aux_sym_tags_repeat1] = aux_sym_tags_repeat1, 87 | }; 88 | 89 | static const TSSymbolMetadata ts_symbol_metadata[] = { 90 | [ts_builtin_sym_end] = { 91 | .visible = false, 92 | .named = true, 93 | }, 94 | [sym_line_ending] = { 95 | .visible = true, 96 | .named = true, 97 | }, 98 | [sym_stars] = { 99 | .visible = true, 100 | .named = true, 101 | }, 102 | [sym_priority] = { 103 | .visible = true, 104 | .named = true, 105 | }, 106 | [anon_sym_TODO] = { 107 | .visible = true, 108 | .named = false, 109 | }, 110 | [anon_sym_NEXT] = { 111 | .visible = true, 112 | .named = false, 113 | }, 114 | [anon_sym_DONE] = { 115 | .visible = true, 116 | .named = false, 117 | }, 118 | [anon_sym_WAITING] = { 119 | .visible = true, 120 | .named = false, 121 | }, 122 | [anon_sym_CANCELLED] = { 123 | .visible = true, 124 | .named = false, 125 | }, 126 | [sym_comment] = { 127 | .visible = true, 128 | .named = true, 129 | }, 130 | [sym_tag] = { 131 | .visible = true, 132 | .named = true, 133 | }, 134 | [anon_sym_COLON] = { 135 | .visible = true, 136 | .named = false, 137 | }, 138 | [sym_title] = { 139 | .visible = true, 140 | .named = true, 141 | }, 142 | [sym_org_headline] = { 143 | .visible = true, 144 | .named = true, 145 | }, 146 | [sym_org_file] = { 147 | .visible = true, 148 | .named = true, 149 | }, 150 | [sym__section] = { 151 | .visible = false, 152 | .named = true, 153 | }, 154 | [sym_headline] = { 155 | .visible = true, 156 | .named = true, 157 | }, 158 | [sym_todo] = { 159 | .visible = true, 160 | .named = true, 161 | }, 162 | [sym_tags] = { 163 | .visible = true, 164 | .named = true, 165 | }, 166 | [aux_sym_org_file_repeat1] = { 167 | .visible = false, 168 | .named = false, 169 | }, 170 | [aux_sym_tags_repeat1] = { 171 | .visible = false, 172 | .named = false, 173 | }, 174 | }; 175 | 176 | enum { 177 | field_comment = 1, 178 | field_end_title = 2, 179 | field_level = 3, 180 | field_prio = 4, 181 | field_tags = 5, 182 | field_title = 6, 183 | field_todo = 7, 184 | }; 185 | 186 | static const char *ts_field_names[] = { 187 | [0] = NULL, 188 | [field_comment] = "comment", 189 | [field_end_title] = "end_title", 190 | [field_level] = "level", 191 | [field_prio] = "prio", 192 | [field_tags] = "tags", 193 | [field_title] = "title", 194 | [field_todo] = "todo", 195 | }; 196 | 197 | static const TSFieldMapSlice ts_field_map_slices[33] = { 198 | [1] = {.index = 0, .length = 2}, 199 | [2] = {.index = 2, .length = 3}, 200 | [3] = {.index = 5, .length = 3}, 201 | [4] = {.index = 8, .length = 3}, 202 | [5] = {.index = 11, .length = 3}, 203 | [6] = {.index = 14, .length = 3}, 204 | [7] = {.index = 17, .length = 4}, 205 | [8] = {.index = 21, .length = 4}, 206 | [9] = {.index = 25, .length = 4}, 207 | [10] = {.index = 29, .length = 4}, 208 | [11] = {.index = 33, .length = 4}, 209 | [12] = {.index = 37, .length = 4}, 210 | [13] = {.index = 41, .length = 4}, 211 | [14] = {.index = 45, .length = 4}, 212 | [15] = {.index = 49, .length = 4}, 213 | [16] = {.index = 53, .length = 4}, 214 | [17] = {.index = 57, .length = 5}, 215 | [18] = {.index = 62, .length = 5}, 216 | [19] = {.index = 67, .length = 5}, 217 | [20] = {.index = 72, .length = 5}, 218 | [21] = {.index = 77, .length = 5}, 219 | [22] = {.index = 82, .length = 5}, 220 | [23] = {.index = 87, .length = 5}, 221 | [24] = {.index = 92, .length = 5}, 222 | [25] = {.index = 97, .length = 5}, 223 | [26] = {.index = 102, .length = 5}, 224 | [27] = {.index = 107, .length = 6}, 225 | [28] = {.index = 113, .length = 6}, 226 | [29] = {.index = 119, .length = 6}, 227 | [30] = {.index = 125, .length = 6}, 228 | [31] = {.index = 131, .length = 6}, 229 | [32] = {.index = 137, .length = 7}, 230 | }; 231 | 232 | static const TSFieldMapEntry ts_field_map_entries[] = { 233 | [0] = 234 | {field_end_title, 1}, 235 | {field_level, 0}, 236 | [2] = 237 | {field_end_title, 2}, 238 | {field_level, 0}, 239 | {field_prio, 1}, 240 | [5] = 241 | {field_comment, 1}, 242 | {field_end_title, 2}, 243 | {field_level, 0}, 244 | [8] = 245 | {field_end_title, 2}, 246 | {field_level, 0}, 247 | {field_title, 1}, 248 | [11] = 249 | {field_end_title, 2}, 250 | {field_level, 0}, 251 | {field_todo, 1}, 252 | [14] = 253 | {field_end_title, 2}, 254 | {field_level, 0}, 255 | {field_tags, 1}, 256 | [17] = 257 | {field_comment, 2}, 258 | {field_end_title, 3}, 259 | {field_level, 0}, 260 | {field_prio, 1}, 261 | [21] = 262 | {field_end_title, 3}, 263 | {field_level, 0}, 264 | {field_prio, 1}, 265 | {field_title, 2}, 266 | [25] = 267 | {field_end_title, 3}, 268 | {field_level, 0}, 269 | {field_prio, 1}, 270 | {field_tags, 2}, 271 | [29] = 272 | {field_comment, 1}, 273 | {field_end_title, 3}, 274 | {field_level, 0}, 275 | {field_title, 2}, 276 | [33] = 277 | {field_comment, 1}, 278 | {field_end_title, 3}, 279 | {field_level, 0}, 280 | {field_tags, 2}, 281 | [37] = 282 | {field_end_title, 3}, 283 | {field_level, 0}, 284 | {field_tags, 2}, 285 | {field_title, 1}, 286 | [41] = 287 | {field_end_title, 3}, 288 | {field_level, 0}, 289 | {field_prio, 2}, 290 | {field_todo, 1}, 291 | [45] = 292 | {field_comment, 2}, 293 | {field_end_title, 3}, 294 | {field_level, 0}, 295 | {field_todo, 1}, 296 | [49] = 297 | {field_end_title, 3}, 298 | {field_level, 0}, 299 | {field_title, 2}, 300 | {field_todo, 1}, 301 | [53] = 302 | {field_end_title, 3}, 303 | {field_level, 0}, 304 | {field_tags, 2}, 305 | {field_todo, 1}, 306 | [57] = 307 | {field_comment, 2}, 308 | {field_end_title, 4}, 309 | {field_level, 0}, 310 | {field_prio, 1}, 311 | {field_title, 3}, 312 | [62] = 313 | {field_comment, 2}, 314 | {field_end_title, 4}, 315 | {field_level, 0}, 316 | {field_prio, 1}, 317 | {field_tags, 3}, 318 | [67] = 319 | {field_end_title, 4}, 320 | {field_level, 0}, 321 | {field_prio, 1}, 322 | {field_tags, 3}, 323 | {field_title, 2}, 324 | [72] = 325 | {field_comment, 1}, 326 | {field_end_title, 4}, 327 | {field_level, 0}, 328 | {field_tags, 3}, 329 | {field_title, 2}, 330 | [77] = 331 | {field_comment, 3}, 332 | {field_end_title, 4}, 333 | {field_level, 0}, 334 | {field_prio, 2}, 335 | {field_todo, 1}, 336 | [82] = 337 | {field_end_title, 4}, 338 | {field_level, 0}, 339 | {field_prio, 2}, 340 | {field_title, 3}, 341 | {field_todo, 1}, 342 | [87] = 343 | {field_end_title, 4}, 344 | {field_level, 0}, 345 | {field_prio, 2}, 346 | {field_tags, 3}, 347 | {field_todo, 1}, 348 | [92] = 349 | {field_comment, 2}, 350 | {field_end_title, 4}, 351 | {field_level, 0}, 352 | {field_title, 3}, 353 | {field_todo, 1}, 354 | [97] = 355 | {field_comment, 2}, 356 | {field_end_title, 4}, 357 | {field_level, 0}, 358 | {field_tags, 3}, 359 | {field_todo, 1}, 360 | [102] = 361 | {field_end_title, 4}, 362 | {field_level, 0}, 363 | {field_tags, 3}, 364 | {field_title, 2}, 365 | {field_todo, 1}, 366 | [107] = 367 | {field_comment, 2}, 368 | {field_end_title, 5}, 369 | {field_level, 0}, 370 | {field_prio, 1}, 371 | {field_tags, 4}, 372 | {field_title, 3}, 373 | [113] = 374 | {field_comment, 3}, 375 | {field_end_title, 5}, 376 | {field_level, 0}, 377 | {field_prio, 2}, 378 | {field_title, 4}, 379 | {field_todo, 1}, 380 | [119] = 381 | {field_comment, 3}, 382 | {field_end_title, 5}, 383 | {field_level, 0}, 384 | {field_prio, 2}, 385 | {field_tags, 4}, 386 | {field_todo, 1}, 387 | [125] = 388 | {field_end_title, 5}, 389 | {field_level, 0}, 390 | {field_prio, 2}, 391 | {field_tags, 4}, 392 | {field_title, 3}, 393 | {field_todo, 1}, 394 | [131] = 395 | {field_comment, 2}, 396 | {field_end_title, 5}, 397 | {field_level, 0}, 398 | {field_tags, 4}, 399 | {field_title, 3}, 400 | {field_todo, 1}, 401 | [137] = 402 | {field_comment, 3}, 403 | {field_end_title, 6}, 404 | {field_level, 0}, 405 | {field_prio, 2}, 406 | {field_tags, 5}, 407 | {field_title, 4}, 408 | {field_todo, 1}, 409 | }; 410 | 411 | static TSSymbol ts_alias_sequences[33][MAX_ALIAS_SEQUENCE_LENGTH] = { 412 | [0] = {0}, 413 | }; 414 | 415 | static bool ts_lex(TSLexer *lexer, TSStateId state) { 416 | START_LEXER(); 417 | eof = lexer->eof(lexer); 418 | switch (state) { 419 | case 0: 420 | if (eof) ADVANCE(38); 421 | if (lookahead == '*') ADVANCE(44); 422 | if (lookahead == ':') ADVANCE(53); 423 | if (lookahead == 'C') ADVANCE(7); 424 | if (lookahead == 'D') ADVANCE(30); 425 | if (lookahead == 'N') ADVANCE(12); 426 | if (lookahead == 'T') ADVANCE(28); 427 | if (lookahead == 'W') ADVANCE(8); 428 | if (lookahead == '[') ADVANCE(6); 429 | if (lookahead == '\t' || 430 | lookahead == '\n' || 431 | lookahead == '\r' || 432 | lookahead == ' ') SKIP(0) 433 | END_STATE(); 434 | case 1: 435 | if (lookahead == '\n') ADVANCE(39); 436 | if (lookahead == '\r') ADVANCE(1); 437 | if (lookahead == ':') ADVANCE(53); 438 | if (lookahead == 'C') ADVANCE(59); 439 | if (lookahead == 'D') ADVANCE(83); 440 | if (lookahead == 'N') ADVANCE(65); 441 | if (lookahead == 'T') ADVANCE(82); 442 | if (lookahead == 'W') ADVANCE(60); 443 | if (lookahead == '[') ADVANCE(58); 444 | if (lookahead == '\t' || 445 | lookahead == ' ') ADVANCE(54); 446 | if (lookahead != 0) ADVANCE(90); 447 | END_STATE(); 448 | case 2: 449 | if (lookahead == '\n') ADVANCE(40); 450 | if (lookahead == '\r') ADVANCE(2); 451 | if (lookahead == ':') ADVANCE(53); 452 | if (lookahead == '\t' || 453 | lookahead == ' ') SKIP(2) 454 | if (lookahead == '#' || 455 | lookahead == '%' || 456 | ('0' <= lookahead && lookahead <= '9') || 457 | ('A' <= lookahead && lookahead <= 'Z') || 458 | ('a' <= lookahead && lookahead <= 'z')) ADVANCE(52); 459 | END_STATE(); 460 | case 3: 461 | if (lookahead == '\n') ADVANCE(41); 462 | if (lookahead == '\r') ADVANCE(3); 463 | if (lookahead == ':') ADVANCE(53); 464 | if (lookahead == 'C') ADVANCE(81); 465 | if (lookahead == '[') ADVANCE(58); 466 | if (lookahead == '\t' || 467 | lookahead == ' ') ADVANCE(55); 468 | if (lookahead != 0) ADVANCE(90); 469 | END_STATE(); 470 | case 4: 471 | if (lookahead == '\n') ADVANCE(42); 472 | if (lookahead == '\r') ADVANCE(4); 473 | if (lookahead == ':') ADVANCE(53); 474 | if (lookahead == 'C') ADVANCE(81); 475 | if (lookahead == '\t' || 476 | lookahead == ' ') ADVANCE(56); 477 | if (lookahead != 0) ADVANCE(90); 478 | END_STATE(); 479 | case 5: 480 | if (lookahead == '\n') ADVANCE(43); 481 | if (lookahead == '\r') ADVANCE(5); 482 | if (lookahead == ':') ADVANCE(53); 483 | if (lookahead == '\t' || 484 | lookahead == ' ') ADVANCE(57); 485 | if (lookahead != 0) ADVANCE(90); 486 | END_STATE(); 487 | case 6: 488 | if (lookahead == '#') ADVANCE(37); 489 | END_STATE(); 490 | case 7: 491 | if (lookahead == 'A') ADVANCE(24); 492 | if (lookahead == 'O') ADVANCE(22); 493 | END_STATE(); 494 | case 8: 495 | if (lookahead == 'A') ADVANCE(18); 496 | END_STATE(); 497 | case 9: 498 | if (lookahead == 'C') ADVANCE(14); 499 | END_STATE(); 500 | case 10: 501 | if (lookahead == 'D') ADVANCE(50); 502 | END_STATE(); 503 | case 11: 504 | if (lookahead == 'D') ADVANCE(29); 505 | END_STATE(); 506 | case 12: 507 | if (lookahead == 'E') ADVANCE(34); 508 | END_STATE(); 509 | case 13: 510 | if (lookahead == 'E') ADVANCE(48); 511 | END_STATE(); 512 | case 14: 513 | if (lookahead == 'E') ADVANCE(20); 514 | END_STATE(); 515 | case 15: 516 | if (lookahead == 'E') ADVANCE(10); 517 | END_STATE(); 518 | case 16: 519 | if (lookahead == 'E') ADVANCE(27); 520 | END_STATE(); 521 | case 17: 522 | if (lookahead == 'G') ADVANCE(49); 523 | END_STATE(); 524 | case 18: 525 | if (lookahead == 'I') ADVANCE(33); 526 | END_STATE(); 527 | case 19: 528 | if (lookahead == 'I') ADVANCE(25); 529 | END_STATE(); 530 | case 20: 531 | if (lookahead == 'L') ADVANCE(21); 532 | END_STATE(); 533 | case 21: 534 | if (lookahead == 'L') ADVANCE(15); 535 | END_STATE(); 536 | case 22: 537 | if (lookahead == 'M') ADVANCE(23); 538 | END_STATE(); 539 | case 23: 540 | if (lookahead == 'M') ADVANCE(16); 541 | END_STATE(); 542 | case 24: 543 | if (lookahead == 'N') ADVANCE(9); 544 | END_STATE(); 545 | case 25: 546 | if (lookahead == 'N') ADVANCE(17); 547 | END_STATE(); 548 | case 26: 549 | if (lookahead == 'N') ADVANCE(13); 550 | END_STATE(); 551 | case 27: 552 | if (lookahead == 'N') ADVANCE(32); 553 | END_STATE(); 554 | case 28: 555 | if (lookahead == 'O') ADVANCE(11); 556 | END_STATE(); 557 | case 29: 558 | if (lookahead == 'O') ADVANCE(46); 559 | END_STATE(); 560 | case 30: 561 | if (lookahead == 'O') ADVANCE(26); 562 | END_STATE(); 563 | case 31: 564 | if (lookahead == 'T') ADVANCE(47); 565 | END_STATE(); 566 | case 32: 567 | if (lookahead == 'T') ADVANCE(51); 568 | END_STATE(); 569 | case 33: 570 | if (lookahead == 'T') ADVANCE(19); 571 | END_STATE(); 572 | case 34: 573 | if (lookahead == 'X') ADVANCE(31); 574 | END_STATE(); 575 | case 35: 576 | if (lookahead == ']') ADVANCE(45); 577 | END_STATE(); 578 | case 36: 579 | if (lookahead == '\t' || 580 | lookahead == '\n' || 581 | lookahead == '\r' || 582 | lookahead == ' ') SKIP(36) 583 | if (lookahead == '#' || 584 | lookahead == '%' || 585 | ('0' <= lookahead && lookahead <= '9') || 586 | ('A' <= lookahead && lookahead <= 'Z') || 587 | ('a' <= lookahead && lookahead <= 'z')) ADVANCE(52); 588 | END_STATE(); 589 | case 37: 590 | if (('A' <= lookahead && lookahead <= 'C') || 591 | ('a' <= lookahead && lookahead <= 'c')) ADVANCE(35); 592 | END_STATE(); 593 | case 38: 594 | ACCEPT_TOKEN(ts_builtin_sym_end); 595 | END_STATE(); 596 | case 39: 597 | ACCEPT_TOKEN(sym_line_ending); 598 | if (lookahead == '\n') ADVANCE(39); 599 | if (lookahead == '\r') ADVANCE(1); 600 | if (lookahead == '\t' || 601 | lookahead == ' ') ADVANCE(54); 602 | END_STATE(); 603 | case 40: 604 | ACCEPT_TOKEN(sym_line_ending); 605 | if (lookahead == '\n') ADVANCE(40); 606 | if (lookahead == '\r') ADVANCE(2); 607 | END_STATE(); 608 | case 41: 609 | ACCEPT_TOKEN(sym_line_ending); 610 | if (lookahead == '\n') ADVANCE(41); 611 | if (lookahead == '\r') ADVANCE(3); 612 | if (lookahead == '\t' || 613 | lookahead == ' ') ADVANCE(55); 614 | END_STATE(); 615 | case 42: 616 | ACCEPT_TOKEN(sym_line_ending); 617 | if (lookahead == '\n') ADVANCE(42); 618 | if (lookahead == '\r') ADVANCE(4); 619 | if (lookahead == '\t' || 620 | lookahead == ' ') ADVANCE(56); 621 | END_STATE(); 622 | case 43: 623 | ACCEPT_TOKEN(sym_line_ending); 624 | if (lookahead == '\n') ADVANCE(43); 625 | if (lookahead == '\r') ADVANCE(5); 626 | if (lookahead == '\t' || 627 | lookahead == ' ') ADVANCE(57); 628 | END_STATE(); 629 | case 44: 630 | ACCEPT_TOKEN(sym_stars); 631 | if (lookahead == '*') ADVANCE(44); 632 | END_STATE(); 633 | case 45: 634 | ACCEPT_TOKEN(sym_priority); 635 | END_STATE(); 636 | case 46: 637 | ACCEPT_TOKEN(anon_sym_TODO); 638 | END_STATE(); 639 | case 47: 640 | ACCEPT_TOKEN(anon_sym_NEXT); 641 | END_STATE(); 642 | case 48: 643 | ACCEPT_TOKEN(anon_sym_DONE); 644 | END_STATE(); 645 | case 49: 646 | ACCEPT_TOKEN(anon_sym_WAITING); 647 | END_STATE(); 648 | case 50: 649 | ACCEPT_TOKEN(anon_sym_CANCELLED); 650 | END_STATE(); 651 | case 51: 652 | ACCEPT_TOKEN(sym_comment); 653 | END_STATE(); 654 | case 52: 655 | ACCEPT_TOKEN(sym_tag); 656 | if (lookahead == '#' || 657 | lookahead == '%' || 658 | ('0' <= lookahead && lookahead <= '9') || 659 | ('A' <= lookahead && lookahead <= 'Z') || 660 | ('a' <= lookahead && lookahead <= 'z')) ADVANCE(52); 661 | END_STATE(); 662 | case 53: 663 | ACCEPT_TOKEN(anon_sym_COLON); 664 | END_STATE(); 665 | case 54: 666 | ACCEPT_TOKEN(sym_title); 667 | if (lookahead == '\n') ADVANCE(39); 668 | if (lookahead == '\r') ADVANCE(1); 669 | if (lookahead == ':') ADVANCE(53); 670 | if (lookahead == 'C') ADVANCE(59); 671 | if (lookahead == 'D') ADVANCE(83); 672 | if (lookahead == 'N') ADVANCE(65); 673 | if (lookahead == 'T') ADVANCE(82); 674 | if (lookahead == 'W') ADVANCE(60); 675 | if (lookahead == '[') ADVANCE(58); 676 | if (lookahead == '\t' || 677 | lookahead == ' ') ADVANCE(54); 678 | if (lookahead != 0) ADVANCE(90); 679 | END_STATE(); 680 | case 55: 681 | ACCEPT_TOKEN(sym_title); 682 | if (lookahead == '\n') ADVANCE(41); 683 | if (lookahead == '\r') ADVANCE(3); 684 | if (lookahead == ':') ADVANCE(53); 685 | if (lookahead == 'C') ADVANCE(81); 686 | if (lookahead == '[') ADVANCE(58); 687 | if (lookahead == '\t' || 688 | lookahead == ' ') ADVANCE(55); 689 | if (lookahead != 0) ADVANCE(90); 690 | END_STATE(); 691 | case 56: 692 | ACCEPT_TOKEN(sym_title); 693 | if (lookahead == '\n') ADVANCE(42); 694 | if (lookahead == '\r') ADVANCE(4); 695 | if (lookahead == ':') ADVANCE(53); 696 | if (lookahead == 'C') ADVANCE(81); 697 | if (lookahead == '\t' || 698 | lookahead == ' ') ADVANCE(56); 699 | if (lookahead != 0) ADVANCE(90); 700 | END_STATE(); 701 | case 57: 702 | ACCEPT_TOKEN(sym_title); 703 | if (lookahead == '\n') ADVANCE(43); 704 | if (lookahead == '\r') ADVANCE(5); 705 | if (lookahead == ':') ADVANCE(53); 706 | if (lookahead == '\t' || 707 | lookahead == ' ') ADVANCE(57); 708 | if (lookahead != 0) ADVANCE(90); 709 | END_STATE(); 710 | case 58: 711 | ACCEPT_TOKEN(sym_title); 712 | if (lookahead == '#') ADVANCE(89); 713 | if (lookahead != 0 && 714 | lookahead != '\n' && 715 | lookahead != '\r') ADVANCE(90); 716 | END_STATE(); 717 | case 59: 718 | ACCEPT_TOKEN(sym_title); 719 | if (lookahead == 'A') ADVANCE(76); 720 | if (lookahead == 'O') ADVANCE(74); 721 | if (lookahead != 0 && 722 | lookahead != '\n' && 723 | lookahead != '\r') ADVANCE(90); 724 | END_STATE(); 725 | case 60: 726 | ACCEPT_TOKEN(sym_title); 727 | if (lookahead == 'A') ADVANCE(70); 728 | if (lookahead != 0 && 729 | lookahead != '\n' && 730 | lookahead != '\r') ADVANCE(90); 731 | END_STATE(); 732 | case 61: 733 | ACCEPT_TOKEN(sym_title); 734 | if (lookahead == 'C') ADVANCE(66); 735 | if (lookahead != 0 && 736 | lookahead != '\n' && 737 | lookahead != '\r') ADVANCE(90); 738 | END_STATE(); 739 | case 62: 740 | ACCEPT_TOKEN(sym_title); 741 | if (lookahead == 'D') ADVANCE(50); 742 | if (lookahead != 0 && 743 | lookahead != '\n' && 744 | lookahead != '\r') ADVANCE(90); 745 | END_STATE(); 746 | case 63: 747 | ACCEPT_TOKEN(sym_title); 748 | if (lookahead == 'D') ADVANCE(80); 749 | if (lookahead != 0 && 750 | lookahead != '\n' && 751 | lookahead != '\r') ADVANCE(90); 752 | END_STATE(); 753 | case 64: 754 | ACCEPT_TOKEN(sym_title); 755 | if (lookahead == 'E') ADVANCE(48); 756 | if (lookahead != 0 && 757 | lookahead != '\n' && 758 | lookahead != '\r') ADVANCE(90); 759 | END_STATE(); 760 | case 65: 761 | ACCEPT_TOKEN(sym_title); 762 | if (lookahead == 'E') ADVANCE(87); 763 | if (lookahead != 0 && 764 | lookahead != '\n' && 765 | lookahead != '\r') ADVANCE(90); 766 | END_STATE(); 767 | case 66: 768 | ACCEPT_TOKEN(sym_title); 769 | if (lookahead == 'E') ADVANCE(72); 770 | if (lookahead != 0 && 771 | lookahead != '\n' && 772 | lookahead != '\r') ADVANCE(90); 773 | END_STATE(); 774 | case 67: 775 | ACCEPT_TOKEN(sym_title); 776 | if (lookahead == 'E') ADVANCE(62); 777 | if (lookahead != 0 && 778 | lookahead != '\n' && 779 | lookahead != '\r') ADVANCE(90); 780 | END_STATE(); 781 | case 68: 782 | ACCEPT_TOKEN(sym_title); 783 | if (lookahead == 'E') ADVANCE(79); 784 | if (lookahead != 0 && 785 | lookahead != '\n' && 786 | lookahead != '\r') ADVANCE(90); 787 | END_STATE(); 788 | case 69: 789 | ACCEPT_TOKEN(sym_title); 790 | if (lookahead == 'G') ADVANCE(49); 791 | if (lookahead != 0 && 792 | lookahead != '\n' && 793 | lookahead != '\r') ADVANCE(90); 794 | END_STATE(); 795 | case 70: 796 | ACCEPT_TOKEN(sym_title); 797 | if (lookahead == 'I') ADVANCE(86); 798 | if (lookahead != 0 && 799 | lookahead != '\n' && 800 | lookahead != '\r') ADVANCE(90); 801 | END_STATE(); 802 | case 71: 803 | ACCEPT_TOKEN(sym_title); 804 | if (lookahead == 'I') ADVANCE(77); 805 | if (lookahead != 0 && 806 | lookahead != '\n' && 807 | lookahead != '\r') ADVANCE(90); 808 | END_STATE(); 809 | case 72: 810 | ACCEPT_TOKEN(sym_title); 811 | if (lookahead == 'L') ADVANCE(73); 812 | if (lookahead != 0 && 813 | lookahead != '\n' && 814 | lookahead != '\r') ADVANCE(90); 815 | END_STATE(); 816 | case 73: 817 | ACCEPT_TOKEN(sym_title); 818 | if (lookahead == 'L') ADVANCE(67); 819 | if (lookahead != 0 && 820 | lookahead != '\n' && 821 | lookahead != '\r') ADVANCE(90); 822 | END_STATE(); 823 | case 74: 824 | ACCEPT_TOKEN(sym_title); 825 | if (lookahead == 'M') ADVANCE(75); 826 | if (lookahead != 0 && 827 | lookahead != '\n' && 828 | lookahead != '\r') ADVANCE(90); 829 | END_STATE(); 830 | case 75: 831 | ACCEPT_TOKEN(sym_title); 832 | if (lookahead == 'M') ADVANCE(68); 833 | if (lookahead != 0 && 834 | lookahead != '\n' && 835 | lookahead != '\r') ADVANCE(90); 836 | END_STATE(); 837 | case 76: 838 | ACCEPT_TOKEN(sym_title); 839 | if (lookahead == 'N') ADVANCE(61); 840 | if (lookahead != 0 && 841 | lookahead != '\n' && 842 | lookahead != '\r') ADVANCE(90); 843 | END_STATE(); 844 | case 77: 845 | ACCEPT_TOKEN(sym_title); 846 | if (lookahead == 'N') ADVANCE(69); 847 | if (lookahead != 0 && 848 | lookahead != '\n' && 849 | lookahead != '\r') ADVANCE(90); 850 | END_STATE(); 851 | case 78: 852 | ACCEPT_TOKEN(sym_title); 853 | if (lookahead == 'N') ADVANCE(64); 854 | if (lookahead != 0 && 855 | lookahead != '\n' && 856 | lookahead != '\r') ADVANCE(90); 857 | END_STATE(); 858 | case 79: 859 | ACCEPT_TOKEN(sym_title); 860 | if (lookahead == 'N') ADVANCE(85); 861 | if (lookahead != 0 && 862 | lookahead != '\n' && 863 | lookahead != '\r') ADVANCE(90); 864 | END_STATE(); 865 | case 80: 866 | ACCEPT_TOKEN(sym_title); 867 | if (lookahead == 'O') ADVANCE(46); 868 | if (lookahead != 0 && 869 | lookahead != '\n' && 870 | lookahead != '\r') ADVANCE(90); 871 | END_STATE(); 872 | case 81: 873 | ACCEPT_TOKEN(sym_title); 874 | if (lookahead == 'O') ADVANCE(74); 875 | if (lookahead != 0 && 876 | lookahead != '\n' && 877 | lookahead != '\r') ADVANCE(90); 878 | END_STATE(); 879 | case 82: 880 | ACCEPT_TOKEN(sym_title); 881 | if (lookahead == 'O') ADVANCE(63); 882 | if (lookahead != 0 && 883 | lookahead != '\n' && 884 | lookahead != '\r') ADVANCE(90); 885 | END_STATE(); 886 | case 83: 887 | ACCEPT_TOKEN(sym_title); 888 | if (lookahead == 'O') ADVANCE(78); 889 | if (lookahead != 0 && 890 | lookahead != '\n' && 891 | lookahead != '\r') ADVANCE(90); 892 | END_STATE(); 893 | case 84: 894 | ACCEPT_TOKEN(sym_title); 895 | if (lookahead == 'T') ADVANCE(47); 896 | if (lookahead != 0 && 897 | lookahead != '\n' && 898 | lookahead != '\r') ADVANCE(90); 899 | END_STATE(); 900 | case 85: 901 | ACCEPT_TOKEN(sym_title); 902 | if (lookahead == 'T') ADVANCE(51); 903 | if (lookahead != 0 && 904 | lookahead != '\n' && 905 | lookahead != '\r') ADVANCE(90); 906 | END_STATE(); 907 | case 86: 908 | ACCEPT_TOKEN(sym_title); 909 | if (lookahead == 'T') ADVANCE(71); 910 | if (lookahead != 0 && 911 | lookahead != '\n' && 912 | lookahead != '\r') ADVANCE(90); 913 | END_STATE(); 914 | case 87: 915 | ACCEPT_TOKEN(sym_title); 916 | if (lookahead == 'X') ADVANCE(84); 917 | if (lookahead != 0 && 918 | lookahead != '\n' && 919 | lookahead != '\r') ADVANCE(90); 920 | END_STATE(); 921 | case 88: 922 | ACCEPT_TOKEN(sym_title); 923 | if (lookahead == ']') ADVANCE(45); 924 | if (lookahead != 0 && 925 | lookahead != '\n' && 926 | lookahead != '\r') ADVANCE(90); 927 | END_STATE(); 928 | case 89: 929 | ACCEPT_TOKEN(sym_title); 930 | if (('A' <= lookahead && lookahead <= 'C') || 931 | ('a' <= lookahead && lookahead <= 'c')) ADVANCE(88); 932 | if (lookahead != 0 && 933 | lookahead != '\n' && 934 | lookahead != '\r') ADVANCE(90); 935 | END_STATE(); 936 | case 90: 937 | ACCEPT_TOKEN(sym_title); 938 | if (lookahead != 0 && 939 | lookahead != '\n' && 940 | lookahead != '\r') ADVANCE(90); 941 | END_STATE(); 942 | default: 943 | return false; 944 | } 945 | } 946 | 947 | static TSLexMode ts_lex_modes[STATE_COUNT] = { 948 | [0] = {.lex_state = 0, .external_lex_state = 1}, 949 | [1] = {.lex_state = 0}, 950 | [2] = {.lex_state = 1}, 951 | [3] = {.lex_state = 3}, 952 | [4] = {.lex_state = 0}, 953 | [5] = {.lex_state = 0}, 954 | [6] = {.lex_state = 4}, 955 | [7] = {.lex_state = 4}, 956 | [8] = {.lex_state = 3}, 957 | [9] = {.lex_state = 5}, 958 | [10] = {.lex_state = 5}, 959 | [11] = {.lex_state = 5}, 960 | [12] = {.lex_state = 5}, 961 | [13] = {.lex_state = 2}, 962 | [14] = {.lex_state = 2}, 963 | [15] = {.lex_state = 2}, 964 | [16] = {.lex_state = 2}, 965 | [17] = {.lex_state = 2}, 966 | [18] = {.lex_state = 2}, 967 | [19] = {.lex_state = 2}, 968 | [20] = {.lex_state = 2}, 969 | [21] = {.lex_state = 2}, 970 | [22] = {.lex_state = 2}, 971 | [23] = {.lex_state = 0}, 972 | [24] = {.lex_state = 36}, 973 | [25] = {.lex_state = 0}, 974 | [26] = {.lex_state = 0}, 975 | [27] = {.lex_state = 0}, 976 | [28] = {.lex_state = 0}, 977 | [29] = {.lex_state = 0}, 978 | [30] = {.lex_state = 0}, 979 | [31] = {.lex_state = 0}, 980 | [32] = {.lex_state = 0}, 981 | [33] = {.lex_state = 0}, 982 | [34] = {.lex_state = 0}, 983 | [35] = {.lex_state = 0}, 984 | [36] = {.lex_state = 0}, 985 | [37] = {.lex_state = 0}, 986 | [38] = {.lex_state = 0}, 987 | [39] = {.lex_state = 0}, 988 | [40] = {.lex_state = 2}, 989 | [41] = {.lex_state = 0}, 990 | [42] = {.lex_state = 0}, 991 | [43] = {.lex_state = 0}, 992 | [44] = {.lex_state = 0}, 993 | [45] = {.lex_state = 0}, 994 | [46] = {.lex_state = 0}, 995 | [47] = {.lex_state = 0}, 996 | [48] = {.lex_state = 0}, 997 | [49] = {.lex_state = 0}, 998 | [50] = {.lex_state = 0}, 999 | [51] = {.lex_state = 0}, 1000 | [52] = {.lex_state = 0}, 1001 | [53] = {.lex_state = 0}, 1002 | [54] = {.lex_state = 0}, 1003 | [55] = {.lex_state = 0}, 1004 | [56] = {.lex_state = 0}, 1005 | [57] = {.lex_state = 2}, 1006 | [58] = {.lex_state = 2}, 1007 | [59] = {.lex_state = 2}, 1008 | [60] = {.lex_state = 2}, 1009 | [61] = {.lex_state = 2}, 1010 | [62] = {.lex_state = 2}, 1011 | [63] = {.lex_state = 2}, 1012 | [64] = {.lex_state = 2}, 1013 | [65] = {.lex_state = 2}, 1014 | [66] = {.lex_state = 2}, 1015 | [67] = {.lex_state = 2}, 1016 | [68] = {.lex_state = 2}, 1017 | [69] = {.lex_state = 2}, 1018 | [70] = {.lex_state = 2}, 1019 | [71] = {.lex_state = 0}, 1020 | [72] = {.lex_state = 2}, 1021 | [73] = {.lex_state = 2}, 1022 | [74] = {.lex_state = 0}, 1023 | }; 1024 | 1025 | enum { 1026 | ts_external_token_org_headline = 0, 1027 | }; 1028 | 1029 | static TSSymbol ts_external_scanner_symbol_map[EXTERNAL_TOKEN_COUNT] = { 1030 | [ts_external_token_org_headline] = sym_org_headline, 1031 | }; 1032 | 1033 | static bool ts_external_scanner_states[2][EXTERNAL_TOKEN_COUNT] = { 1034 | [1] = { 1035 | [ts_external_token_org_headline] = true, 1036 | }, 1037 | }; 1038 | 1039 | static uint16_t ts_parse_table[LARGE_STATE_COUNT][SYMBOL_COUNT] = { 1040 | [0] = { 1041 | [ts_builtin_sym_end] = ACTIONS(1), 1042 | [sym_stars] = ACTIONS(1), 1043 | [sym_priority] = ACTIONS(1), 1044 | [anon_sym_TODO] = ACTIONS(1), 1045 | [anon_sym_NEXT] = ACTIONS(1), 1046 | [anon_sym_DONE] = ACTIONS(1), 1047 | [anon_sym_WAITING] = ACTIONS(1), 1048 | [anon_sym_CANCELLED] = ACTIONS(1), 1049 | [sym_comment] = ACTIONS(1), 1050 | [anon_sym_COLON] = ACTIONS(1), 1051 | [sym_org_headline] = ACTIONS(1), 1052 | }, 1053 | [1] = { 1054 | [sym_org_file] = STATE(71), 1055 | [sym__section] = STATE(5), 1056 | [sym_headline] = STATE(5), 1057 | [aux_sym_org_file_repeat1] = STATE(5), 1058 | [ts_builtin_sym_end] = ACTIONS(3), 1059 | [sym_stars] = ACTIONS(5), 1060 | }, 1061 | [2] = { 1062 | [sym_todo] = STATE(3), 1063 | [sym_tags] = STATE(64), 1064 | [sym_line_ending] = ACTIONS(7), 1065 | [sym_priority] = ACTIONS(9), 1066 | [anon_sym_TODO] = ACTIONS(11), 1067 | [anon_sym_NEXT] = ACTIONS(11), 1068 | [anon_sym_DONE] = ACTIONS(11), 1069 | [anon_sym_WAITING] = ACTIONS(11), 1070 | [anon_sym_CANCELLED] = ACTIONS(11), 1071 | [sym_comment] = ACTIONS(13), 1072 | [anon_sym_COLON] = ACTIONS(15), 1073 | [sym_title] = ACTIONS(17), 1074 | }, 1075 | }; 1076 | 1077 | static uint16_t ts_small_parse_table[] = { 1078 | [0] = 6, 1079 | ACTIONS(15), 1, 1080 | anon_sym_COLON, 1081 | ACTIONS(19), 1, 1082 | sym_line_ending, 1083 | ACTIONS(21), 1, 1084 | sym_priority, 1085 | ACTIONS(23), 1, 1086 | sym_comment, 1087 | ACTIONS(25), 1, 1088 | sym_title, 1089 | STATE(72), 1, 1090 | sym_tags, 1091 | [19] = 3, 1092 | ACTIONS(27), 1, 1093 | ts_builtin_sym_end, 1094 | ACTIONS(29), 1, 1095 | sym_stars, 1096 | STATE(4), 3, 1097 | sym__section, 1098 | sym_headline, 1099 | aux_sym_org_file_repeat1, 1100 | [31] = 3, 1101 | ACTIONS(5), 1, 1102 | sym_stars, 1103 | ACTIONS(32), 1, 1104 | ts_builtin_sym_end, 1105 | STATE(4), 3, 1106 | sym__section, 1107 | sym_headline, 1108 | aux_sym_org_file_repeat1, 1109 | [43] = 5, 1110 | ACTIONS(15), 1, 1111 | anon_sym_COLON, 1112 | ACTIONS(34), 1, 1113 | sym_line_ending, 1114 | ACTIONS(36), 1, 1115 | sym_comment, 1116 | ACTIONS(38), 1, 1117 | sym_title, 1118 | STATE(63), 1, 1119 | sym_tags, 1120 | [59] = 5, 1121 | ACTIONS(15), 1, 1122 | anon_sym_COLON, 1123 | ACTIONS(40), 1, 1124 | sym_line_ending, 1125 | ACTIONS(42), 1, 1126 | sym_comment, 1127 | ACTIONS(44), 1, 1128 | sym_title, 1129 | STATE(66), 1, 1130 | sym_tags, 1131 | [75] = 1, 1132 | ACTIONS(46), 5, 1133 | sym_line_ending, 1134 | sym_priority, 1135 | sym_comment, 1136 | anon_sym_COLON, 1137 | sym_title, 1138 | [83] = 4, 1139 | ACTIONS(15), 1, 1140 | anon_sym_COLON, 1141 | ACTIONS(48), 1, 1142 | sym_line_ending, 1143 | ACTIONS(50), 1, 1144 | sym_title, 1145 | STATE(59), 1, 1146 | sym_tags, 1147 | [96] = 4, 1148 | ACTIONS(15), 1, 1149 | anon_sym_COLON, 1150 | ACTIONS(52), 1, 1151 | sym_line_ending, 1152 | ACTIONS(54), 1, 1153 | sym_title, 1154 | STATE(61), 1, 1155 | sym_tags, 1156 | [109] = 4, 1157 | ACTIONS(15), 1, 1158 | anon_sym_COLON, 1159 | ACTIONS(56), 1, 1160 | sym_line_ending, 1161 | ACTIONS(58), 1, 1162 | sym_title, 1163 | STATE(69), 1, 1164 | sym_tags, 1165 | [122] = 4, 1166 | ACTIONS(15), 1, 1167 | anon_sym_COLON, 1168 | ACTIONS(60), 1, 1169 | sym_line_ending, 1170 | ACTIONS(62), 1, 1171 | sym_title, 1172 | STATE(60), 1, 1173 | sym_tags, 1174 | [135] = 3, 1175 | ACTIONS(15), 1, 1176 | anon_sym_COLON, 1177 | ACTIONS(64), 1, 1178 | sym_line_ending, 1179 | STATE(65), 1, 1180 | sym_tags, 1181 | [145] = 3, 1182 | ACTIONS(66), 1, 1183 | sym_line_ending, 1184 | ACTIONS(68), 1, 1185 | sym_tag, 1186 | STATE(14), 1, 1187 | aux_sym_tags_repeat1, 1188 | [155] = 3, 1189 | ACTIONS(15), 1, 1190 | anon_sym_COLON, 1191 | ACTIONS(71), 1, 1192 | sym_line_ending, 1193 | STATE(70), 1, 1194 | sym_tags, 1195 | [165] = 3, 1196 | ACTIONS(15), 1, 1197 | anon_sym_COLON, 1198 | ACTIONS(73), 1, 1199 | sym_line_ending, 1200 | STATE(68), 1, 1201 | sym_tags, 1202 | [175] = 3, 1203 | ACTIONS(15), 1, 1204 | anon_sym_COLON, 1205 | ACTIONS(75), 1, 1206 | sym_line_ending, 1207 | STATE(73), 1, 1208 | sym_tags, 1209 | [185] = 3, 1210 | ACTIONS(15), 1, 1211 | anon_sym_COLON, 1212 | ACTIONS(77), 1, 1213 | sym_line_ending, 1214 | STATE(57), 1, 1215 | sym_tags, 1216 | [195] = 3, 1217 | ACTIONS(15), 1, 1218 | anon_sym_COLON, 1219 | ACTIONS(79), 1, 1220 | sym_line_ending, 1221 | STATE(67), 1, 1222 | sym_tags, 1223 | [205] = 3, 1224 | ACTIONS(15), 1, 1225 | anon_sym_COLON, 1226 | ACTIONS(81), 1, 1227 | sym_line_ending, 1228 | STATE(62), 1, 1229 | sym_tags, 1230 | [215] = 3, 1231 | ACTIONS(15), 1, 1232 | anon_sym_COLON, 1233 | ACTIONS(83), 1, 1234 | sym_line_ending, 1235 | STATE(58), 1, 1236 | sym_tags, 1237 | [225] = 3, 1238 | ACTIONS(85), 1, 1239 | sym_line_ending, 1240 | ACTIONS(87), 1, 1241 | sym_tag, 1242 | STATE(14), 1, 1243 | aux_sym_tags_repeat1, 1244 | [235] = 1, 1245 | ACTIONS(89), 2, 1246 | ts_builtin_sym_end, 1247 | sym_stars, 1248 | [240] = 2, 1249 | ACTIONS(91), 1, 1250 | sym_tag, 1251 | STATE(22), 1, 1252 | aux_sym_tags_repeat1, 1253 | [247] = 1, 1254 | ACTIONS(93), 2, 1255 | ts_builtin_sym_end, 1256 | sym_stars, 1257 | [252] = 1, 1258 | ACTIONS(95), 2, 1259 | ts_builtin_sym_end, 1260 | sym_stars, 1261 | [257] = 1, 1262 | ACTIONS(97), 2, 1263 | ts_builtin_sym_end, 1264 | sym_stars, 1265 | [262] = 1, 1266 | ACTIONS(99), 2, 1267 | ts_builtin_sym_end, 1268 | sym_stars, 1269 | [267] = 1, 1270 | ACTIONS(101), 2, 1271 | ts_builtin_sym_end, 1272 | sym_stars, 1273 | [272] = 1, 1274 | ACTIONS(103), 2, 1275 | ts_builtin_sym_end, 1276 | sym_stars, 1277 | [277] = 1, 1278 | ACTIONS(105), 2, 1279 | ts_builtin_sym_end, 1280 | sym_stars, 1281 | [282] = 1, 1282 | ACTIONS(107), 2, 1283 | ts_builtin_sym_end, 1284 | sym_stars, 1285 | [287] = 1, 1286 | ACTIONS(109), 2, 1287 | ts_builtin_sym_end, 1288 | sym_stars, 1289 | [292] = 1, 1290 | ACTIONS(111), 2, 1291 | ts_builtin_sym_end, 1292 | sym_stars, 1293 | [297] = 1, 1294 | ACTIONS(113), 2, 1295 | ts_builtin_sym_end, 1296 | sym_stars, 1297 | [302] = 1, 1298 | ACTIONS(115), 2, 1299 | ts_builtin_sym_end, 1300 | sym_stars, 1301 | [307] = 1, 1302 | ACTIONS(117), 2, 1303 | ts_builtin_sym_end, 1304 | sym_stars, 1305 | [312] = 1, 1306 | ACTIONS(119), 2, 1307 | ts_builtin_sym_end, 1308 | sym_stars, 1309 | [317] = 1, 1310 | ACTIONS(121), 2, 1311 | ts_builtin_sym_end, 1312 | sym_stars, 1313 | [322] = 2, 1314 | ACTIONS(66), 1, 1315 | sym_line_ending, 1316 | ACTIONS(123), 1, 1317 | sym_tag, 1318 | [329] = 1, 1319 | ACTIONS(125), 2, 1320 | ts_builtin_sym_end, 1321 | sym_stars, 1322 | [334] = 1, 1323 | ACTIONS(127), 2, 1324 | ts_builtin_sym_end, 1325 | sym_stars, 1326 | [339] = 1, 1327 | ACTIONS(129), 2, 1328 | ts_builtin_sym_end, 1329 | sym_stars, 1330 | [344] = 1, 1331 | ACTIONS(131), 2, 1332 | ts_builtin_sym_end, 1333 | sym_stars, 1334 | [349] = 1, 1335 | ACTIONS(133), 2, 1336 | ts_builtin_sym_end, 1337 | sym_stars, 1338 | [354] = 1, 1339 | ACTIONS(135), 2, 1340 | ts_builtin_sym_end, 1341 | sym_stars, 1342 | [359] = 1, 1343 | ACTIONS(137), 2, 1344 | ts_builtin_sym_end, 1345 | sym_stars, 1346 | [364] = 1, 1347 | ACTIONS(139), 2, 1348 | ts_builtin_sym_end, 1349 | sym_stars, 1350 | [369] = 1, 1351 | ACTIONS(141), 2, 1352 | ts_builtin_sym_end, 1353 | sym_stars, 1354 | [374] = 1, 1355 | ACTIONS(143), 2, 1356 | ts_builtin_sym_end, 1357 | sym_stars, 1358 | [379] = 1, 1359 | ACTIONS(145), 2, 1360 | ts_builtin_sym_end, 1361 | sym_stars, 1362 | [384] = 1, 1363 | ACTIONS(147), 2, 1364 | ts_builtin_sym_end, 1365 | sym_stars, 1366 | [389] = 1, 1367 | ACTIONS(149), 2, 1368 | ts_builtin_sym_end, 1369 | sym_stars, 1370 | [394] = 1, 1371 | ACTIONS(151), 2, 1372 | ts_builtin_sym_end, 1373 | sym_stars, 1374 | [399] = 1, 1375 | ACTIONS(153), 2, 1376 | ts_builtin_sym_end, 1377 | sym_stars, 1378 | [404] = 1, 1379 | ACTIONS(155), 2, 1380 | ts_builtin_sym_end, 1381 | sym_stars, 1382 | [409] = 1, 1383 | ACTIONS(157), 1, 1384 | sym_line_ending, 1385 | [413] = 1, 1386 | ACTIONS(159), 1, 1387 | sym_line_ending, 1388 | [417] = 1, 1389 | ACTIONS(161), 1, 1390 | sym_line_ending, 1391 | [421] = 1, 1392 | ACTIONS(163), 1, 1393 | sym_line_ending, 1394 | [425] = 1, 1395 | ACTIONS(165), 1, 1396 | sym_line_ending, 1397 | [429] = 1, 1398 | ACTIONS(167), 1, 1399 | sym_line_ending, 1400 | [433] = 1, 1401 | ACTIONS(169), 1, 1402 | sym_line_ending, 1403 | [437] = 1, 1404 | ACTIONS(171), 1, 1405 | sym_line_ending, 1406 | [441] = 1, 1407 | ACTIONS(173), 1, 1408 | sym_line_ending, 1409 | [445] = 1, 1410 | ACTIONS(175), 1, 1411 | sym_line_ending, 1412 | [449] = 1, 1413 | ACTIONS(177), 1, 1414 | sym_line_ending, 1415 | [453] = 1, 1416 | ACTIONS(179), 1, 1417 | sym_line_ending, 1418 | [457] = 1, 1419 | ACTIONS(181), 1, 1420 | sym_line_ending, 1421 | [461] = 1, 1422 | ACTIONS(183), 1, 1423 | sym_line_ending, 1424 | [465] = 1, 1425 | ACTIONS(185), 1, 1426 | ts_builtin_sym_end, 1427 | [469] = 1, 1428 | ACTIONS(187), 1, 1429 | sym_line_ending, 1430 | [473] = 1, 1431 | ACTIONS(189), 1, 1432 | sym_line_ending, 1433 | [477] = 1, 1434 | ACTIONS(191), 1, 1435 | anon_sym_COLON, 1436 | }; 1437 | 1438 | static uint32_t ts_small_parse_table_map[] = { 1439 | [SMALL_STATE(3)] = 0, 1440 | [SMALL_STATE(4)] = 19, 1441 | [SMALL_STATE(5)] = 31, 1442 | [SMALL_STATE(6)] = 43, 1443 | [SMALL_STATE(7)] = 59, 1444 | [SMALL_STATE(8)] = 75, 1445 | [SMALL_STATE(9)] = 83, 1446 | [SMALL_STATE(10)] = 96, 1447 | [SMALL_STATE(11)] = 109, 1448 | [SMALL_STATE(12)] = 122, 1449 | [SMALL_STATE(13)] = 135, 1450 | [SMALL_STATE(14)] = 145, 1451 | [SMALL_STATE(15)] = 155, 1452 | [SMALL_STATE(16)] = 165, 1453 | [SMALL_STATE(17)] = 175, 1454 | [SMALL_STATE(18)] = 185, 1455 | [SMALL_STATE(19)] = 195, 1456 | [SMALL_STATE(20)] = 205, 1457 | [SMALL_STATE(21)] = 215, 1458 | [SMALL_STATE(22)] = 225, 1459 | [SMALL_STATE(23)] = 235, 1460 | [SMALL_STATE(24)] = 240, 1461 | [SMALL_STATE(25)] = 247, 1462 | [SMALL_STATE(26)] = 252, 1463 | [SMALL_STATE(27)] = 257, 1464 | [SMALL_STATE(28)] = 262, 1465 | [SMALL_STATE(29)] = 267, 1466 | [SMALL_STATE(30)] = 272, 1467 | [SMALL_STATE(31)] = 277, 1468 | [SMALL_STATE(32)] = 282, 1469 | [SMALL_STATE(33)] = 287, 1470 | [SMALL_STATE(34)] = 292, 1471 | [SMALL_STATE(35)] = 297, 1472 | [SMALL_STATE(36)] = 302, 1473 | [SMALL_STATE(37)] = 307, 1474 | [SMALL_STATE(38)] = 312, 1475 | [SMALL_STATE(39)] = 317, 1476 | [SMALL_STATE(40)] = 322, 1477 | [SMALL_STATE(41)] = 329, 1478 | [SMALL_STATE(42)] = 334, 1479 | [SMALL_STATE(43)] = 339, 1480 | [SMALL_STATE(44)] = 344, 1481 | [SMALL_STATE(45)] = 349, 1482 | [SMALL_STATE(46)] = 354, 1483 | [SMALL_STATE(47)] = 359, 1484 | [SMALL_STATE(48)] = 364, 1485 | [SMALL_STATE(49)] = 369, 1486 | [SMALL_STATE(50)] = 374, 1487 | [SMALL_STATE(51)] = 379, 1488 | [SMALL_STATE(52)] = 384, 1489 | [SMALL_STATE(53)] = 389, 1490 | [SMALL_STATE(54)] = 394, 1491 | [SMALL_STATE(55)] = 399, 1492 | [SMALL_STATE(56)] = 404, 1493 | [SMALL_STATE(57)] = 409, 1494 | [SMALL_STATE(58)] = 413, 1495 | [SMALL_STATE(59)] = 417, 1496 | [SMALL_STATE(60)] = 421, 1497 | [SMALL_STATE(61)] = 425, 1498 | [SMALL_STATE(62)] = 429, 1499 | [SMALL_STATE(63)] = 433, 1500 | [SMALL_STATE(64)] = 437, 1501 | [SMALL_STATE(65)] = 441, 1502 | [SMALL_STATE(66)] = 445, 1503 | [SMALL_STATE(67)] = 449, 1504 | [SMALL_STATE(68)] = 453, 1505 | [SMALL_STATE(69)] = 457, 1506 | [SMALL_STATE(70)] = 461, 1507 | [SMALL_STATE(71)] = 465, 1508 | [SMALL_STATE(72)] = 469, 1509 | [SMALL_STATE(73)] = 473, 1510 | [SMALL_STATE(74)] = 477, 1511 | }; 1512 | 1513 | static TSParseActionEntry ts_parse_actions[] = { 1514 | [0] = {.entry = {.count = 0, .reusable = false}}, 1515 | [1] = {.entry = {.count = 1, .reusable = false}}, RECOVER(), 1516 | [3] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_org_file, 0), 1517 | [5] = {.entry = {.count = 1, .reusable = true}}, SHIFT(2), 1518 | [7] = {.entry = {.count = 1, .reusable = false}}, SHIFT(49), 1519 | [9] = {.entry = {.count = 1, .reusable = false}}, SHIFT(7), 1520 | [11] = {.entry = {.count = 1, .reusable = false}}, SHIFT(8), 1521 | [13] = {.entry = {.count = 1, .reusable = false}}, SHIFT(10), 1522 | [15] = {.entry = {.count = 1, .reusable = false}}, SHIFT(24), 1523 | [17] = {.entry = {.count = 1, .reusable = false}}, SHIFT(17), 1524 | [19] = {.entry = {.count = 1, .reusable = false}}, SHIFT(28), 1525 | [21] = {.entry = {.count = 1, .reusable = false}}, SHIFT(6), 1526 | [23] = {.entry = {.count = 1, .reusable = false}}, SHIFT(9), 1527 | [25] = {.entry = {.count = 1, .reusable = false}}, SHIFT(21), 1528 | [27] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_org_file_repeat1, 2), 1529 | [29] = {.entry = {.count = 2, .reusable = true}}, REDUCE(aux_sym_org_file_repeat1, 2), SHIFT_REPEAT(2), 1530 | [32] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_org_file, 1), 1531 | [34] = {.entry = {.count = 1, .reusable = false}}, SHIFT(43), 1532 | [36] = {.entry = {.count = 1, .reusable = false}}, SHIFT(12), 1533 | [38] = {.entry = {.count = 1, .reusable = false}}, SHIFT(20), 1534 | [40] = {.entry = {.count = 1, .reusable = false}}, SHIFT(44), 1535 | [42] = {.entry = {.count = 1, .reusable = false}}, SHIFT(11), 1536 | [44] = {.entry = {.count = 1, .reusable = false}}, SHIFT(16), 1537 | [46] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_todo, 1), 1538 | [48] = {.entry = {.count = 1, .reusable = false}}, SHIFT(47), 1539 | [50] = {.entry = {.count = 1, .reusable = false}}, SHIFT(13), 1540 | [52] = {.entry = {.count = 1, .reusable = false}}, SHIFT(37), 1541 | [54] = {.entry = {.count = 1, .reusable = false}}, SHIFT(19), 1542 | [56] = {.entry = {.count = 1, .reusable = false}}, SHIFT(31), 1543 | [58] = {.entry = {.count = 1, .reusable = false}}, SHIFT(18), 1544 | [60] = {.entry = {.count = 1, .reusable = false}}, SHIFT(51), 1545 | [62] = {.entry = {.count = 1, .reusable = false}}, SHIFT(15), 1546 | [64] = {.entry = {.count = 1, .reusable = true}}, SHIFT(45), 1547 | [66] = {.entry = {.count = 1, .reusable = true}}, REDUCE(aux_sym_tags_repeat1, 2), 1548 | [68] = {.entry = {.count = 2, .reusable = false}}, REDUCE(aux_sym_tags_repeat1, 2), SHIFT_REPEAT(74), 1549 | [71] = {.entry = {.count = 1, .reusable = true}}, SHIFT(33), 1550 | [73] = {.entry = {.count = 1, .reusable = true}}, SHIFT(34), 1551 | [75] = {.entry = {.count = 1, .reusable = true}}, SHIFT(26), 1552 | [77] = {.entry = {.count = 1, .reusable = true}}, SHIFT(53), 1553 | [79] = {.entry = {.count = 1, .reusable = true}}, SHIFT(23), 1554 | [81] = {.entry = {.count = 1, .reusable = true}}, SHIFT(48), 1555 | [83] = {.entry = {.count = 1, .reusable = true}}, SHIFT(50), 1556 | [85] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_tags, 2), 1557 | [87] = {.entry = {.count = 1, .reusable = false}}, SHIFT(74), 1558 | [89] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 4, .production_id = 10), 1559 | [91] = {.entry = {.count = 1, .reusable = true}}, SHIFT(74), 1560 | [93] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 7, .production_id = 32), 1561 | [95] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 3, .production_id = 4), 1562 | [97] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 6, .production_id = 31), 1563 | [99] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 3, .production_id = 5), 1564 | [101] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 6, .production_id = 30), 1565 | [103] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 3, .production_id = 6), 1566 | [105] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 4, .production_id = 7), 1567 | [107] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 6, .production_id = 29), 1568 | [109] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 6, .production_id = 28), 1569 | [111] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 4, .production_id = 8), 1570 | [113] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 6, .production_id = 27), 1571 | [115] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 4, .production_id = 9), 1572 | [117] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 3, .production_id = 3), 1573 | [119] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 5, .production_id = 26), 1574 | [121] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 4, .production_id = 11), 1575 | [123] = {.entry = {.count = 1, .reusable = false}}, REDUCE(aux_sym_tags_repeat1, 2), 1576 | [125] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 5, .production_id = 25), 1577 | [127] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 4, .production_id = 12), 1578 | [129] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 4, .production_id = 13), 1579 | [131] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 3, .production_id = 2), 1580 | [133] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 5, .production_id = 24), 1581 | [135] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 5, .production_id = 23), 1582 | [137] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 4, .production_id = 14), 1583 | [139] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 5, .production_id = 22), 1584 | [141] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 2, .production_id = 1), 1585 | [143] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 4, .production_id = 15), 1586 | [145] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 5, .production_id = 21), 1587 | [147] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 4, .production_id = 16), 1588 | [149] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 5, .production_id = 17), 1589 | [151] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 5, .production_id = 20), 1590 | [153] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 5, .production_id = 18), 1591 | [155] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_headline, 5, .production_id = 19), 1592 | [157] = {.entry = {.count = 1, .reusable = true}}, SHIFT(35), 1593 | [159] = {.entry = {.count = 1, .reusable = true}}, SHIFT(38), 1594 | [161] = {.entry = {.count = 1, .reusable = true}}, SHIFT(41), 1595 | [163] = {.entry = {.count = 1, .reusable = true}}, SHIFT(32), 1596 | [165] = {.entry = {.count = 1, .reusable = true}}, SHIFT(39), 1597 | [167] = {.entry = {.count = 1, .reusable = true}}, SHIFT(29), 1598 | [169] = {.entry = {.count = 1, .reusable = true}}, SHIFT(46), 1599 | [171] = {.entry = {.count = 1, .reusable = true}}, SHIFT(30), 1600 | [173] = {.entry = {.count = 1, .reusable = true}}, SHIFT(27), 1601 | [175] = {.entry = {.count = 1, .reusable = true}}, SHIFT(36), 1602 | [177] = {.entry = {.count = 1, .reusable = true}}, SHIFT(54), 1603 | [179] = {.entry = {.count = 1, .reusable = true}}, SHIFT(56), 1604 | [181] = {.entry = {.count = 1, .reusable = true}}, SHIFT(55), 1605 | [183] = {.entry = {.count = 1, .reusable = true}}, SHIFT(25), 1606 | [185] = {.entry = {.count = 1, .reusable = true}}, ACCEPT_INPUT(), 1607 | [187] = {.entry = {.count = 1, .reusable = true}}, SHIFT(52), 1608 | [189] = {.entry = {.count = 1, .reusable = true}}, SHIFT(42), 1609 | [191] = {.entry = {.count = 1, .reusable = true}}, SHIFT(40), 1610 | }; 1611 | 1612 | #ifdef __cplusplus 1613 | extern "C" { 1614 | #endif 1615 | void *tree_sitter_org_external_scanner_create(void); 1616 | void tree_sitter_org_external_scanner_destroy(void *); 1617 | bool tree_sitter_org_external_scanner_scan(void *, TSLexer *, const bool *); 1618 | unsigned tree_sitter_org_external_scanner_serialize(void *, char *); 1619 | void tree_sitter_org_external_scanner_deserialize(void *, const char *, unsigned); 1620 | 1621 | #ifdef _WIN32 1622 | #define extern __declspec(dllexport) 1623 | #endif 1624 | 1625 | extern const TSLanguage *tree_sitter_org(void) { 1626 | static TSLanguage language = { 1627 | .version = LANGUAGE_VERSION, 1628 | .symbol_count = SYMBOL_COUNT, 1629 | .alias_count = ALIAS_COUNT, 1630 | .token_count = TOKEN_COUNT, 1631 | .large_state_count = LARGE_STATE_COUNT, 1632 | .symbol_metadata = ts_symbol_metadata, 1633 | .parse_table = (const unsigned short *)ts_parse_table, 1634 | .small_parse_table = (const uint16_t *)ts_small_parse_table, 1635 | .small_parse_table_map = (const uint32_t *)ts_small_parse_table_map, 1636 | .parse_actions = ts_parse_actions, 1637 | .lex_modes = ts_lex_modes, 1638 | .symbol_names = ts_symbol_names, 1639 | .public_symbol_map = ts_symbol_map, 1640 | .alias_sequences = (const TSSymbol *)ts_alias_sequences, 1641 | .field_count = FIELD_COUNT, 1642 | .field_names = ts_field_names, 1643 | .field_map_slices = (const TSFieldMapSlice *)ts_field_map_slices, 1644 | .field_map_entries = (const TSFieldMapEntry *)ts_field_map_entries, 1645 | .max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH, 1646 | .lex_fn = ts_lex, 1647 | .external_token_count = EXTERNAL_TOKEN_COUNT, 1648 | .external_scanner = { 1649 | (const bool *)ts_external_scanner_states, 1650 | ts_external_scanner_symbol_map, 1651 | tree_sitter_org_external_scanner_create, 1652 | tree_sitter_org_external_scanner_destroy, 1653 | tree_sitter_org_external_scanner_scan, 1654 | tree_sitter_org_external_scanner_serialize, 1655 | tree_sitter_org_external_scanner_deserialize, 1656 | }, 1657 | }; 1658 | return &language; 1659 | } 1660 | #ifdef __cplusplus 1661 | } 1662 | #endif 1663 | -------------------------------------------------------------------------------- /src/scanner.cc: -------------------------------------------------------------------------------- 1 | #include "tree_sitter/parser.h" 2 | #include 3 | 4 | static const char* ORG_TODO_KEYWORDS_1[] = {"TODO", "DONE"}; 5 | 6 | enum TokenType { 7 | ORG_HEADLINE, 8 | }; 9 | 10 | 11 | class Scanner { 12 | public: 13 | /// Serialize the scanner to bytes 14 | /// Return the count of bytes written 15 | unsigned int serialize(char* buffer) const; 16 | friend std::unique_ptr deserialize(const char* buffer, unsigned int length); 17 | /// Scan the stream to find the correct token type 18 | bool scan(TSLexer* lexer, const bool*valid_symbols); 19 | }; 20 | 21 | extern "C" { 22 | void *tree_sitter_org_external_scanner_create(); 23 | void tree_sitter_org_external_scanner_destroy(void *payload); 24 | unsigned tree_sitter_org_external_scanner_serialize(void *payload, 25 | char *buffer); 26 | void tree_sitter_org_external_scanner_deserialize(void *payload, 27 | const char *buffer, 28 | unsigned length); 29 | bool tree_sitter_org_external_scanner_scan(void *payload, TSLexer *lexer, 30 | const bool *valid_symbols); 31 | } 32 | 33 | unsigned int Scanner::serialize(char *buffer) const { 34 | return 0; 35 | } 36 | 37 | bool Scanner::scan(TSLexer *lexer, const bool *valid_symbols) { 38 | return false; 39 | } 40 | 41 | /// Deserialize a buffer and modifies the current scanner to fit this 42 | std::unique_ptr deserialize(const char* buffer, unsigned int length) { 43 | return std::make_unique(); 44 | } 45 | 46 | 47 | void *tree_sitter_org_external_scanner_create() { return nullptr; } 48 | 49 | void tree_sitter_org_external_scanner_destroy(void *payload) { 50 | auto scanner = reinterpret_cast(payload); 51 | delete scanner; 52 | } 53 | 54 | unsigned tree_sitter_org_external_scanner_serialize(void *payload, 55 | char *buffer) { 56 | auto scanner = reinterpret_cast(payload); 57 | auto size = scanner->serialize(buffer); 58 | return size; 59 | } 60 | 61 | void tree_sitter_org_external_scanner_deserialize(void *payload, 62 | const char *buffer, 63 | unsigned length) { 64 | auto scanner = deserialize(buffer, length); 65 | } 66 | 67 | bool tree_sitter_org_external_scanner_scan(void *payload, TSLexer *lexer, 68 | const bool *valid_symbols) { 69 | auto scanner = reinterpret_cast(payload); 70 | return scanner->scan(lexer, valid_symbols); 71 | } 72 | -------------------------------------------------------------------------------- /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 | #ifndef TREE_SITTER_API_H_ 17 | typedef uint16_t TSSymbol; 18 | typedef uint16_t TSFieldId; 19 | typedef struct TSLanguage TSLanguage; 20 | #endif 21 | 22 | typedef struct { 23 | TSFieldId field_id; 24 | uint8_t child_index; 25 | bool inherited; 26 | } TSFieldMapEntry; 27 | 28 | typedef struct { 29 | uint16_t index; 30 | uint16_t length; 31 | } TSFieldMapSlice; 32 | 33 | typedef uint16_t TSStateId; 34 | 35 | typedef struct { 36 | bool visible : 1; 37 | bool named : 1; 38 | } TSSymbolMetadata; 39 | 40 | typedef struct TSLexer TSLexer; 41 | 42 | struct TSLexer { 43 | int32_t lookahead; 44 | TSSymbol result_symbol; 45 | void (*advance)(TSLexer *, bool); 46 | void (*mark_end)(TSLexer *); 47 | uint32_t (*get_column)(TSLexer *); 48 | bool (*is_at_included_range_start)(const TSLexer *); 49 | bool (*eof)(const TSLexer *); 50 | }; 51 | 52 | typedef enum { 53 | TSParseActionTypeShift, 54 | TSParseActionTypeReduce, 55 | TSParseActionTypeAccept, 56 | TSParseActionTypeRecover, 57 | } TSParseActionType; 58 | 59 | typedef struct { 60 | union { 61 | struct { 62 | TSStateId state; 63 | bool extra : 1; 64 | bool repetition : 1; 65 | } shift; 66 | struct { 67 | TSSymbol symbol; 68 | int16_t dynamic_precedence; 69 | uint8_t child_count; 70 | uint8_t production_id; 71 | } reduce; 72 | } params; 73 | TSParseActionType type : 4; 74 | } TSParseAction; 75 | 76 | typedef struct { 77 | uint16_t lex_state; 78 | uint16_t external_lex_state; 79 | } TSLexMode; 80 | 81 | typedef union { 82 | TSParseAction action; 83 | struct { 84 | uint8_t count; 85 | bool reusable : 1; 86 | } entry; 87 | } TSParseActionEntry; 88 | 89 | struct TSLanguage { 90 | uint32_t version; 91 | uint32_t symbol_count; 92 | uint32_t alias_count; 93 | uint32_t token_count; 94 | uint32_t external_token_count; 95 | const char **symbol_names; 96 | const TSSymbolMetadata *symbol_metadata; 97 | const uint16_t *parse_table; 98 | const TSParseActionEntry *parse_actions; 99 | const TSLexMode *lex_modes; 100 | const TSSymbol *alias_sequences; 101 | uint16_t max_alias_sequence_length; 102 | bool (*lex_fn)(TSLexer *, TSStateId); 103 | bool (*keyword_lex_fn)(TSLexer *, TSStateId); 104 | TSSymbol keyword_capture_token; 105 | struct { 106 | const bool *states; 107 | const TSSymbol *symbol_map; 108 | void *(*create)(void); 109 | void (*destroy)(void *); 110 | bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist); 111 | unsigned (*serialize)(void *, char *); 112 | void (*deserialize)(void *, const char *, unsigned); 113 | } external_scanner; 114 | uint32_t field_count; 115 | const TSFieldMapSlice *field_map_slices; 116 | const TSFieldMapEntry *field_map_entries; 117 | const char **field_names; 118 | uint32_t large_state_count; 119 | const uint16_t *small_parse_table; 120 | const uint32_t *small_parse_table_map; 121 | const TSSymbol *public_symbol_map; 122 | }; 123 | 124 | /* 125 | * Lexer Macros 126 | */ 127 | 128 | #define START_LEXER() \ 129 | bool result = false; \ 130 | bool skip = false; \ 131 | bool eof = false; \ 132 | int32_t lookahead; \ 133 | goto start; \ 134 | next_state: \ 135 | lexer->advance(lexer, skip); \ 136 | start: \ 137 | skip = false; \ 138 | lookahead = lexer->lookahead; 139 | 140 | #define ADVANCE(state_value) \ 141 | { \ 142 | state = state_value; \ 143 | goto next_state; \ 144 | } 145 | 146 | #define SKIP(state_value) \ 147 | { \ 148 | skip = true; \ 149 | state = state_value; \ 150 | goto next_state; \ 151 | } 152 | 153 | #define ACCEPT_TOKEN(symbol_value) \ 154 | result = true; \ 155 | lexer->result_symbol = symbol_value; \ 156 | lexer->mark_end(lexer); 157 | 158 | #define END_STATE() return result; 159 | 160 | /* 161 | * Parse Table Macros 162 | */ 163 | 164 | #define SMALL_STATE(id) id - LARGE_STATE_COUNT 165 | 166 | #define STATE(id) id 167 | 168 | #define ACTIONS(id) id 169 | 170 | #define SHIFT(state_value) \ 171 | { \ 172 | { \ 173 | .params = { \ 174 | .shift = { \ 175 | .state = state_value \ 176 | } \ 177 | }, \ 178 | .type = TSParseActionTypeShift \ 179 | } \ 180 | } 181 | 182 | #define SHIFT_REPEAT(state_value) \ 183 | { \ 184 | { \ 185 | .params = { \ 186 | .shift = { \ 187 | .state = state_value, \ 188 | .repetition = true \ 189 | } \ 190 | }, \ 191 | .type = TSParseActionTypeShift \ 192 | } \ 193 | } 194 | 195 | #define RECOVER() \ 196 | { \ 197 | { .type = TSParseActionTypeRecover } \ 198 | } 199 | 200 | #define SHIFT_EXTRA() \ 201 | { \ 202 | { \ 203 | .params = { \ 204 | .shift = { \ 205 | .extra = true \ 206 | } \ 207 | }, \ 208 | .type = TSParseActionTypeShift \ 209 | } \ 210 | } 211 | 212 | #define REDUCE(symbol_val, child_count_val, ...) \ 213 | { \ 214 | { \ 215 | .params = { \ 216 | .reduce = { \ 217 | .symbol = symbol_val, \ 218 | .child_count = child_count_val, \ 219 | __VA_ARGS__ \ 220 | }, \ 221 | }, \ 222 | .type = TSParseActionTypeReduce \ 223 | } \ 224 | } 225 | 226 | #define ACCEPT_INPUT() \ 227 | { \ 228 | { .type = TSParseActionTypeAccept } \ 229 | } 230 | 231 | #ifdef __cplusplus 232 | } 233 | #endif 234 | 235 | #endif // TREE_SITTER_PARSER_H_ 236 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | scratch.org 2 | -------------------------------------------------------------------------------- /test/corpus/headline.txt: -------------------------------------------------------------------------------- 1 | =========== 2 | Simple star 3 | =========== 4 | 5 | * 6 | 7 | --- 8 | 9 | (org_file 10 | (headline 11 | (stars) 12 | (line_ending))) 13 | 14 | 15 | ================ 16 | Oneword Headline 17 | ================ 18 | 19 | * First 20 | 21 | --- 22 | 23 | (org_file 24 | (headline 25 | (stars) 26 | (title) 27 | (line_ending))) 28 | 29 | 30 | =============== 31 | Simple Headline 32 | =============== 33 | 34 | * First level ttitle 35 | 36 | --- 37 | 38 | (org_file 39 | (headline 40 | (stars) 41 | (title) 42 | (line_ending))) 43 | 44 | 45 | =========== 46 | Simple TODO 47 | =========== 48 | 49 | ** TODO 50 | 51 | --- 52 | 53 | (org_file 54 | (headline 55 | (stars) 56 | (todo) 57 | (line_ending))) 58 | 59 | 60 | ====================== 61 | Simple TODO with title 62 | ====================== 63 | 64 | ** TODO Pass this test 65 | 66 | --- 67 | 68 | (org_file 69 | (headline 70 | (stars) 71 | (todo) 72 | (title) 73 | (line_ending))) 74 | 75 | 76 | ================ 77 | Complex Headline 78 | ================ 79 | 80 | *** DONE [#C] COMMENT Chaussette :#tag:ARCHIVE:test%:tag2: 81 | 82 | --- 83 | 84 | (org_file 85 | (headline 86 | (stars) 87 | (todo) 88 | (priority) 89 | (comment) 90 | (title) 91 | (tags (tag tag tag tag)) 92 | (line_ending))) 93 | 94 | =============== 95 | Nested sections 96 | =============== 97 | 98 | * Level 1 heading 99 | A little text to test ownership in level 1 100 | ** Level 2 heading 101 | This text should belong to level 2 102 | 103 | --- 104 | 105 | (org_file 106 | (headline 107 | (stars) 108 | (title) 109 | (line_ending) 110 | 111 | (section 112 | (paragraph) 113 | (headline 114 | (stars) 115 | (title) 116 | (line_ending) 117 | 118 | (section 119 | (paragraph)))))) 120 | 121 | ======================= 122 | Nested complex sections 123 | ======================= 124 | 125 | 126 | * TODO [#B] COMMENT Level 1 commented 127 | 128 | This heading should be considered as commented 129 | 130 | ** DONE [#A] Level 2 tagged :bare:#tag:other_tag:third@:okay%: 131 | 132 | This heading should have a few tags 133 | 134 | --- 135 | (org_file 136 | (headline 137 | (stars) 138 | (todo) 139 | (priority) 140 | (comment) 141 | (title) 142 | (line_ending) 143 | 144 | (section 145 | (paragraph) 146 | (headline 147 | (stars) 148 | (todo) 149 | (priority) 150 | (title) 151 | (tags (tag tag tag tag tag)) 152 | (line_ending) 153 | 154 | (section 155 | (paragraph)))))) 156 | 157 | =============== 158 | Skipping Levels 159 | =============== 160 | 161 | * Level 1 heading 162 | 163 | **** Skipping a level 164 | This text should be in level 4 heading 165 | 166 | ** Level 2 heading 167 | This should belong to level 1 heading 168 | 169 | --- 170 | 171 | (org_file 172 | (headline 173 | (stars) 174 | (title) 175 | (line_ending) 176 | (section 177 | (headline 178 | (stars) 179 | (title) 180 | (line_ending) 181 | (section 182 | (paragraph))) 183 | 184 | (headline 185 | (stars) 186 | (title) 187 | (line_ending) 188 | (section 189 | (paragraph)))))) 190 | 191 | ================== 192 | Indent Dedent text 193 | ================== 194 | 195 | * Level 1 heading 196 | ** Indent then dedent is still in level 2 197 | This is indented text and belongs to level 2 198 | 199 | This is dedented text and belongs to level 2 200 | 201 | --- 202 | 203 | (org_file 204 | (headline 205 | (stars) 206 | (title) 207 | (line_ending) 208 | (section 209 | (headline 210 | (stars) 211 | (title) 212 | (line_ending) 213 | (section 214 | (paragraph paragraph)))))) 215 | 216 | --------------------------------------------------------------------------------