├── Coco.ebnf ├── LICENSE ├── README.md ├── cfront-3.ebnf ├── grammars.db.sql ├── haxe.ebnf ├── json2ebnf-lua.js ├── json2ebnf.html ├── json2ebnf.js ├── json2sql.js ├── parser_c_preproc.ebnf ├── ruby ├── ruby-jruby.ebnf ├── ruby-librubyparser.ebnf ├── ruby-mruby.ebnf ├── ruby-parser.y.ebnf ├── ruby-sorbete.ebnf └── ruby-truffleruby.ebnf ├── scanner_c_preproc.ebnf ├── tree-sitter-abnf.ebnf ├── tree-sitter-ada.ebnf ├── tree-sitter-agda.ebnf ├── tree-sitter-bash.ebnf ├── tree-sitter-beancount.ebnf ├── tree-sitter-beancount2.ebnf ├── tree-sitter-c-dad.ebnf ├── tree-sitter-c-sharp.ebnf ├── tree-sitter-c.ebnf ├── tree-sitter-c3.ebnf ├── tree-sitter-carp.ebnf ├── tree-sitter-clojure.ebnf ├── tree-sitter-cmake.ebnf ├── tree-sitter-commonlisp.ebnf ├── tree-sitter-cpp-dad.ebnf ├── tree-sitter-cpp.ebnf ├── tree-sitter-css.ebnf ├── tree-sitter-cuda.ebnf ├── tree-sitter-d.ebnf ├── tree-sitter-dart.ebnf ├── tree-sitter-dockerfile.ebnf ├── tree-sitter-dot.ebnf ├── tree-sitter-elisp.ebnf ├── tree-sitter-elixir.ebnf ├── tree-sitter-elm.ebnf ├── tree-sitter-embedded-template.ebnf ├── tree-sitter-eno.ebnf ├── tree-sitter-erlang.ebnf ├── tree-sitter-fennel.ebnf ├── tree-sitter-fortran.ebnf ├── tree-sitter-generate.js ├── tree-sitter-glsl.ebnf ├── tree-sitter-go.ebnf ├── tree-sitter-graphql.ebnf ├── tree-sitter-hack.ebnf ├── tree-sitter-hare.ebnf ├── tree-sitter-haskel.ebnf ├── tree-sitter-haskell.ebnf ├── tree-sitter-hcl.ebnf ├── tree-sitter-html.ebnf ├── tree-sitter-janet.ebnf ├── tree-sitter-java.ebnf ├── tree-sitter-javascript.ebnf ├── tree-sitter-jsdoc.ebnf ├── tree-sitter-json5.ebnf ├── tree-sitter-julia.ebnf ├── tree-sitter-kotlin.ebnf ├── tree-sitter-lbnf.ebnf ├── tree-sitter-ld.ebnf ├── tree-sitter-lean.ebnf ├── tree-sitter-ledger.ebnf ├── tree-sitter-linkerscript.ebnf ├── tree-sitter-lp.ebnf ├── tree-sitter-lua.ebnf ├── tree-sitter-make.ebnf ├── tree-sitter-markdown.ebnf ├── tree-sitter-menhir.ebnf ├── tree-sitter-minizinc.ebnf ├── tree-sitter-nim.ebnf ├── tree-sitter-nim2.ebnf ├── tree-sitter-nix.ebnf ├── tree-sitter-objc.ebnf ├── tree-sitter-ocaml.ebnf ├── tree-sitter-perl.ebnf ├── tree-sitter-php.ebnf ├── tree-sitter-postgresql.ebnf ├── tree-sitter-powershell.ebnf ├── tree-sitter-prolog.ebnf ├── tree-sitter-python.ebnf ├── tree-sitter-ql.ebnf ├── tree-sitter-quakec.ebnf ├── tree-sitter-r.ebnf ├── tree-sitter-reason.ebnf ├── tree-sitter-regex.ebnf ├── tree-sitter-ruby.ebnf ├── tree-sitter-rust.ebnf ├── tree-sitter-scala.ebnf ├── tree-sitter-scheme.ebnf ├── tree-sitter-sexp.ebnf ├── tree-sitter-sml.ebnf ├── tree-sitter-souffle.ebnf ├── tree-sitter-sourcepawn.ebnf ├── tree-sitter-sparql.ebnf ├── tree-sitter-sql.ebnf ├── tree-sitter-sqlite.ebnf ├── tree-sitter-stan.ebnf ├── tree-sitter-svelte.ebnf ├── tree-sitter-swift.ebnf ├── tree-sitter-systemrdl.ebnf ├── tree-sitter-tablegen.ebnf ├── tree-sitter-teal.ebnf ├── tree-sitter-tlaplus.ebnf ├── tree-sitter-toml.ebnf ├── tree-sitter-turtle.ebnf ├── tree-sitter-typescript.ebnf ├── tree-sitter-v.ebnf ├── tree-sitter-verilog.ebnf ├── tree-sitter-vhdl.ebnf ├── tree-sitter-vue.ebnf ├── tree-sitter-wgsl.ebnf ├── tree-sitter-yaml.ebnf ├── tree-sitter-zig.ebnf ├── typescript.ebnf └── v.ebnf /Coco.ebnf: -------------------------------------------------------------------------------- 1 | 2 | Coco ::= 3 | // using statements 4 | ANY* 5 | "COMPILER" ident 6 | ANY* 7 | "IGNORECASE"? /* pdt */ 8 | ( "CHARACTERS" SetDecl*)? 9 | ( "TOKENS" TokenDecl*)? 10 | ( "PRAGMAS" TokenDecl*)? 11 | ( "COMMENTS" "FROM" TokenExpr "TO" TokenExpr "NESTED"?)* 12 | ( "IGNORE" Set )* 13 | SYNC 14 | "PRODUCTIONS" 15 | ( ident AttrDecl? SemText? WEAK '=' Expression WEAK '.' )* 16 | "END" ident '.' 17 | 18 | /*------------------------------------------------------------------------------------*/ 19 | 20 | SetDecl ::= ident '=' Set '.' 21 | 22 | /*------------------------------------------------------------------------------------*/ 23 | 24 | Set ::= SimSet ( '+' SimSet | '-' SimSet )* 25 | 26 | /*------------------------------------------------------------------------------------*/ 27 | 28 | SimSet ::= ident 29 | | string 30 | | Char ( '..' Char )? 31 | | 'ANY' 32 | 33 | /*--------------------------------------------------------------------------------------*/ 34 | 35 | Char ::= char 36 | 37 | /*------------------------------------------------------------------------------------*/ 38 | 39 | TokenDecl ::= Sym SYNC ( '=' TokenExpr '.' )? SemText? 40 | 41 | /*------------------------------------------------------------------------------------*/ 42 | 43 | AttrDecl ::= '<' ( ANY | badString )* '>' 44 | | '<.' ( ANY | badString )* '.>' 45 | 46 | /*------------------------------------------------------------------------------------*/ 47 | 48 | Expression ::= Term ( WEAK '|' Term )* 49 | 50 | /*------------------------------------------------------------------------------------*/ 51 | 52 | Term ::= Resolver? Factor+ 53 | 54 | /*------------------------------------------------------------------------------------*/ 55 | 56 | Factor ::= 'WEAK'? Sym Attribs? 57 | | '(' Expression ')' 58 | | '[' Expression ']' 59 | | '{' Expression '}' 60 | | SemText 61 | | 'ANY' 62 | | 'SYNC' 63 | 64 | /*------------------------------------------------------------------------------------*/ 65 | 66 | Resolver ::= "IF" "(" Condition 67 | 68 | /*------------------------------------------------------------------------------------*/ 69 | 70 | Condition ::= ( "(" Condition | ANY )* ")" 71 | 72 | /*------------------------------------------------------------------------------------*/ 73 | 74 | TokenExpr ::= TokenTerm ( WEAK '|' TokenTerm )* 75 | 76 | /*------------------------------------------------------------------------------------*/ 77 | 78 | TokenTerm ::= TokenFactor+ ( 'CONTEXT' '(' TokenExpr ')' )? 79 | 80 | /*------------------------------------------------------------------------------------*/ 81 | 82 | TokenFactor ::= Sym 83 | | '(' TokenExpr ')' 84 | | '[' TokenExpr ']' 85 | | '{' TokenExpr '}' 86 | 87 | /*------------------------------------------------------------------------------------*/ 88 | 89 | Sym ::= ident 90 | | string 91 | | char 92 | 93 | /*------------------------------------------------------------------------------------*/ 94 | 95 | Attribs ::= '<' ( ANY | badString )* '>' 96 | | '<.' ( ANY | badString )* '.>' 97 | 98 | /*------------------------------------------------------------------------------------*/ 99 | 100 | SemText ::= "(." ( ANY | badString | "(." )* ".)" 101 | 102 | /* ---- TOKENS ----- */ 103 | 104 | ident ::= letter ( letter | digit )* 105 | number ::= digit+ 106 | string ::= '"' ( stringCh | '\' printable )* '"' 107 | badString ::= '"' ( stringCh | '\' printable )* (cr | lf) 108 | char ::= "'" ( charCh | '\' printable hex* ) "'" 109 | 110 | /* ---- CHARACTERS ----- */ 111 | letter ::= [A-Za-z_] 112 | digit ::= [0-9] 113 | cr ::= #xD 114 | lf ::= #xA 115 | tab ::= #x9 116 | stringCh ::= [^"\#xD#xA] //ANY - '"' - '\\' - cr - lf 117 | charCh ::= [^'\#xD#xA] //ANY - '\'' - '\\' - cr - lf 118 | printable ::= [#x0020-#x007e] 119 | hex ::= (digit | [a-f])+ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Domingo Alvarez Duarte 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # plgh 2 | 3 | ## Programming Languages Grammar House (BNF like grammars) 4 | 5 | **Individual grammars can have different license in the origin !** 6 | 7 | **Notice: The online railroad generator has changed to IPV6 only and soemone else hosted it on an IPV4 address.** 8 | 9 | The railroad generator project can be found here https://github.com/GuntherRademacher/rr . 10 | 11 | Initially this project is using a Javascript (QuickJS) program that converts the `tree-sitter` generated "src/grammar.json" to an 12 | `EBNF` format that can be used on (IPV6) https://www.bottlecaps.de/rr/ui or (IPV4) https://rr.red-dove.com/ui (some grammars still require a bit of manual editing the generated `EBNF`, most of the ones here were manually edited just enough to alow then be viewed as `rail road diagram`). 13 | 14 | To view the `rail road diagram` copy the `EBNF` file and paste on (IPV6) https://www.bottlecaps.de/rr/ui or (IPV4) https://rr.red-dove.com/ui in the `Edit Grammar` tab then switch to the `View Diagram` tab. 15 | 16 | Short guide of the equivalences between **tree-sitter Javascript** notation and **EBNF from rail road diagram** (notice that **rr** does some optmizations and simplifications that help tidy the grammar): 17 | 18 | ``` 19 | seq(a,b,c) <=> a b c 20 | repeat(a) <=> a* 21 | repeat1(a) <=> a+ 22 | choice(a,b,c) <=> a | b | c 23 | optional(a) <=> a? 24 | commaSep(a) <=> a (',' a)* 25 | ``` 26 | 27 | There is a script (QuickJS) to convert "src/grammar.json" to **SQL** json2sql.js that was used to generated and manually fixed a SQL file with all "src/grammar.json" for the grammars on this repository. 28 | 29 | 30 | # Good Reads 31 | 32 | From https://github.com/tajmone/lemon-grove/edit/master/README.md 33 | 34 | Links to useful books, articles and tutorials on the topics of lexing and parsing. 35 | 36 | ## Compiler Design in C 37 | 38 | Free PDF book + sources, 984 pp. 39 | 40 | - https://holub.com/compiler/ 41 | 42 | Originally published in 1990 by [Prentice-Hall Inc.], _Compiler Design in C_, by [Allen Holub], is an excellent book on the topic. Written in plain language, this book takes the reader through a 984 pages long journey on how to build a compiler, step by step, introducing and explaining each compiler component in detail, and providing source code examples of each implementation step. 43 | 44 | Since the book is now out of print, the author has generously made it available for free download on his website, in PDF format, including all the source code files and the release notes. 45 | 46 | [Prentice-Hall Inc.]: http://www.prenticehall.com/ -------------------------------------------------------------------------------- /haxe.ebnf: -------------------------------------------------------------------------------- 1 | /* 2 | The begning of a HAXE grammar 3 | */ 4 | 5 | program ::= stmt* 6 | 7 | stmt ::= 8 | var_decl 9 | | 'using' access_field 10 | | 'import' access_field ('.*')? (('in' | 'as') ID)? 11 | | class_decl 12 | | interface_decl 13 | | enum_decl 14 | | function_decl ';' 15 | | structure_type 16 | | abstract_decl 17 | | '@' ':'? anotation_id ('(' expr ')')? 18 | | '#' ('if' expr | 'else' | 'elseif' expr | 'end') 19 | 20 | class_decl ::= 'extern'? 'final'? 'class' ID type_paramter? extends* implements* '{' class_members '}' 21 | 22 | interface_decl ::= 'final'? 'interface' ID extends* '{' interface_members '}' 23 | 24 | enum_decl ::= 'enum' ID type_paramter? '{' enum_item_list '}' 25 | 26 | type_paramter ::= '<' one_type_param (',' one_type_param)* '>' 27 | 28 | one_type_param ::= ID (':' type)? 29 | 30 | type ::= 31 | Void 32 | | Bool 33 | | Float 34 | | Int 35 | | Dynamic 36 | | ID type_paramter? 37 | 38 | anotation_id ::= 39 | 'access' 40 | | 'allow' 41 | | 'arrayAccess' 42 | | 'author' 43 | | 'broken' 44 | | 'coreType' 45 | | 'enum' 46 | | 'forward' 47 | | 'from' 48 | | 'generic' 49 | | 'keep' 50 | | 'native' 51 | | 'notNull' 52 | | 'noUsing' 53 | | 'op' 54 | | 'range' 55 | | 'to' 56 | | 'using' 57 | 58 | var_decl ::= ('var' | 'final') ID (':' type)? '=' expr 59 | 60 | extends ::= 'extends' ID 61 | implements ::= 'implements' ID 62 | 63 | class_members ::= 64 | ('var' | 'final') ID ('(' ID ',' ID ')')? (':' type)? '=' expr 65 | | function_decl 66 | 67 | interface_members ::= 68 | function_decl 69 | 70 | enum_item_list ::= enum_item+ 71 | 72 | enum_item ::= ID ';' 73 | 74 | function_def ::= function_decl block_stmt 75 | 76 | function_decl ::= 'static'? 'inline'? ('public' | 'private')? ('override' | 'final')? 'dynamic'? 'extern'? function_id_decl 77 | 78 | function_id_decl ::= 'function' ID type_paramter? '(' param_decl_list? ')' (':' type)? 79 | 80 | lambda_decl ::= 'function' '(' param_decl_list? ')' (':' type)? 81 | 82 | param_decl_list ::= param_decl (',' param_decl)* 83 | 84 | param_decl ::= '?'? ID ':' type ('=' literal_expr)? 85 | 86 | structure_type ::= 'typedef' ID type_paramter? '=' struct_type_def 87 | 88 | struct_type_def ::= 89 | '{' ('>' ID ',')? structure_type_member_list '}' 90 | | ID '&' '{' structure_type_member_list '}' 91 | | ID type_paramter 92 | | function_id_decl 93 | 94 | structure_type_member_list ::= structure_type_member (',' structure_type_member)* 95 | 96 | structure_type_member ::= ('var' | 'final') '?'? ID ':' type 97 | 98 | abstract_decl ::= 'enum'? 'abstract' ID '(' type ')' ('from' type 'to' type)? '{' stmt '}' 99 | 100 | block_stmt ::= 101 | var_decl 102 | | if_stmt 103 | | switch_stmt 104 | | 'return' expr 105 | | for_stmt 106 | | while_stmt 107 | | do_while_stmt 108 | | debug_stmt 109 | | throw_stmt 110 | | try_catch_stmt 111 | | 'break' 112 | | 'continue' 113 | 114 | if_stmt ::= 'if' '(' expr ')' block_stmt ('else' block_stmt)? 115 | 116 | while_stmt ::= 'while' '(' expr ')' block_stmt 117 | 118 | do_while_stmt ::= 'do' block_stmt 'while' '(' expr ')' 119 | 120 | for_stmt ::= 'for' '(' ID ('=>' ID)? 'in' (range_def | ID) ')' block_stmt 121 | 122 | range_def ::= expr '...' expr 123 | 124 | throw_stmt ::= 'throw' expr 125 | 126 | try_catch_stmt ::= 'try' block_stmt catch_clause+ 127 | 128 | catch_clause ::= 'catch' '(' ID (':' type)? ')' block_stmt 129 | 130 | switch_stmt ::= 'switch' '(' expr ')' switch_body switch_default? 131 | 132 | switch_body ::= 133 | 'case' (literal_expr ('|' literal_expr)* | ID | ('{' structure_type_member (',' structure_type_member)* '}') | ('[' (literal_expr | '_') (',' (literal_expr | '_'))* ']') | '_') ('if' expr)? ':' block_stmt* 134 | 135 | switch_default ::= 'default' block_stmt 136 | 137 | debug_stmt ::= '$' function_call 138 | 139 | literal_expr ::= 140 | BOOLEAN 141 | | INTEGER 142 | | FLOAT 143 | | STRING 144 | 145 | expr ::= 146 | ID 147 | | 'null' 148 | | 'new' ID 149 | | literal_expr 150 | | function_call 151 | | 'new' type 152 | | anonymous_struct 153 | | literal_array 154 | | access_field 155 | | expr op_binary expr 156 | | lambda_decl 157 | | 'cast' (expr | '(' expr ',' type ')') 158 | | '(' expr ':' type ')' // compile time type check 159 | | 'inline' expr 160 | | '[' (for_stmt | while_stmt) ']' 161 | | switch_stmt 162 | 163 | op_binary ::= 164 | '=' 165 | | '||' //Logical or 166 | | '&&' //Logical and 167 | | '>=' //Comparison and equality 168 | | '>' 169 | | '<' 170 | | '<=' 171 | | '==' 172 | | '!=' 173 | | '&' | '|' | '^' //Bitwise and, or, xor 174 | | '<<' | '>>' //Bitwise shifts 175 | | '+' | '-' //Plus, minus 176 | | '%' | '*' | '/' //Modulo, multiply, divide 177 | 178 | function_call ::= ID '(' param_list? ')' 179 | 180 | param_list ::= param (',' param)* 181 | 182 | param ::= expr 183 | 184 | anonymous_struct ::= '{' anonymous_struct_member_list '}' 185 | 186 | anonymous_struct_member_list ::= anonymous_struct_member (',' anonymous_struct_member)* 187 | 188 | anonymous_struct_member ::= 189 | (ID | STRING) ':' expr 190 | | '?'? ID ':' type 191 | 192 | literal_array ::= '[' expr_list? ']' 193 | 194 | expr_list ::= expr (',' expr)* 195 | 196 | access_field ::= ID ('.' ID)+ 197 | 198 | keywords ::= 199 | 'abstract' 200 | | 'break' 201 | | 'case' 202 | | 'cast' 203 | | 'catch' 204 | | 'class' 205 | | 'continue' 206 | | 'default' 207 | | 'do' 208 | | 'dynamic' 209 | | 'else' 210 | | 'enum' 211 | | 'extends' 212 | | 'extern' 213 | | 'false' 214 | | 'final' 215 | | 'for' 216 | | 'function' 217 | | 'if' 218 | | 'implements' 219 | | 'import' 220 | | 'in' 221 | | 'inline' 222 | | 'interface' 223 | | 'macro' 224 | | 'new' 225 | | 'null' 226 | | 'operator' 227 | | 'overload' 228 | | 'override' 229 | | 'package' 230 | | 'private' 231 | | 'public' 232 | | 'return' 233 | | 'static' 234 | | 'switch' 235 | | 'this' 236 | | 'throw' 237 | | 'true' 238 | | 'try' 239 | | 'typedef' 240 | | 'untyped' 241 | | 'using' 242 | | 'var' 243 | | 'while' 244 | 245 | -------------------------------------------------------------------------------- /parser_c_preproc.ebnf: -------------------------------------------------------------------------------- 1 | /* 2 | Grammar originally from https://sourceforge.net/projects/libparser/ 3 | files test/grammar/parser_c_preproc.bnf and test/grammar/scanner_c_preproc.bnf 4 | Manually converted (correctnes is not the priority now) to be viewd by 5 | (IPV6) https://www.bottlecaps.de/rr/ui 6 | (IPV4) https://rr.red-dove.com/ui 7 | */ 8 | 9 | PREPROCESSOR ::= CODE CONTROL_LINE PREPROCESSOR 10 | | CODE 11 | 12 | 13 | // accept anything that is not a control line or a directive end 14 | CODE_WITHOUT_DIRECTEND ::= CODE_WITHOUT_DIRECTEND CODE_TOKEN_WITHOUT_DIRECTEND 15 | | /* empty */ 16 | 17 | 18 | // accept anything that is not a control line 19 | CODE ::= CODE CODE_TOKEN 20 | | /* empty */ 21 | 22 | 23 | CODE_TOKEN ::= CODE_TOKEN_WITHOUT_DIRECTEND 24 | | DIRECTIVE_END 25 | 26 | 27 | CODE_TOKEN_WITHOUT_DIRECTEND ::= DEFINED 28 | | IDENTIFIER 29 | | MACRO 30 | | CONSTANT 31 | | FILENAME_SYSTEM 32 | | STRING_LITERAL 33 | | COMMA 34 | | P_OPEN 35 | | P_CLOSE 36 | | RIGHT_OP 37 | | LEFT_OP 38 | | AND_OP 39 | | OR_OP 40 | | LE_OP 41 | | GE_OP 42 | | EQ_OP 43 | | NE_OP 44 | | DOT 45 | | AND 46 | | NOT 47 | | NEG 48 | | LESS_SIG 49 | | PLUS_SIG 50 | | MUL 51 | | DIV 52 | | MOD 53 | | LESS 54 | | GREATER 55 | | XOR 56 | | OR 57 | | TEXT 58 | 59 | 60 | CONTROL_LINE ::= DEFINE_LINE 61 | | UNDEF_LINE 62 | | INCLUDE_LINE 63 | | CONDITIONAL 64 | | LINE_LINE 65 | | ERROR_LINE 66 | | WARNING_LINE 67 | | PRAGMA_LINE 68 | 69 | 70 | DEFINE_LINE ::= DEFINE IDENTIFIER CODE_WITHOUT_DIRECTEND DIRECTIVE_END 71 | | DEFINE MACRO IDENTIFIER_LIST P_CLOSE CODE_WITHOUT_DIRECTEND DIRECTIVE_END 72 | | DEFINE MACRO P_CLOSE CODE_WITHOUT_DIRECTEND DIRECTIVE_END 73 | 74 | 75 | UNDEF_LINE ::= UNDEF IDENTIFIER DIRECTIVE_END 76 | 77 | INCLUDE_LINE ::= INCLUDE FILENAME_SYSTEM DIRECTIVE_END 78 | | INCLUDE STRING_LITERAL DIRECTIVE_END 79 | | INCLUDE IDENTIFIER DIRECTIVE_END 80 | 81 | 82 | LINE_LINE ::= LINE CONSTANT STRING_LITERAL DIRECTIVE_END 83 | | LINE CONSTANT DIRECTIVE_END 84 | 85 | 86 | ERROR_LINE ::= ERROR STRING_LITERAL DIRECTIVE_END 87 | 88 | WARNING_LINE ::= WARNING STRING_LITERAL DIRECTIVE_END 89 | 90 | PRAGMA_LINE ::= PRAGMA STRING_LITERAL DIRECTIVE_END 91 | 92 | CONDITIONAL ::= IF_LINE PREPROCESSOR ELIF_PARTS 93 | 94 | IF_LINE ::= IF CODE_WITHOUT_DIRECTEND DIRECTIVE_END 95 | | IFDEF IDENTIFIER DIRECTIVE_END 96 | | IFNDEF IDENTIFIER DIRECTIVE_END 97 | 98 | 99 | ENDIF_LINE ::= ENDIF DIRECTIVE_END 100 | 101 | ELIF_PARTS ::= ELIF_LINE PREPROCESSOR ELIF_PARTS 102 | | ELSE_PART 103 | 104 | 105 | ELSE_PART ::= ELSE_LINE PREPROCESSOR ENDIF_LINE 106 | | ENDIF_LINE 107 | 108 | 109 | ELIF_LINE ::= ELIF CODE_WITHOUT_DIRECTEND DIRECTIVE_END 110 | 111 | ELSE_LINE ::= ELSE DIRECTIVE_END 112 | 113 | IDENTIFIER_LIST ::= IDENTIFIER COMMA IDENTIFIER_LIST 114 | | IDENTIFIER 115 | 116 | /* scanner */ 117 | 118 | /*ignore*/ COMMENT ::= ("/*"([^\*]|("*"+[^\*/]))*"*"+"/")|("//"[^\n]*) 119 | 120 | /*ignore*/ DIRECTIVE_CONTINUE ::= "\\\n" 121 | 122 | DIRECTIVE_END ::= "\n" 123 | 124 | DEFINE ::= "#define" 125 | DEFINED ::= "defined" 126 | UNDEF ::= "#undef" 127 | INCLUDE ::= "#include" 128 | IF ::= "#if" 129 | IFDEF ::= "#ifdef" 130 | IFNDEF ::= "#ifndef" 131 | ELSE ::= "#else" 132 | ELIF ::= "#elif" 133 | ENDIF ::= "#endif" 134 | 135 | LINE ::= "#line" 136 | ERROR ::= "#error" 137 | WARNING ::= "#warning" 138 | PRAGMA ::= "#pragma" 139 | 140 | IDENTIFIER ::= [_a-zA-Z][_a-zA-Z0-9]* 141 | 142 | /* 143 | * MACRO is a workaround becouse in the expression 144 | * #define a (b) c 145 | * if there is a whitespace between a and (b), it is a ordinary define 146 | * if there is no whitespace, then it's a macro, 147 | * as our lexer ignores whitespaces, we define the token MACRO 148 | * that is an identifier with a '(' in the end 149 | */ 150 | MACRO ::= [_a-zA-Z][_a-zA-Z0-9]* 151 | 152 | CONSTANT ::= "0"[xX]([0-9a-fA-F])+[uUlL]? 153 | CONSTANT ::= [0-9]+[uUlL]? 154 | CONSTANT ::= "'"([^\']|"\'")+"'" 155 | 156 | CONSTANT ::= [0-9]+[eE][\+-]?[0-9]+[fFlL]? 157 | CONSTANT ::= [0-9]+'.'[0-9]*([eE][\+-]?)?[0-9]+[fFlL]? 158 | CONSTANT ::= [0-9]*'.'[0-9]+([eE][\+-]?)?[0-9]+[fFlL]? 159 | 160 | FILENAME_SYSTEM ::= "<" [^>]* ">" 161 | STRING_LITERAL ::= '"' ([^\"]|'\"')* '"' 162 | 163 | ELLIPSIS ::= "..." 164 | RIGHT_ASSIGN ::= ">>=" 165 | LEFT_ASSIGN ::= "<<=" 166 | ADD_ASSIGN ::= "+=" 167 | SUB_ASSIGN ::= "-=" 168 | MUL_ASSIGN ::= "*=" 169 | DIV_ASSIGN ::= "/=" 170 | MOD_ASSIGN ::= "%=" 171 | AND_ASSIGN ::= "&=" 172 | XOR_ASSIGN ::= "^=" 173 | OR_ASSIGN ::= "|=" 174 | 175 | RIGHT_OP ::= ">>" 176 | LEFT_OP ::= "<<" 177 | INC_OP ::= "++" 178 | DEC_OP ::= "--" 179 | PTR_OP ::= "->" 180 | AND_OP ::= "&&" 181 | OR_OP ::= "||" 182 | LE_OP ::= "<=" 183 | GE_OP ::= ">=" 184 | EQ_OP ::= "==" 185 | NE_OP ::= "!=" 186 | 187 | INST_END ::= ";" 188 | BEGIN ::= "{" 189 | END ::= "}" 190 | COMMA ::= "," 191 | COLUMN ::= ":" 192 | EQ ::= "=" 193 | P_OPEN ::= "(" 194 | P_CLOSE ::= ")" 195 | B_OPEN ::= "[" 196 | B_CLOSE ::= "]" 197 | DOT ::= "." 198 | AND ::= "&" 199 | NOT ::= "!" 200 | NEG ::= "~" 201 | LESS_SIG ::= "-" 202 | PLUS_SIG ::= "+" 203 | MUL ::= "*" 204 | DIV ::= "/" 205 | MOD ::= "%" 206 | LESS ::= "<" 207 | GREATER ::= ">" 208 | XOR ::= "^" 209 | OR ::= "|" 210 | QUESTION ::= "?" 211 | 212 | /*ignore*/ WHITESPCE ::= "[ \t\f\r]+" 213 | 214 | // the text will be generated by PreprocessorScanner. 215 | // define it's regex to be never used here 216 | TEXT ::= " " 217 | -------------------------------------------------------------------------------- /scanner_c_preproc.ebnf: -------------------------------------------------------------------------------- 1 | /*ignore*/ COMMENT ::= ("/*"([^\*]|("*"+[^\*/]))*"*"+"/")|("//"[^\n]*) 2 | 3 | /*ignore*/ DIRECTIVE_CONTINUE ::= "\\\n" 4 | 5 | DIRECTIVE_END ::= "\n" 6 | 7 | DEFINE ::= "#define" 8 | DEFINED ::= "defined" 9 | UNDEF ::= "#undef" 10 | INCLUDE ::= "#include" 11 | IF ::= "#if" 12 | IFDEF ::= "#ifdef" 13 | IFNDEF ::= "#ifndef" 14 | ELSE ::= "#else" 15 | ELIF ::= "#elif" 16 | ENDIF ::= "#endif" 17 | 18 | LINE ::= "#line" 19 | ERROR ::= "#error" 20 | WARNING ::= "#warning" 21 | PRAGMA ::= "#pragma" 22 | 23 | IDENTIFIER ::= [_a-zA-Z][_a-zA-Z0-9]* 24 | 25 | /* 26 | * MACRO is a workaround becouse in the expression 27 | * #define a (b) c 28 | * if there is a whitespace between a and (b), it is a ordinary define 29 | * if there is no whitespace, then it's a macro, 30 | * as our lexer ignores whitespaces, we define the token MACRO 31 | * that is an identifier with a '(' in the end 32 | */ 33 | MACRO ::= [_a-zA-Z][_a-zA-Z0-9]* 34 | 35 | CONSTANT ::= "0"[xX]([0-9a-fA-F])+[uUlL]? 36 | CONSTANT ::= [0-9]+[uUlL]? 37 | CONSTANT ::= "'"([^\']|"\'")+"'" 38 | 39 | CONSTANT ::= [0-9]+[eE][\+-]?[0-9]+[fFlL]? 40 | CONSTANT ::= [0-9]+'.'[0-9]*([eE][\+-]?)?[0-9]+[fFlL]? 41 | CONSTANT ::= [0-9]*'.'[0-9]+([eE][\+-]?)?[0-9]+[fFlL]? 42 | 43 | FILENAME_SYSTEM ::= "<" [^>]* ">" 44 | STRING_LITERAL ::= '"' ([^\"]|'\"')* '"' 45 | 46 | ELLIPSIS ::= "..." 47 | RIGHT_ASSIGN ::= ">>=" 48 | LEFT_ASSIGN ::= "<<=" 49 | ADD_ASSIGN ::= "+=" 50 | SUB_ASSIGN ::= "-=" 51 | MUL_ASSIGN ::= "*=" 52 | DIV_ASSIGN ::= "/=" 53 | MOD_ASSIGN ::= "%=" 54 | AND_ASSIGN ::= "&=" 55 | XOR_ASSIGN ::= "^=" 56 | OR_ASSIGN ::= "|=" 57 | 58 | RIGHT_OP ::= ">>" 59 | LEFT_OP ::= "<<" 60 | INC_OP ::= "++" 61 | DEC_OP ::= "--" 62 | PTR_OP ::= "->" 63 | AND_OP ::= "&&" 64 | OR_OP ::= "||" 65 | LE_OP ::= "<=" 66 | GE_OP ::= ">=" 67 | EQ_OP ::= "==" 68 | NE_OP ::= "!=" 69 | 70 | INST_END ::= ";" 71 | BEGIN ::= "{" 72 | END ::= "}" 73 | COMMA ::= "," 74 | COLUMN ::= ":" 75 | EQ ::= "=" 76 | P_OPEN ::= "(" 77 | P_CLOSE ::= ")" 78 | B_OPEN ::= "[" 79 | B_CLOSE ::= "]" 80 | DOT ::= "." 81 | AND ::= "&" 82 | NOT ::= "!" 83 | NEG ::= "~" 84 | LESS_SIG ::= "-" 85 | PLUS_SIG ::= "+" 86 | MUL ::= "*" 87 | DIV ::= "/" 88 | MOD ::= "%" 89 | LESS ::= "<" 90 | GREATER ::= ">" 91 | XOR ::= "^" 92 | OR ::= "|" 93 | QUESTION ::= "?" 94 | 95 | /*ignore*/ WHITESPCE ::= "[ \t\f\r]+" 96 | 97 | // the text will be generated by PreprocessorScanner. 98 | // define it's regex to be never used here 99 | TEXT ::= " " 100 | -------------------------------------------------------------------------------- /tree-sitter-abnf.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-abnf/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | source_file ::= 11 | rulelist 12 | 13 | rulelist ::= 14 | ( rule | _c_wsp* _c_nl )+ 15 | 16 | rule ::= 17 | rulename defined_as elements _c_nl 18 | 19 | rulename ::= 20 | [A-Za-z][A-Za-z0-9-]* 21 | 22 | defined_as ::= 23 | _c_wsp* ( '=' | '=/' ) _c_wsp* 24 | 25 | elements ::= 26 | alternation _c_wsp* 27 | 28 | _c_wsp ::= 29 | _WSP 30 | | _c_nl _WSP 31 | 32 | _c_nl ::= 33 | comment 34 | | _CRLF 35 | 36 | comment ::= 37 | ';'[ #x09\x21-\x7E]*'#x0D#x0A' 38 | 39 | alternation ::= 40 | concatenation ( _c_wsp* '/' _c_wsp* concatenation )* 41 | 42 | concatenation ::= 43 | repetition ( _c_wsp+ repetition )* 44 | 45 | repetition ::= 46 | repeat? element 47 | 48 | repeat ::= 49 | DIGIT+ 50 | | DIGIT* '*' DIGIT* 51 | 52 | element ::= 53 | core_rulename 54 | | rulename 55 | | group 56 | | option 57 | | char_val 58 | | num_val 59 | | prose_val 60 | 61 | group ::= 62 | '(' _c_wsp* alternation _c_wsp* ')' 63 | 64 | option ::= 65 | '[' _c_wsp* alternation _c_wsp* ']' 66 | 67 | char_val ::= 68 | case_insensitive_string 69 | | case_sensitive_string 70 | 71 | case_insensitive_string ::= 72 | '%i'? quoted_string 73 | 74 | case_sensitive_string ::= 75 | '%s' quoted_string 76 | 77 | quoted_string ::= 78 | _DQUOTE [\x20-\x21\x23-\x7E]* _DQUOTE 79 | 80 | num_val ::= 81 | '%' ( bin_val | dec_val | hex_val ) 82 | 83 | bin_val ::= 84 | 'b' BIT+ ( ( '.' BIT+ )+ | '-' BIT+ )? 85 | 86 | dec_val ::= 87 | 'd' DIGIT+ ( ( '.' DIGIT+ )+ | '-' DIGIT+ )? 88 | 89 | hex_val ::= 90 | 'x' HEXDIG+ ( ( '.' HEXDIG+ )+ | '-' HEXDIG+ )? 91 | 92 | prose_val ::= 93 | '<' [\x20-\x3D\x3F-\x7E]* '>' 94 | 95 | core_rulename ::= 96 | 'ALPHA' 97 | | 'BIT' 98 | | 'CHAR' 99 | | 'CR' 100 | | 'CRLF' 101 | | 'CTL' 102 | | 'DIGIT' 103 | | 'DQUOTE' 104 | | 'HEXDIG' 105 | | 'HTAB' 106 | | 'LF' 107 | | 'LWSP' 108 | | 'OCTET' 109 | | 'SP' 110 | | 'VCHAR' 111 | | 'WSP' 112 | 113 | ALPHA ::= 114 | [A-Za-z] 115 | 116 | BIT ::= 117 | '0' 118 | | '1' 119 | 120 | DIGIT ::= 121 | [0-9] 122 | 123 | _CR ::= 124 | '\r' 125 | 126 | _CRLF ::= 127 | _CR _LF 128 | 129 | _DQUOTE ::= 130 | '"' 131 | 132 | HEXDIG ::= 133 | [0-9A-Fa-f] 134 | 135 | _HTAB ::= 136 | '\t' 137 | 138 | _LF ::= 139 | '\n' 140 | 141 | _SP ::= 142 | ' ' 143 | 144 | VCHAR ::= 145 | [\x21-\x7E] 146 | 147 | _WSP ::= 148 | _SP 149 | | _HTAB 150 | 151 | -------------------------------------------------------------------------------- /tree-sitter-beancount.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-beancount/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | beancount_file ::= 11 | ( _skipped_lines | _dated_directives | _undated_directives )* 12 | 13 | _skipped_lines ::= 14 | [!&?%PSTCURM*#x23] '.'* '#x0A'([ #x0D#x09]+'#x0A')? 15 | | ':' '.'* '#x0A'([ #x0D#x09]+'#x0A')? 16 | | '#x0A'([ #x0D#x09]+'#x0A')? 17 | | ';.'* '#x0A'([ #x0D#x09]+'#x0A')? 18 | 19 | _undated_directives ::= 20 | include 21 | | option 22 | | plugin 23 | | popmeta 24 | | poptag 25 | | pushmeta 26 | | pushtag 27 | 28 | include ::= 29 | 'include' string '#x0A'([ #x0D#x09]+'#x0A')? 30 | 31 | option ::= 32 | 'option' string string '#x0A'([ #x0D#x09]+'#x0A')? 33 | 34 | plugin ::= 35 | 'plugin' string string? '#x0A'([ #x0D#x09]+'#x0A')? 36 | 37 | pushtag ::= 38 | 'pushtag' tag '#x0A'([ #x0D#x09]+'#x0A')? 39 | 40 | poptag ::= 41 | 'poptag' tag '#x0A'([ #x0D#x09]+'#x0A')? 42 | 43 | pushmeta ::= 44 | 'pushmeta' key_value '#x0A'([ #x0D#x09]+'#x0A')? 45 | 46 | popmeta ::= 47 | 'popmeta' key '#x0A'([ #x0D#x09]+'#x0A')? 48 | 49 | _dated_directives ::= 50 | balance 51 | | close 52 | | commodity 53 | | custom 54 | | document 55 | | event 56 | | note 57 | | open 58 | | pad 59 | | price 60 | | transaction 61 | | query 62 | 63 | balance ::= 64 | date 'balance' account ( amount | amount_with_tolerance ) metadata? '#x0A'([ #x0D#x09]+'#x0A')? 65 | 66 | close ::= 67 | date 'close' account metadata? '#x0A'([ #x0D#x09]+'#x0A')? 68 | 69 | commodity ::= 70 | date 'commodity' currency metadata? '#x0A'([ #x0D#x09]+'#x0A')? 71 | 72 | custom ::= 73 | date 'custom' string ( string | date | account | bool | amount | _num_expr )* metadata? '#x0A'([ #x0D#x09]+'#x0A')? 74 | 75 | document ::= 76 | date 'document' account string tags_and_links? metadata? '#x0A'([ #x0D#x09]+'#x0A')? 77 | 78 | event ::= 79 | date 'event' string string metadata? '#x0A'([ #x0D#x09]+'#x0A')? 80 | 81 | note ::= 82 | date 'note' account string metadata? '#x0A'([ #x0D#x09]+'#x0A')? 83 | 84 | open ::= 85 | date 'open' account currency_list? string? metadata? '#x0A'([ #x0D#x09]+'#x0A')? 86 | 87 | pad ::= 88 | date 'pad' account account metadata? '#x0A'([ #x0D#x09]+'#x0A')? 89 | 90 | price ::= 91 | date 'price' currency amount metadata? '#x0A'([ #x0D#x09]+'#x0A')? 92 | 93 | transaction ::= 94 | date flag ( string string | string )? tags_and_links? metadata? postings '#x0A'([ #x0D#x09]+'#x0A')? 95 | 96 | query ::= 97 | date 'query' string string metadata? '#x0A'([ #x0D#x09]+'#x0A')? 98 | 99 | cost ::= 100 | '{' _cost_comp_list? '}' 101 | 102 | total_cost ::= 103 | '{{' _cost_comp_list? '}}' 104 | 105 | _cost_comp_list ::= 106 | _cost_comp ( ',' _cost_comp )* 107 | 108 | _cost_comp ::= 109 | '*' 110 | | date 111 | | string 112 | | compound_amount 113 | 114 | compound_amount ::= 115 | _num_expr? currency 116 | | _num_expr currency? 117 | | _num_expr? '#' _num_expr? currency 118 | 119 | incomplete_amount ::= 120 | _num_expr 121 | | currency 122 | 123 | price_annotation ::= 124 | '@' ( amount | incomplete_amount )? 125 | 126 | total_price_annotation ::= 127 | '@@' ( amount | incomplete_amount )? 128 | 129 | posting ::= 130 | '#x0A'[ #x0D#x09]+ flag? account ( amount | incomplete_amount )? ( cost | total_cost )? ( price_annotation | total_price_annotation )? ';.'*? metadata? 131 | 132 | postings ::= 133 | ( posting | '#x0A'[ #x0D#x09]+ ';.'* )+ 134 | 135 | tags_and_links ::= 136 | ( '#x0A'[ #x0D#x09]+? ( tag | link ) )+ 137 | 138 | currency_list ::= 139 | currency ( ',' currency )* 140 | 141 | metadata ::= 142 | ( '#x0A'[ #x0D#x09]+ key_value )+ 143 | 144 | key_value ::= 145 | key ( string | account | date | currency | tag | bool | _num_expr | amount )? 146 | 147 | amount ::= 148 | _num_expr currency 149 | 150 | amount_with_tolerance ::= 151 | _num_expr '~' _num_expr currency 152 | 153 | _num_expr ::= 154 | number 155 | | paren_num_expr 156 | | unary_num_expr 157 | | binary_num_expr 158 | 159 | paren_num_expr ::= 160 | '(' _num_expr ')' 161 | 162 | unary_num_expr ::= 163 | '-' _num_expr | '+' _num_expr 164 | 165 | binary_num_expr ::= 166 | _num_expr '*' _num_expr 167 | | _num_expr '/' _num_expr 168 | | _num_expr '+' _num_expr 169 | | _num_expr '-' _num_expr 170 | 171 | bool ::= 172 | 'TRUE'|'FALSE' 173 | 174 | date ::= 175 | [0-9][0-9][0-9][0-9][#x2D-/][0-9][0-9][#x2D-/][0-9][0-9] 176 | 177 | key ::= 178 | [a-z][a-zA-Z0-9#x2D-_]+':' 179 | 180 | tag ::= 181 | '#'[A-Za-z0-9#x2D-_/.]+ 182 | 183 | link ::= 184 | '\^'[A-Za-z0-9#x2D-_/.]+ 185 | 186 | string ::= 187 | '"'[^"]*'"' 188 | 189 | currency ::= 190 | [A-Z][A-Z0-9\'._#x2D-]"{0,22}"[A-Z0-9] 191 | 192 | number ::= 193 | ([0-9]+|[0-9][0-9,]+[0-9])('.'[0-9]*)? 194 | 195 | flag ::= 196 | [!&?%PSTCURM*#x23] 197 | 198 | account ::= 199 | ( [A-Z]|[^\x00-\x7F] [A-Za-z0-9#x2D-]|[^\x00-\x7F]* ( ':' [A-Z0-9]|[^\x00-\x7F] [A-Za-z0-9#x2D-]|[^\x00-\x7F]* )+ ) 200 | 201 | -------------------------------------------------------------------------------- /tree-sitter-beancount2.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-beancount2/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | source_file ::= 11 | _definition* 12 | 13 | _definition ::= 14 | _entry_definition 15 | | option_definition 16 | | plugin_definition 17 | | include_definition 18 | | pushtag_definition 19 | | poptag_definition 20 | 21 | option_definition ::= 22 | 'option' text text 23 | 24 | plugin_definition ::= 25 | 'plugin' text text? 26 | 27 | include_definition ::= 28 | 'include' filepath 29 | 30 | pushtag_definition ::= 31 | 'pushtag' tag 32 | 33 | poptag_definition ::= 34 | 'poptag' tag 35 | 36 | _entry_definition ::= 37 | date ( open_definition | close_definition | commodity_definition | transaction_definition | note_definition | document_definition | event_definition | balance_definition | price_definition | pad_definition | custom_definition ) metadata_definition* 38 | 39 | open_definition ::= 40 | 'open' account ( commodity ( ',' commodity )* )? 41 | 42 | close_definition ::= 43 | 'close' account 44 | 45 | commodity_definition ::= 46 | 'commodity' commodity 47 | 48 | transaction_definition ::= 49 | txn ( text text | text )? ( tag | link )* ( post_definition | metadata_definition )* 50 | 51 | post_definition ::= 52 | account ( amount commodity cost? price? )? 53 | 54 | price ::= 55 | '@{1,2}' unsigned_amount commodity 56 | 57 | cost ::= 58 | '{' unsigned_amount commodity '}' 59 | 60 | tag ::= 61 | '#'('-'|[a-zA-Z_])+ 62 | 63 | link ::= 64 | '\^'('-'|[a-zA-Z_])+ 65 | 66 | note_definition ::= 67 | 'note' account note 68 | 69 | document_definition ::= 70 | 'document' account filepath 71 | 72 | filepath ::= 73 | '".'+'"' 74 | 75 | event_definition ::= 76 | 'event' text text 77 | 78 | balance_definition ::= 79 | 'balance' account amount commodity 80 | 81 | price_definition ::= 82 | 'price' commodity amount commodity 83 | 84 | pad_definition ::= 85 | 'pad' account account 86 | 87 | custom_definition ::= 88 | 'custom' text uncheck* 89 | 90 | uncheck ::= 91 | text 92 | | '\S'+ 93 | 94 | account ::= 95 | ( 'Assets' | 'Liabilities' | 'Equity' | 'Income' | 'Expenses' ) ( ':' _account_component )* 96 | 97 | metadata_definition ::= 98 | metadata_key ':' metadata_value? 99 | 100 | metadata_key ::= 101 | [a-z][a-zA-Z0-9-_]* 102 | 103 | metadata_value ::= 104 | text 105 | | account 106 | | commodity 107 | | date 108 | | tag 109 | | amount 110 | 111 | _account_component ::= 112 | [A-Z0-9][a-zA-Z0-9-]* 113 | 114 | _booking_method ::= 115 | 'STRICT' 116 | | 'NONE' 117 | 118 | date ::= 119 | [0-9][0-9][0-9][0-9][-/]('0'[1-9]|'1'[0-2])[-/]([012][0-9]|'3'[0-1]) 120 | 121 | note ::= 122 | '".'*'"' 123 | 124 | text ::= 125 | '"' '.'* '"' 126 | 127 | unsigned_amount ::= 128 | [0-9]+('.'[0-9]+)? 129 | 130 | amount ::= 131 | '-'?[0-9]+('.'[0-9]+)? 132 | 133 | txn ::= 134 | '*' 135 | | '!' 136 | 137 | commodity ::= 138 | [A-Z]+ 139 | 140 | comment ::= 141 | ';' '.'* 142 | 143 | -------------------------------------------------------------------------------- /tree-sitter-carp.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-carp/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | source_file ::= 11 | _expr* 12 | 13 | line_comment ::= 14 | ( ';' '.'* ) 15 | 16 | _expr ::= 17 | _special_forms 18 | | _literals 19 | | _shorthand 20 | | _identifier 21 | | _defs 22 | | _specials 23 | | call 24 | | array 25 | | map 26 | | register 27 | | hidden 28 | | doc 29 | | signature 30 | | private 31 | 32 | call ::= 33 | '(' _call_name _expr*? ')' 34 | 35 | _call_name ::= 36 | _identifier 37 | | short_fn_ref 38 | 39 | array ::= 40 | '[' _expr*? ']' 41 | 42 | map ::= 43 | '{' ( _expr _expr )*? '}' 44 | 45 | hidden ::= 46 | '(' 'hidden' _identifier ')' 47 | 48 | doc ::= 49 | '(' 'doc' _identifier str_literal ')' 50 | 51 | signature ::= 52 | '(' 'sig' _identifier '(' interface_fn ')' ')' 53 | 54 | private ::= 55 | '(' 'private' _identifier ')' 56 | 57 | register ::= 58 | '(' 'register' _defs_name ( type | _shorthand ) _expr? ')' 59 | 60 | _special_forms ::= 61 | fn 62 | | let 63 | | do 64 | | if 65 | | while 66 | | use 67 | | with 68 | | ref 69 | | address 70 | | set 71 | | the 72 | | match 73 | 74 | fn ::= 75 | '(' 'fn' _parameters _expr? ')' 76 | 77 | _parameters ::= 78 | _identifier 79 | | parameters 80 | | quote 81 | | short_quote 82 | 83 | parameters ::= 84 | '[' _identifier*? ']' 85 | 86 | let ::= 87 | '(' 'let' _let_pairs _expr? ')' 88 | 89 | _let_pairs ::= 90 | _identifier 91 | | call 92 | | pairs 93 | | quote 94 | | short_quote 95 | 96 | pairs ::= 97 | '[' ( _expr _expr )* ']' 98 | 99 | do ::= 100 | '(' 'do' _expr* ')' 101 | 102 | if ::= 103 | '(' 'if' _expr _expr _expr ')' 104 | 105 | while ::= 106 | '(' 'while' _expr _expr? ')' 107 | 108 | use ::= 109 | '(' 'use' _use_module ')' 110 | 111 | with ::= 112 | '(' 'with' _use_module _expr* ')' 113 | 114 | _use_module ::= 115 | symbol 116 | | scoped_identifier 117 | | quote 118 | | short_quote 119 | | call 120 | 121 | ref ::= 122 | '(' 'ref' _expr? ')' 123 | 124 | address ::= 125 | '(' 'address' _expr ')' 126 | 127 | set ::= 128 | '(' 'set!' _expr _expr ')' 129 | 130 | the ::= 131 | '(' 'the' type _expr ')' 132 | 133 | match ::= 134 | '(' 'match' _expr match_case*? ')' 135 | 136 | match_case ::= 137 | _expr _expr 138 | 139 | _defs ::= 140 | def 141 | | defn 142 | | definterface 143 | | defmacro 144 | | defndynamic 145 | | defmodule 146 | | deftype 147 | | deftemplate 148 | 149 | def ::= 150 | '(' 'def' _defs_name _expr ')' 151 | 152 | defn ::= 153 | '(' 'defn' _defs_name _parameters _expr? ')' 154 | 155 | definterface ::= 156 | '(' 'definterface' _defs_name ( _identifier | _sig ) ')' 157 | 158 | _sig ::= 159 | quote 160 | | short_quote 161 | | '(' interface_fn ')' 162 | 163 | defmacro ::= 164 | '(' 'defmacro' _defs_name _parameters _expr? ')' 165 | 166 | defndynamic ::= 167 | '(' 'defndynamic' _defs_name _parameters _expr? ')' 168 | 169 | defmodule ::= 170 | '(' 'defmodule' _defmodule_name _expr* ')' 171 | 172 | _defmodule_name ::= 173 | symbol 174 | | quote 175 | | short_quote 176 | 177 | deftype ::= 178 | '(' 'deftype' _deftype_names ( _deftype_struct | _deftype_enum1* | _deftype_enum2* ) ')' 179 | 180 | _deftype_struct ::= 181 | '[' ( _field type )* ']' 182 | 183 | _deftype_enum1 ::= 184 | '(' symbol '[' _field* ']' ')' 185 | 186 | _deftype_enum2 ::= 187 | symbol 188 | 189 | _deftype_names ::= 190 | symbol 191 | | '(' symbol symbol*? ')' 192 | 193 | _field ::= 194 | symbol 195 | | call 196 | | quote 197 | | short_quote 198 | 199 | deftemplate ::= 200 | '(' 'deftemplate' _defs_name type _deftemplate_str _deftemplate_str ')' 201 | 202 | _deftemplate_str ::= 203 | str_literal 204 | | pattern_literal 205 | | quote 206 | | short_quote 207 | 208 | _defs_name ::= 209 | _identifier 210 | | quote 211 | | short_quote 212 | 213 | _specials ::= 214 | quote 215 | 216 | quote ::= 217 | '(' 'quote' _expr ')' 218 | 219 | _shorthand ::= 220 | short_ref 221 | | short_copy 222 | | short_fn_ref 223 | | short_quote 224 | 225 | short_ref ::= 226 | '&' _expr 227 | 228 | short_copy ::= 229 | '@' _expr 230 | 231 | short_fn_ref ::= 232 | '~' _expr 233 | 234 | short_quote ::= 235 | "'" _expr 236 | 237 | type ::= 238 | ( 'Bool' | 'Byte' | 'Char' | 'Int' | 'Long' | 'Float' | 'Double' | 'Vector2' | 'Vector3' | 'VectorN' | 'String' | 'Pattern' | 'Array' | 'Map' | 'Maybe' | 'Result' | 'Id' | 'Ptr' ) 239 | | complex_type 240 | | symbol 241 | 242 | complex_type ::= 243 | '(' ( ( 'Bool' | 'Byte' | 'Char' | 'Int' | 'Long' | 'Float' | 'Double' | 'Vector2' | 'Vector3' | 'VectorN' | 'String' | 'Pattern' | 'Array' | 'Map' | 'Maybe' | 'Result' | 'Id' | 'Ptr' ) | complex_type | symbol | interface_fn | static_lifetime )* ')' 244 | 245 | interface_fn ::= 246 | ( 'Fn' | 'λ' ) ( _type_parameters ) ( _shorthand | type ) 247 | 248 | _type_parameters ::= 249 | symbol 250 | | call 251 | | type_parameters 252 | | quote 253 | | short_quote 254 | 255 | static_lifetime ::= 256 | 'StaticLifetime' 257 | 258 | type_parameters ::= 259 | '[' ( type | _shorthand )* ']' 260 | 261 | _literals ::= 262 | unit 263 | | str_literal 264 | | char_literal 265 | | pattern_literal 266 | | bool_literal 267 | | integer_literal 268 | | float_literal 269 | 270 | integer_literal ::= 271 | ( '-'? ( '0x'[0-9a-fA-F]+ | '0x'[0-9a-fA-F]+'l' | '0b'[01]+ | '0b'[01]+'l' | '0b'[01]+'b' | [0-9][0-9]* | [0-9][0-9]*'l' | [0-9][0-9]*'b' ) ) 272 | 273 | float_literal ::= 274 | ( '-'? ( [0-9][0-9]*'f' | [0-9][0-9]*'.'[0-9][0-9]*'f'? ) ) 275 | 276 | bool_literal ::= 277 | 'true' 278 | | 'false' 279 | 280 | str_literal ::= 281 | '"' ( [^"\$]+ | escape_sequence | meta_symbol )* '"' 282 | 283 | char_literal ::= 284 | '\\' ( escape_sequence | [ #x09#x0A#x0B#x0C#x0D] | '.' ) 285 | 286 | pattern_literal ::= 287 | '#"' ( [^"]+ )* '"' 288 | 289 | meta_symbol ::= 290 | '\$'[^({#x5B#x5D})"'@&|`;.,~#x23 #x09#x0A#x0B#x0C#x0D\:][^({#x5B#x5D})"'@&|`;.,~#x23 #x09#x0A#x0B#x0C#x0D\]* 291 | 292 | escape_sequence ::= 293 | ( '\'[^xu] | '\u'[0-9a-fA-F]'{4}' | '\u{'[0-9a-fA-F]+'}' | '\x'[0-9a-fA-F]'{2}' ) 294 | 295 | unit ::= 296 | '()' 297 | 298 | _identifier ::= 299 | keyword 300 | | symbol 301 | | scoped_identifier 302 | 303 | scoped_identifier ::= 304 | ( scoped_identifier | symbol | keyword ) '.' _identifier 305 | 306 | keyword ::= 307 | ':'[^({#x5B#x5D})"'@&|`;.,~#x23 #x09#x0A#x0B#x0C#x0D\] 308 | 309 | symbol ::= 310 | [^({#x5B#x5D})"'@&|`;.,~#x23 #x09#x0A#x0B#x0C#x0D\:][^({#x5B#x5D})"'@&|`;.,~#x23 #x09#x0A#x0B#x0C#x0D\]* 311 | 312 | -------------------------------------------------------------------------------- /tree-sitter-clojure.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-clojure/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | program ::= 11 | _anything* 12 | 13 | _anything ::= 14 | _literals 15 | | symbol 16 | | interop 17 | | _functions 18 | | quote 19 | | comment 20 | | deref 21 | | syntax_quote 22 | | var_quote 23 | | unquote 24 | | unquote_splice 25 | | gensym 26 | | shorthand_function_arg 27 | | reader_conditional 28 | 29 | _literals ::= 30 | nil 31 | | boolean 32 | | number 33 | | symbolic_value 34 | | character 35 | | string 36 | | regex 37 | | keyword 38 | | _collection_literals 39 | | tagged_literal 40 | 41 | _collection_literals ::= 42 | metadata? ( list | vector | hash_map | set ) 43 | 44 | nil ::= 45 | 'nil' 46 | 47 | boolean ::= 48 | true 49 | | false 50 | 51 | true ::= 52 | 'true' 53 | 54 | false ::= 55 | 'false' 56 | 57 | number ::= 58 | _number 59 | 60 | _number ::= 61 | number_long 62 | | number_double 63 | | number_bigint 64 | | number_bigdecimal 65 | | number_ratio 66 | 67 | number_long ::= 68 | _normal_long 69 | | _number_hex 70 | | _number_arbitrary_radix 71 | | _number_octal 72 | 73 | _normal_long ::= 74 | [-+]?[0-9]+ 75 | 76 | _number_hex ::= 77 | '-'?'0'[xX][0-9a-fA-F]+ 78 | 79 | _number_arbitrary_radix ::= 80 | '-'?[0-9]+[rR][0-9a-zA-Z]+ 81 | 82 | _number_octal ::= 83 | '-'?'0'[0-9]+ 84 | 85 | number_double ::= 86 | ( ( [0-9]+ ( '_'+ [0-9]+ )* ) '.' ( [0-9]+ ( '_'+ [0-9]+ )* )? ( [eE] ( '-' | '+' )? ( [0-9]+ ( '_'+ [0-9]+ )* ) )? [fFdD]? | '.' ( [0-9]+ ( '_'+ [0-9]+ )* ) ( [eE] ( '-' | '+' )? ( [0-9]+ ( '_'+ [0-9]+ )* ) )? [fFdD]? | ( [0-9]+ ( '_'+ [0-9]+ )* ) [eE] ( '-' | '+' )? ( [0-9]+ ( '_'+ [0-9]+ )* ) [fFdD]? | ( [0-9]+ ( '_'+ [0-9]+ )* ) ( [eE] ( '-' | '+' )? ( [0-9]+ ( '_'+ [0-9]+ )* ) )? [fFdD] ) 87 | 88 | number_bigint ::= 89 | [-+]?[0-9]+'N' 90 | 91 | number_bigdecimal ::= 92 | '-'?[0-9]+'.'[0-9]+([eE][+-]?[0-9]+)?'M' 93 | 94 | number_ratio ::= 95 | [-+]?[0-9]+'\/'[0-9]+ 96 | 97 | symbolic_value ::= 98 | '##' ( infinity | negative_infinity | not_a_number ) 99 | 100 | infinity ::= 101 | 'Inf' 102 | 103 | negative_infinity ::= 104 | '-Inf' 105 | 106 | not_a_number ::= 107 | 'NaN' 108 | 109 | character ::= 110 | _character 111 | 112 | _character ::= 113 | '\\' ( _normal_char | _special_char | _unicode_char | _octal_char ) 114 | 115 | _normal_char ::= 116 | '.' 117 | 118 | _special_char ::= 119 | 'newline' 120 | | 'space' 121 | | 'tab' 122 | | 'formfeed' 123 | | 'backspace' 124 | | 'return' 125 | 126 | _unicode_char ::= 127 | 'u' _hex_char _hex_char _hex_char _hex_char 128 | 129 | _hex_char ::= 130 | [A-Fa-f0-9] 131 | 132 | _octal_char ::= 133 | 'o' _octal_num 134 | 135 | _octal_num ::= 136 | [0-3][0-7][0-7] 137 | | [0-7][0-7] 138 | | [0-7] 139 | 140 | string ::= 141 | _string 142 | 143 | _string ::= 144 | '"' ( '\"' | [^"] )* '"' 145 | 146 | regex ::= 147 | _regex 148 | 149 | _regex ::= 150 | '#"' ( '\"' | [^"#x0A#x0D] )* '"' 151 | 152 | quote ::= 153 | _quote 154 | 155 | _quote ::= 156 | "'" _anything 157 | | '(quote' _anything ')' 158 | 159 | keyword ::= 160 | _keyword 161 | 162 | _keyword ::= 163 | _unqualified_keyword 164 | | qualified_keyword 165 | 166 | _unqualified_keyword ::= 167 | ':' _keyword_chars 168 | 169 | qualified_keyword ::= 170 | '::' _keyword_chars 171 | | '::' _keyword_chars '/' _keyword_chars 172 | 173 | _keyword_chars ::= 174 | [a-zA-Z0-9#x2D-_\!\+.][a-zA-Z0-9#x2D-_\!\+.:\?]* 175 | 176 | symbol ::= 177 | _symbol 178 | 179 | _symbol ::= 180 | threading_macro 181 | | _symbol_chars 182 | | qualified_symbol 183 | 184 | threading_macro ::= 185 | '->' 186 | | '->>' 187 | | 'as->' 188 | | 'some->' 189 | | 'some->>' 190 | | 'cond->' 191 | | 'cond->>' 192 | 193 | _symbol_chars ::= 194 | [a-zA-Z\*\+\!#x2D-_\?][a-zA-Z0-9\*\+\!#x2D-_\?\':]* 195 | 196 | qualified_symbol ::= 197 | _qualified_symbol 198 | 199 | _qualified_symbol ::= 200 | _symbol_chars '/' _symbol_chars 201 | 202 | interop ::= 203 | member_access 204 | | field_access 205 | | new_class 206 | 207 | member_access ::= 208 | '.'[a-zA-Z_][a-zA-Z_]* 209 | 210 | field_access ::= 211 | '.-'[a-zA-Z_][a-zA-Z_]* 212 | 213 | new_class ::= 214 | ([a-zA-Z_][a-zA-Z_]*'.')([a-zA-Z_]+'.')* 215 | 216 | list ::= 217 | _list 218 | 219 | _list ::= 220 | '(' _anything* ')' 221 | 222 | vector ::= 223 | _vector 224 | 225 | _vector ::= 226 | '[' _anything* ']' 227 | 228 | hash_map ::= 229 | _hash_map 230 | 231 | _hash_map ::= 232 | '{' _hash_map_kv_pair* '}' 233 | | namespace_map 234 | 235 | namespace_map ::= 236 | '#::{' _hash_map_kv_pair* '}' 237 | | '\#:'[a-zA-Z\*\+\!#x2D-_\?][a-zA-Z0-9\*\+\!#x2D-_\?\':]* '{' _hash_map_kv_pair* '}' 238 | 239 | _hash_map_kv_pair ::= 240 | _hash_map_key _hash_map_value 241 | 242 | _hash_map_key ::= 243 | _anything 244 | 245 | _hash_map_value ::= 246 | _anything 247 | 248 | set ::= 249 | _set 250 | 251 | _set ::= 252 | '#{' _anything* '}' 253 | 254 | comment ::= 255 | semicolon 256 | | shebang_line 257 | | ignore_form 258 | | comment_macro 259 | 260 | semicolon ::= 261 | ';' '.'* 262 | 263 | shebang_line ::= 264 | '#!' '.'* 265 | 266 | ignore_form ::= 267 | '#_' _anything 268 | 269 | comment_macro ::= 270 | '(' 'comment' _anything* ')' 271 | 272 | _functions ::= 273 | anonymous_function 274 | | shorthand_function 275 | | defn 276 | 277 | anonymous_function ::= 278 | '(' 'fn' function_name? _after_the_fn_name ')' 279 | 280 | _after_the_fn_name ::= 281 | _single_arity_fn 282 | | _multi_arity_fn 283 | 284 | function_name ::= 285 | symbol 286 | 287 | _single_arity_fn ::= 288 | params function_body? 289 | 290 | _multi_arity_fn ::= 291 | ( '(' _single_arity_fn ')' )+ 292 | 293 | function_body ::= 294 | _anything+ 295 | 296 | params ::= 297 | vector 298 | 299 | shorthand_function ::= 300 | '#(' _anything* ')' 301 | 302 | shorthand_function_arg ::= 303 | '%'[1-9&]* 304 | 305 | defn ::= 306 | '(' ( 'defn' | 'defn-' ) metadata? function_name docstring? attr_map? _after_the_fn_name ')' 307 | 308 | docstring ::= 309 | string 310 | 311 | attr_map ::= 312 | hash_map 313 | 314 | metadata ::= 315 | metadata_shorthand+ 316 | | _metadata_map 317 | 318 | _metadata_map ::= 319 | '^' hash_map 320 | 321 | metadata_shorthand ::= 322 | '^:' _keyword_chars 323 | | '^"' ( '\"' | [^"] )* '"' 324 | | '^' _symbol_chars 325 | 326 | syntax_quote ::= 327 | '`' _anything 328 | 329 | var_quote ::= 330 | "#'" symbol 331 | 332 | unquote ::= 333 | '~' _anything 334 | 335 | unquote_splice ::= 336 | '~@' _anything 337 | 338 | gensym ::= 339 | [a-zA-Z\*\+\!#x2D-_\?][a-zA-Z0-9\*\+\!#x2D-_\?\':]*"\#" 340 | 341 | deref ::= 342 | '@' ( symbol | list ) 343 | 344 | tagged_literal ::= 345 | '#' ( _symbol_chars | _qualified_symbol ) _anything 346 | 347 | reader_conditional ::= 348 | _reader_conditional_symbol '(' ( keyword _anything )* ')' 349 | 350 | _reader_conditional_symbol ::= 351 | '#?' 352 | | '#?@' 353 | 354 | -------------------------------------------------------------------------------- /tree-sitter-cmake.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-cmake/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | source_file ::= 11 | _untrimmed_command_invocation* 12 | 13 | escape_sequence ::= 14 | _escape_identity 15 | | _escape_encoded 16 | | _escape_semicolon 17 | 18 | _escape_identity ::= 19 | '\'[^A-Za-z0-9;] 20 | 21 | _escape_encoded ::= 22 | '\t' 23 | | '\r' 24 | | '\n' 25 | 26 | _escape_semicolon ::= 27 | ';' 28 | | '\;' 29 | 30 | variable ::= 31 | ( [a-zA-Z0-9/_.+-] | escape_sequence | variable_ref )+ 32 | 33 | variable_ref ::= 34 | normal_var 35 | | env_var 36 | | cache_var 37 | 38 | normal_var ::= 39 | '$' '{' variable '}' 40 | 41 | env_var ::= 42 | '$' 'ENV' '{' variable '}' 43 | 44 | cache_var ::= 45 | '$' 'CACHE' '{' variable '}' 46 | 47 | gen_exp ::= 48 | '$' '<' _gen_exp_content? '>' 49 | 50 | _gen_exp_content ::= 51 | argument _gen_exp_arguments? 52 | 53 | _gen_exp_arguments ::= 54 | ':' ( argument [,;]? )* 55 | 56 | argument ::= 57 | bracket_argument 58 | | quoted_argument 59 | | unquoted_argument 60 | 61 | _untrimmed_argument ::= 62 | [ #x09#x0A#x0B#x0C#x0D] 63 | | bracket_comment 64 | | line_comment 65 | | argument 66 | | _paren_argument 67 | 68 | _paren_argument ::= 69 | '(' _untrimmed_argument* ')' 70 | 71 | quoted_argument ::= 72 | '"' quoted_element? '"' 73 | 74 | quoted_element ::= 75 | ( variable_ref | gen_exp | _quoted_text | escape_sequence )+ 76 | 77 | _quoted_text ::= 78 | ( '$' | [^\"] )+ 79 | 80 | unquoted_argument ::= 81 | ( variable_ref | gen_exp | _unquoted_text | escape_sequence )+ 82 | 83 | _unquoted_text ::= 84 | ( '$' | [^()#x23"\] )+ 85 | 86 | body ::= 87 | _untrimmed_command_invocation+ 88 | 89 | argument_list ::= 90 | _untrimmed_argument+ 91 | 92 | if_command ::= 93 | if [#x09 ]* '(' argument_list ')' 94 | 95 | elseif_command ::= 96 | elseif [#x09 ]* '(' argument_list ')' 97 | 98 | else_command ::= 99 | else [#x09 ]* '(' argument_list? ')' 100 | 101 | endif_command ::= 102 | endif [#x09 ]* '(' argument_list? ')' 103 | 104 | if_condition ::= 105 | if_command ( body | elseif_command | else_command )* endif_command 106 | 107 | foreach_command ::= 108 | foreach [#x09 ]* '(' argument_list ')' 109 | 110 | endforeach_command ::= 111 | endforeach [#x09 ]* '(' argument? ')' 112 | 113 | foreach_loop ::= 114 | foreach_command body endforeach_command 115 | 116 | while_command ::= 117 | while [#x09 ]* '(' argument_list ')' 118 | 119 | endwhile_command ::= 120 | endwhile [#x09 ]* '(' ( [ #x09#x0A#x0B#x0C#x0D]* argument [ #x09#x0A#x0B#x0C#x0D]* )? ')' 121 | 122 | while_loop ::= 123 | while_command body endwhile_command 124 | 125 | function_command ::= 126 | function [#x09 ]* '(' argument_list ')' 127 | 128 | endfunction_command ::= 129 | endfunction [#x09 ]* '(' argument_list? ')' 130 | 131 | function_def ::= 132 | function_command body endfunction_command 133 | 134 | macro_command ::= 135 | macro [#x09 ]* '(' argument_list ')' 136 | 137 | endmacro_command ::= 138 | endmacro [#x09 ]* '(' argument_list? ')' 139 | 140 | macro_def ::= 141 | macro_command body endmacro_command 142 | 143 | block_command ::= 144 | block [#x09 ]* '(' argument_list ')' 145 | 146 | endblock_command ::= 147 | endblock [#x09 ]* '(' argument_list? ')' 148 | 149 | block_def ::= 150 | block_command body endblock_command 151 | 152 | normal_command ::= 153 | identifier [#x09 ]* '(' argument_list? ')' 154 | 155 | _command_invocation ::= 156 | normal_command 157 | | if_condition 158 | | foreach_loop 159 | | while_loop 160 | | function_def 161 | | macro_def 162 | | block_def 163 | 164 | _untrimmed_command_invocation ::= 165 | [ #x09#x0A#x0B#x0C#x0D] 166 | | bracket_comment 167 | | line_comment 168 | | _command_invocation 169 | 170 | if ::= 171 | [iI][fF] 172 | 173 | elseif ::= 174 | [eE][lL][sS][eE][iI][fF] 175 | 176 | else ::= 177 | [eE][lL][sS][eE] 178 | 179 | endif ::= 180 | [eE][nN][dD][iI][fF] 181 | 182 | foreach ::= 183 | [fF][oO][rR][eE][aA][cC][hH] 184 | 185 | endforeach ::= 186 | [eE][nN][dD][fF][oO][rR][eE][aA][cC][hH] 187 | 188 | while ::= 189 | [wW][hH][iI][lL][eE] 190 | 191 | endwhile ::= 192 | [eE][nN][dD][wW][hH][iI][lL][eE] 193 | 194 | function ::= 195 | [fF][uU][nN][cC][tT][iI][oO][nN] 196 | 197 | endfunction ::= 198 | [eE][nN][dD][fF][uU][nN][cC][tT][iI][oO][nN] 199 | 200 | macro ::= 201 | [mM][aA][cC][rR][oO] 202 | 203 | endmacro ::= 204 | [eE][nN][dD][mM][aA][cC][rR][oO] 205 | 206 | block ::= 207 | [bB][lL][oO][cC][kK] 208 | 209 | endblock ::= 210 | [eE][nN][dD][bB][lL][oO][cC][kK] 211 | 212 | identifier ::= 213 | [A-Za-z_][A-Za-z0-9_]* 214 | 215 | integer ::= 216 | [+-]*[0-9]+ 217 | 218 | -------------------------------------------------------------------------------- /tree-sitter-css.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-css/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | stylesheet ::= 11 | _top_level_item* 12 | 13 | _top_level_item ::= 14 | declaration 15 | | rule_set 16 | | import_statement 17 | | media_statement 18 | | charset_statement 19 | | namespace_statement 20 | | keyframes_statement 21 | | supports_statement 22 | | at_rule 23 | 24 | import_statement ::= 25 | '@import' _value ( _query ( ',' _query )* )? ';' 26 | 27 | media_statement ::= 28 | '@media' _query ( ',' _query )* block 29 | 30 | charset_statement ::= 31 | '@charset' _value ';' 32 | 33 | namespace_statement ::= 34 | '@namespace' identifier? ( string_value | call_expression ) ';' 35 | 36 | keyframes_statement ::= 37 | ( '@keyframes' | '@'[-a-z]+'keyframes' ) identifier keyframe_block_list 38 | 39 | keyframe_block_list ::= 40 | '{' keyframe_block* '}' 41 | 42 | keyframe_block ::= 43 | ( from | to | integer_value ) block 44 | 45 | from ::= 46 | 'from' 47 | 48 | to ::= 49 | 'to' 50 | 51 | supports_statement ::= 52 | '@supports' _query block 53 | 54 | postcss_statement ::= 55 | at_keyword _value* ';' 56 | 57 | at_rule ::= 58 | at_keyword ( _query ( ',' _query )* )? ( ';' | block ) 59 | 60 | rule_set ::= 61 | selectors block 62 | 63 | selectors ::= 64 | _selector ( ',' _selector )* 65 | 66 | block ::= 67 | '{' _block_item* last_declaration? '}' 68 | 69 | _block_item ::= 70 | declaration 71 | | rule_set 72 | | import_statement 73 | | media_statement 74 | | charset_statement 75 | | namespace_statement 76 | | keyframes_statement 77 | | supports_statement 78 | | postcss_statement 79 | | at_rule 80 | 81 | _selector ::= 82 | universal_selector 83 | | identifier 84 | | class_selector 85 | | nesting_selector 86 | | pseudo_class_selector 87 | | pseudo_element_selector 88 | | id_selector 89 | | attribute_selector 90 | | string_value 91 | | child_selector 92 | | descendant_selector 93 | | sibling_selector 94 | | adjacent_sibling_selector 95 | | namespace_selector 96 | 97 | nesting_selector ::= 98 | '&' 99 | 100 | universal_selector ::= 101 | '*' 102 | 103 | class_selector ::= 104 | _selector? '.' identifier 105 | 106 | pseudo_class_selector ::= 107 | _selector? _pseudo_class_selector_colon identifier pseudo_class_arguments? 108 | 109 | pseudo_element_selector ::= 110 | _selector? '::' identifier pseudo_element_arguments? 111 | 112 | id_selector ::= 113 | _selector? '#' identifier 114 | 115 | attribute_selector ::= 116 | _selector? '[' ( identifier | namespace_selector ) ( ( '=' | '~=' | '^=' | '|=' | '*=' | '$=' ) _value )? ']' 117 | 118 | child_selector ::= 119 | _selector '>' _selector 120 | 121 | descendant_selector ::= 122 | _selector _descendant_operator _selector 123 | 124 | sibling_selector ::= 125 | _selector '~' _selector 126 | 127 | adjacent_sibling_selector ::= 128 | _selector '+' _selector 129 | 130 | namespace_selector ::= 131 | _selector '|' _selector 132 | 133 | pseudo_class_arguments ::= 134 | '(' ( ( _selector | _value+ ) ( ',' ( _selector | _value+ ) )* )? ')' 135 | 136 | pseudo_element_arguments ::= 137 | '(' ( ( _selector | _value+ ) ( ',' ( _selector | _value+ ) )* )? ')' 138 | 139 | declaration ::= 140 | identifier ':' _value ( ','? _value )* important? ';' 141 | 142 | last_declaration ::= 143 | identifier ':' _value ( ','? _value )* important? 144 | 145 | important ::= 146 | '!important' 147 | 148 | _query ::= 149 | identifier 150 | | feature_query 151 | | binary_query 152 | | unary_query 153 | | selector_query 154 | | parenthesized_query 155 | 156 | feature_query ::= 157 | '(' identifier ':' _value+ ')' 158 | 159 | parenthesized_query ::= 160 | '(' _query ')' 161 | 162 | binary_query ::= 163 | _query ( 'and' | 'or' ) _query 164 | 165 | unary_query ::= 166 | ( 'not' | 'only' ) _query 167 | 168 | selector_query ::= 169 | 'selector' '(' _selector ')' 170 | 171 | _value ::= 172 | identifier | plain_value | color_value | integer_value | float_value | string_value | grid_value | binary_expression | parenthesized_value | call_expression | important 173 | 174 | parenthesized_value ::= 175 | '(' _value ')' 176 | 177 | color_value ::= 178 | '#' [0-9a-fA-F]'{3,8}' 179 | 180 | string_value ::= 181 | "'" ([^'#x0A]|"\"("."|"#x0A"))* "'" 182 | | '"' ([^"#x0A]|'\'('.'|'#x0A'))* '"' 183 | 184 | integer_value ::= 185 | ( ( '+' | '-' )? [0-9]+ ) unit? 186 | 187 | float_value ::= 188 | ( ( '+' | '-' )? [0-9]* ( '.' [0-9]+ | [eE] '-'? [0-9]+ | '.' [0-9]+ [eE] '-'? [0-9]+ ) ) unit? 189 | 190 | unit ::= 191 | [a-zA-Z%]+ 192 | 193 | grid_value ::= 194 | '[' _value ( ',' _value )* ']' 195 | 196 | call_expression ::= 197 | identifier arguments 198 | 199 | binary_expression ::= 200 | _value ( '+' | '-' | '*' | '/' ) _value 201 | 202 | arguments ::= 203 | '(' ( _value+ ( ( ',' | ';' ) _value+ )* )? ')' 204 | 205 | identifier ::= 206 | ('--'|'-'?[a-zA-Z_])[a-zA-Z0-9-_]* 207 | 208 | at_keyword ::= 209 | '@'[a-zA-Z-_]+ 210 | 211 | js_comment ::= 212 | '//' '.'* 213 | 214 | comment ::= 215 | ( '/*' [^*]*'\'*+([^/*][^*]*'\'*+)* '/' ) 216 | 217 | plain_value ::= 218 | ( ( [-_] | '\/'[^\* #x09#x0A#x0B#x0C#x0D,;!{}()#x5B#x5D] )* [a-zA-Z] ( [^/ #x09#x0A#x0B#x0C#x0D,;!{}()#x5B#x5D] | '\/'[^\* #x09#x0A#x0B#x0C#x0D,;!{}()#x5B#x5D] )* ) 219 | 220 | -------------------------------------------------------------------------------- /tree-sitter-dockerfile.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-dockerfile/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | source_file ::= 11 | ( ( _instruction | comment ) '\n' )* 12 | 13 | _instruction ::= 14 | from_instruction 15 | | run_instruction 16 | | cmd_instruction 17 | | label_instruction 18 | | expose_instruction 19 | | env_instruction 20 | | add_instruction 21 | | copy_instruction 22 | | entrypoint_instruction 23 | | volume_instruction 24 | | user_instruction 25 | | workdir_instruction 26 | | arg_instruction 27 | | onbuild_instruction 28 | | stopsignal_instruction 29 | | healthcheck_instruction 30 | | shell_instruction 31 | | maintainer_instruction 32 | | cross_build_instruction 33 | 34 | from_instruction ::= 35 | [fF][rR][oO][mM] param? image_spec ( [aA][sS] image_alias )? 36 | 37 | run_instruction ::= 38 | [rR][uU][nN] ( param | mount_param )* ( json_string_array | shell_command ) 39 | 40 | cmd_instruction ::= 41 | [cC][mM][dD] ( json_string_array | shell_command ) 42 | 43 | label_instruction ::= 44 | [lL][aA][bB][eE][lL] label_pair+ 45 | 46 | expose_instruction ::= 47 | [eE][xX][pP][oO][sS][eE] ( expose_port | expansion )+ 48 | 49 | env_instruction ::= 50 | [eE][nN][vV] ( env_pair+ | _spaced_env_pair ) 51 | 52 | add_instruction ::= 53 | [aA][dD][dD] param* ( path _non_newline_whitespace )+ path 54 | 55 | copy_instruction ::= 56 | [cC][oO][pP][yY] param* ( path _non_newline_whitespace )+ path 57 | 58 | entrypoint_instruction ::= 59 | [eE][nN][tT][rR][yY][pP][oO][iI][nN][tT] ( json_string_array | shell_command ) 60 | 61 | volume_instruction ::= 62 | [vV][oO][lL][uU][mM][eE] ( json_string_array | path ( _non_newline_whitespace path )* ) 63 | 64 | user_instruction ::= 65 | [uU][sS][eE][rR] _user_name_or_group ( ':' _immediate_user_name_or_group )? 66 | 67 | _user_name_or_group ::= 68 | ( ([a-zA-Z][-A-Za-z0-9_]*|[0-9]+) | expansion ) _immediate_user_name_or_group_fragment* 69 | 70 | _immediate_user_name_or_group ::= 71 | _immediate_user_name_or_group_fragment+ 72 | 73 | _immediate_user_name_or_group_fragment ::= 74 | ([a-zA-Z][-a-zA-Z0-9_]*|[0-9]+) 75 | | _immediate_expansion 76 | 77 | workdir_instruction ::= 78 | [wW][oO][rR][kK][dD][iI][rR] path 79 | 80 | arg_instruction ::= 81 | [aA][rR][gG] [a-zA-Z0-9_]+ ( '=' ( double_quoted_string | single_quoted_string | unquoted_string ) )? 82 | 83 | onbuild_instruction ::= 84 | [oO][nN][bB][uU][iI][lL][dD] _instruction 85 | 86 | stopsignal_instruction ::= 87 | [sS][tT][oO][pP][sS][iI][gG][nN][aA][lL] _stopsignal_value 88 | 89 | _stopsignal_value ::= 90 | ( [A-Z0-9]+ | expansion ) ( [A-Z0-9]+ | _immediate_expansion )* 91 | 92 | healthcheck_instruction ::= 93 | [hH][eE][aA][lL][tT][hH][cC][hH][eE][cC][kK] ( 'NONE' | param* cmd_instruction ) 94 | 95 | shell_instruction ::= 96 | [sS][hH][eE][lL][lL] json_string_array 97 | 98 | maintainer_instruction ::= 99 | [mM][aA][iI][nN][tT][aA][iI][nN][eE][rR] '.'* 100 | 101 | cross_build_instruction ::= 102 | [cC][rR][oO][sS][sS]'_'[bB][uU][iI][lL][dD][a-zA-Z_]* '.'* 103 | 104 | path ::= 105 | ( [^- #x09#x0A#x0B#x0C#x0D\$] | expansion ) ( [^ #x09#x0A#x0B#x0C#x0D\$]+ | _immediate_expansion )* 106 | 107 | expansion ::= 108 | '$' _expansion_body 109 | 110 | _immediate_expansion ::= 111 | _imm_expansion 112 | 113 | _imm_expansion ::= 114 | '$' _expansion_body 115 | 116 | _expansion_body ::= 117 | variable 118 | | '{' [^\}]+ '}' 119 | 120 | variable ::= 121 | [a-zA-Z_][a-zA-Z0-9_]* 122 | 123 | env_pair ::= 124 | _env_key '=' ( double_quoted_string | single_quoted_string | unquoted_string )? 125 | 126 | _spaced_env_pair ::= 127 | _env_key [ #x09#x0A#x0B#x0C#x0D]+ ( double_quoted_string | single_quoted_string | unquoted_string ) 128 | 129 | _env_key ::= 130 | [a-zA-Z_][a-zA-Z0-9_]* 131 | 132 | expose_port ::= 133 | [0-9]+ ( '/tcp' | '/udp' )? 134 | 135 | label_pair ::= 136 | ( [-a-zA-Z0-9._]+ | double_quoted_string | single_quoted_string ) '=' ( double_quoted_string | single_quoted_string | unquoted_string ) 137 | 138 | image_spec ::= 139 | image_name image_tag? image_digest? 140 | 141 | image_name ::= 142 | ( [^@: #x09#x0A#x0B#x0C#x0D\$-] | expansion ) ( [^@: #x09#x0A#x0B#x0C#x0D\$]+ | _immediate_expansion )* 143 | 144 | image_tag ::= 145 | ':' ( [^@ #x09#x0A#x0B#x0C#x0D\$]+ | _immediate_expansion )+ 146 | 147 | image_digest ::= 148 | '@' ( [a-zA-Z0-9:]+ | _immediate_expansion )+ 149 | 150 | param ::= 151 | '--' [a-z][-a-z]* '=' [^ #x09#x0A#x0B#x0C#x0D]+ 152 | 153 | mount_param ::= 154 | '--' 'mount' '=' ( mount_param_param ( ',' mount_param_param )* ) 155 | 156 | mount_param_param ::= 157 | [^ #x09#x0A#x0B#x0C#x0D=,]+ '=' [^ #x09#x0A#x0B#x0C#x0D=,]+ 158 | 159 | image_alias ::= 160 | ( [-a-zA-Z0-9_]+ | expansion ) ( [-a-zA-Z0-9_]+ | _immediate_expansion )* 161 | 162 | shell_command ::= 163 | _comment_line* shell_fragment ( required_line_continuation _comment_line* shell_fragment )* 164 | 165 | shell_fragment ::= 166 | ( [,=-] | [^\#x5B#x0A#x23 #x09#x0A#x0B#x0C#x0D,=-][^\#x0A]* | '\'[^#x0A,=-] )+ 167 | 168 | line_continuation ::= 169 | '\\n' 170 | 171 | required_line_continuation ::= 172 | '\\n' 173 | 174 | _comment_line ::= 175 | _anon_comment '\n' 176 | 177 | _anon_comment ::= 178 | '#' '.'* 179 | 180 | json_string_array ::= 181 | '[' ( json_string ( ',' json_string )* )? ']' 182 | 183 | json_string ::= 184 | '"' ( [^"\]+ | json_escape_sequence )* '"' 185 | 186 | json_escape_sequence ::= 187 | '\'(?':'["\/bfnrt]|'u'[0-9A-Fa-f]'{4}') 188 | 189 | double_quoted_string ::= 190 | '"' ( [^"#x0A\\$]+ | double_quoted_escape_sequence | '\\' | _immediate_expansion )* '"' 191 | 192 | single_quoted_string ::= 193 | "'" ( [^'#x0A\]+ | single_quoted_escape_sequence | '\\' )* "'" 194 | 195 | unquoted_string ::= 196 | ( [^ #x09#x0A#x0B#x0C#x0D#x0A\"'\\$]+ | '\ ' | _immediate_expansion )+ 197 | 198 | double_quoted_escape_sequence ::= 199 | ( '\\' | '\"' ) 200 | 201 | single_quoted_escape_sequence ::= 202 | ( '\\' | "\'" ) 203 | 204 | _non_newline_whitespace ::= 205 | [#x09 ]+ 206 | 207 | comment ::= 208 | '#.'* 209 | 210 | -------------------------------------------------------------------------------- /tree-sitter-dot.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-dot/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | source_file ::= 11 | [sS][tT][rR][iI][cC][tT]? ( [gG][rR][aA][pP][hH] | [dD][iI][gG][rR][aA][pP][hH] ) id? block 12 | 13 | block ::= 14 | '{' stmt_list? '}' 15 | 16 | stmt_list ::= 17 | ( _stmt ';'? )+ 18 | 19 | _stmt ::= 20 | subgraph 21 | | node_stmt 22 | | edge_stmt 23 | | attr_stmt 24 | | attribute 25 | 26 | subgraph ::= 27 | ( [sS][uU][bB][gG][rR][aA][pP][hH] id? )? block 28 | 29 | node_stmt ::= 30 | node_id attr_list? 31 | 32 | edge_stmt ::= 33 | ( node_id | subgraph ) ( edgeop ( node_id | subgraph ) )+ attr_list? 34 | 35 | attr_stmt ::= 36 | ( [gG][rR][aA][pP][hH] | [nN][oO][dD][eE] | [eE][dD][gG][eE] ) attr_list 37 | 38 | node_id ::= 39 | id port? 40 | 41 | port ::= 42 | ':' id ( ':' id )? 43 | 44 | attr_list ::= 45 | ( '[' _a_list? ']' )+ 46 | 47 | _a_list ::= 48 | ( attribute ( ';' | ',' )? )+ 49 | 50 | attribute ::= 51 | id '=' id 52 | 53 | id ::= 54 | identifier 55 | | number_literal 56 | | html_string 57 | | string_literal ( '+' string_literal )* 58 | 59 | identifier ::= 60 | [_\p{XID_Start}][_\p{XID_Continue}]* 61 | 62 | number_literal ::= 63 | '-'?('.'[0-9]+|[0-9]+('.'[0-9]*)?) 64 | 65 | string_literal ::= 66 | '"' ([^"\]+|'\.')*'"' 67 | 68 | html_string ::= 69 | '<' _html_internal? '>' 70 | 71 | _html_internal ::= 72 | ( [^<>]+ | '<' _html_internal? '>' )+ 73 | 74 | edgeop ::= 75 | '->' 76 | | '--' 77 | 78 | comment ::= 79 | ( '//' '.'* | '/*' [^*]*'\'*+([^/*][^*]*'\'*+)* '/' ) 80 | 81 | preproc ::= 82 | '#' '.'* 83 | 84 | -------------------------------------------------------------------------------- /tree-sitter-elisp.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-elisp/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | source_file ::= 11 | _sexp* 12 | 13 | _sexp ::= 14 | special_form 15 | | function_definition 16 | | macro_definition 17 | | list 18 | | vector 19 | | hash_table 20 | | bytecode 21 | | string_text_properties 22 | | _atom 23 | | quote 24 | | unquote_splice 25 | | unquote 26 | 27 | special_form ::= 28 | '(' ( 'and' | 'catch' | 'cond' | 'condition-case' | 'defconst' | 'defvar' | 'function' | 'if' | 'interactive' | 'lambda' | 'let' | 'let*' | 'or' | 'prog1' | 'prog2' | 'progn' | 'quote' | 'save-current-buffer' | 'save-excursion' | 'save-restriction' | 'setq' | 'setq-default' | 'unwind-protect' | 'while' ) _sexp* ')' 29 | 30 | function_definition ::= 31 | '(' ( 'defun' | 'defsubst' ) symbol _sexp? string? _sexp* ')' 32 | 33 | macro_definition ::= 34 | '(' 'defmacro' symbol _sexp? string? _sexp* ')' 35 | 36 | _atom ::= 37 | float 38 | | integer 39 | | char 40 | | string 41 | | byte_compiled_file_name 42 | | symbol 43 | 44 | float ::= 45 | [+-]?[0-9]*'.'[0-9]+ 46 | | [+-]?[0-9]+[eE][0-9]+ 47 | | [+-]?[0-9]*'.'[0-9]+[eE][0-9]+ 48 | | '-'?'1.0'[eE]'\'+'INF' 49 | | '-'?'0.0'[eE]'\'+'NaN' 50 | 51 | integer ::= 52 | [+-]?[0-9]+'.'? 53 | | '#'([box]|[0-9][0-9]?'r')[0-9a-zA-Z] 54 | 55 | char ::= 56 | '\'?('\.'|'.') 57 | | '\'?'\N\{'[^}]+'\}' 58 | | '\'?'\u'[0-9a-fA-F]'{4}' 59 | | '\'?'\U'[0-9a-fA-F]'{8}' 60 | | '\'?'\x'[0-9a-fA-F]+ 61 | | '\'?'\'[0-7]'{1,3}' 62 | | '\'?('\'(([CMSHsA]'-')|'\^'))+('\;'|'.') 63 | | '\'?'\M-\'[0-9]'{1,3}' 64 | 65 | string ::= 66 | ( '"' ( [^"\] | '\\' ('.'|'#x0A') )* '"' ) 67 | 68 | byte_compiled_file_name ::= 69 | '#$' 70 | 71 | symbol ::= 72 | 'nil' 73 | | 't' 74 | | 'defun' 75 | | 'defsubst' 76 | | 'defmacro' 77 | | '\'('`'|"'"|",") 78 | | ([^?#x23 #x0A #x09#x0A#x0B#x0C#x0D#x0C()#x5B#x5D'`,\";]|"\.")([^#x23 #x0A #x09#x0A#x0B#x0C#x0D#x0C()#x5B#x5D'`,\";]|"\.")* 79 | | '##' 80 | 81 | quote ::= 82 | ( "#'" | "'" | '`' ) _sexp 83 | 84 | unquote_splice ::= 85 | ',@' _sexp 86 | 87 | unquote ::= 88 | ',' _sexp 89 | 90 | dot ::= 91 | '.' 92 | 93 | list ::= 94 | '(' ( _sexp* ) ')' 95 | 96 | vector ::= 97 | '[' _sexp* ']' 98 | 99 | bytecode ::= 100 | '#[' _sexp* ']' 101 | 102 | string_text_properties ::= 103 | '#(' string _sexp* ')' 104 | 105 | hash_table ::= 106 | '#s(hash-table' _sexp* ')' 107 | 108 | comment ::= 109 | ';.'* 110 | 111 | -------------------------------------------------------------------------------- /tree-sitter-embedded-template.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-embedded-template/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | template ::= 11 | ( directive | output_directive | comment_directive | graphql_directive | content )* 12 | 13 | code ::= 14 | ( [^%=_-]+|[%=_-] | '%%>' )+ 15 | 16 | content ::= 17 | ( [^<]+|'<' | '<%%' )+ 18 | 19 | directive ::= 20 | ( '<%' | '<%_' | '<%|' ) code? ( '%>' | '-%>' | '_%>' ) 21 | 22 | output_directive ::= 23 | ( '<%=' | '<%==' | '<%|=' | '<%|==' | '<%-' ) code? ( '%>' | '-%>' | '=%>' ) 24 | 25 | comment_directive ::= 26 | '<%#' code? '%>' 27 | 28 | graphql_directive ::= 29 | '<%graphql' code? '%>' 30 | 31 | -------------------------------------------------------------------------------- /tree-sitter-eno.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-eno/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | document ::= 11 | _instruction* 12 | 13 | _commentOrEmpty ::= 14 | comment 15 | | _emptyLine 16 | 17 | _elementOrFieldsetOrList ::= 18 | _escapedOrUnescapedKey ( elementOperator | copyOperator token ) _endOfLine 19 | 20 | _emptyLine ::= 21 | [ #x09\uFEFF\u2060\u200B]*'#x0A' 22 | 23 | _escapedOrUnescapedKey ::= 24 | key 25 | | escapeOperator escapedKey escapeOperator 26 | 27 | _escapedOrUnescapedSectionKey ::= 28 | sectionKey 29 | | escapeOperator escapedKey escapeOperator 30 | 31 | _instruction ::= 32 | _commentOrEmpty 33 | | element 34 | | empty 35 | | field 36 | | fieldset 37 | | list 38 | | multilineField 39 | | section 40 | 41 | comment ::= 42 | ( commentOperator token? _endOfLine )+ 43 | 44 | continuation ::= 45 | ( directContinuationOperator | spacedContinuationOperator ) token _endOfLine 46 | 47 | element ::= 48 | _elementOrFieldsetOrList 49 | 50 | empty ::= 51 | _escapedOrUnescapedKey _endOfLine 52 | 53 | entry ::= 54 | _escapedOrUnescapedKey entryOperator token? _endOfLine ( _commentOrEmpty* continuation )* 55 | 56 | field ::= 57 | _escapedOrUnescapedKey elementOperator token _endOfLine ( _commentOrEmpty* continuation )* 58 | | _escapedOrUnescapedKey elementOperator _endOfLine ( _commentOrEmpty* continuation )+ 59 | 60 | fieldset ::= 61 | _elementOrFieldsetOrList ( _commentOrEmpty* entry )+ 62 | 63 | item ::= 64 | itemOperator token? _endOfLine ( _commentOrEmpty* continuation )* 65 | 66 | key ::= 67 | [^`>:=<#x2D-#x23|\ #x09#x0A#x0B#x0C#x0D]|[^`>:=<#x2D-#x23|\ #x09#x0A#x0B#x0C#x0D][^:=<#x0A]*[^:=< #x09#x0A#x0B#x0C#x0D] 68 | 69 | list ::= 70 | _elementOrFieldsetOrList ( _commentOrEmpty* item )+ 71 | 72 | multilineField ::= 73 | multilineFieldOperator multilineFieldKey _endOfLine multilineFieldValue? _multilineFieldEnd multilineFieldOperator multilineFieldKey _endOfLine 74 | 75 | multilineFieldValue ::= 76 | ( _multilineFieldLine _endOfLine )+ 77 | 78 | section ::= 79 | _sectionDescend sectionOperator _escapedOrUnescapedSectionKey ( ( copyOperator | deepCopyOperator ) token )? _endOfLine _instruction* _sectionAscend 80 | 81 | sectionKey ::= 82 | [^`< #x09#x0A#x0B#x0C#x0D]|[^`< #x09#x0A#x0B#x0C#x0D][^<#x0A]*[^< #x09#x0A#x0B#x0C#x0D] 83 | 84 | token ::= 85 | '\S'|'\S'[^#x0A]*'\S' 86 | 87 | directContinuationOperator ::= 88 | '|' 89 | 90 | spacedContinuationOperator ::= 91 | '\\' 92 | 93 | commentOperator ::= 94 | '>' 95 | 96 | copyOperator ::= 97 | '<' 98 | 99 | deepCopyOperator ::= 100 | '<<' 101 | 102 | entryOperator ::= 103 | '=' 104 | 105 | itemOperator ::= 106 | '-' 107 | 108 | elementOperator ::= 109 | ':' 110 | 111 | sectionOperator ::= 112 | '#'+ 113 | 114 | -------------------------------------------------------------------------------- /tree-sitter-fennel.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-fennel/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | program ::= 11 | _sexp* 12 | 13 | _sexp ::= 14 | _special_form 15 | | symbol 16 | | multi_symbol 17 | | list 18 | | sequential_table 19 | | table 20 | | _literal 21 | 22 | _special_form ::= 23 | fn 24 | | lambda 25 | | hashfn 26 | | match 27 | | let 28 | | global 29 | | local 30 | | var 31 | | set 32 | | each 33 | | collect 34 | | icollect 35 | | accumulate 36 | | for 37 | | quote 38 | 39 | each ::= 40 | '(' 'each' '[' iter_bindings ']' _sexp* ')' 41 | 42 | iter_bindings ::= 43 | _binding* _sexp ( ':until' _sexp )? 44 | 45 | for ::= 46 | '(' 'for' for_clause _sexp* ')' 47 | 48 | for_clause ::= 49 | '[' symbol _sexp _sexp _sexp? ']' 50 | 51 | let ::= 52 | '(' 'let' let_clause _sexp* ')' 53 | 54 | let_clause ::= 55 | '[' ( _binding _sexp )* ']' 56 | 57 | global ::= 58 | '(' 'global' _binding _sexp ')' 59 | 60 | local ::= 61 | '(' 'local' _binding _sexp ')' 62 | 63 | var ::= 64 | '(' 'var' _binding _sexp ')' 65 | 66 | set ::= 67 | '(' 'set' _assignment _sexp ')' 68 | 69 | _binding ::= 70 | multi_value_binding 71 | | _non_multi_value_binding 72 | 73 | multi_value_binding ::= 74 | '(' _non_multi_value_binding* ')' 75 | 76 | _non_multi_value_binding ::= 77 | binding 78 | | sequential_table_binding 79 | | table_binding 80 | 81 | binding ::= 82 | symbol 83 | 84 | sequential_table_binding ::= 85 | '[' _non_multi_value_binding* ( '&' binding )? ']' 86 | 87 | table_binding ::= 88 | '{' ( ':' binding | '&as' binding | _sexp _non_multi_value_binding )* '}' 89 | 90 | _assignment ::= 91 | multi_value_assignment 92 | | _non_multi_value_assignment 93 | 94 | multi_value_assignment ::= 95 | '(' _non_multi_value_assignment* ')' 96 | 97 | _non_multi_value_assignment ::= 98 | assignment 99 | | sequential_table_assignment 100 | | table_assignment 101 | 102 | assignment ::= 103 | symbol 104 | | multi_symbol 105 | 106 | sequential_table_assignment ::= 107 | '[' _non_multi_value_assignment* ']' 108 | 109 | table_assignment ::= 110 | '{' ( ':' assignment | _sexp _non_multi_value_assignment )* '}' 111 | 112 | hashfn ::= 113 | '(' 'hashfn' _sexp* ')' 114 | | '#' _sexp 115 | 116 | fn ::= 117 | '(' 'fn' _function_body ')' 118 | 119 | lambda ::= 120 | '(' ( 'lambda' | 'λ' ) _function_body ')' 121 | 122 | _function_body ::= 123 | ( symbol | multi_symbol )? parameters ( string? _sexp+ )? 124 | 125 | parameters ::= 126 | '[' ( _binding | vararg )* ']' 127 | 128 | match ::= 129 | '(' 'match' _sexp ( _pattern _sexp )* ')' 130 | 131 | _pattern ::= 132 | _simple_pattern 133 | | where_pattern 134 | | guard_pattern 135 | 136 | _simple_pattern ::= 137 | multi_value_pattern 138 | | _non_multi_value_pattern 139 | 140 | guard_pattern ::= 141 | '(' _simple_pattern '?' _sexp+ ')' 142 | 143 | where_pattern ::= 144 | '(' 'where' ( _simple_pattern | '(' 'or' _simple_pattern* ')' ) _sexp* ')' 145 | 146 | multi_value_pattern ::= 147 | '(' _non_multi_value_pattern* ')' 148 | 149 | _non_multi_value_pattern ::= 150 | _literal 151 | | symbol 152 | | multi_symbol 153 | | sequential_table_pattern 154 | | table_pattern 155 | 156 | sequential_table_pattern ::= 157 | '[' _non_multi_value_pattern* ']' 158 | 159 | table_pattern ::= 160 | '{' ( ':' _simple_pattern | _sexp _non_multi_value_pattern )* '}' 161 | 162 | collect ::= 163 | '(' 'collect' '[' iter_bindings ']' _sexp* ')' 164 | 165 | icollect ::= 166 | '(' 'icollect' '[' iter_bindings ']' _sexp* ')' 167 | 168 | accumulate ::= 169 | '(' 'accumulate' '[' _binding _sexp iter_bindings ']' _sexp* ')' 170 | 171 | quote ::= 172 | '(' 'quote' _quoted_sexp ')' 173 | | ( "'" | '`' ) _quoted_sexp 174 | 175 | unquote ::= 176 | ',' _sexp 177 | 178 | _quoted_sexp ::= 179 | unquote 180 | | symbol 181 | | multi_symbol 182 | | multi_symbol_method 183 | | quoted_list 184 | | quoted_sequential_table 185 | | quoted_table 186 | | _literal 187 | 188 | quoted_list ::= 189 | '(' _quoted_sexp* ')' 190 | 191 | quoted_sequential_table ::= 192 | '[' _quoted_sexp* ']' 193 | 194 | quoted_table ::= 195 | '{' _quoted_sexp* '}' 196 | 197 | list ::= 198 | '(' ( _sexp | multi_symbol_method ) _sexp* ')' 199 | 200 | sequential_table ::= 201 | '[' _sexp* ']' 202 | 203 | table_pair ::= 204 | ':' binding | string _sexp | ( symbol | multi_symbol ) _sexp 205 | 206 | table ::= 207 | '{' table_pair* '}' 208 | 209 | _literal ::= 210 | string 211 | | number 212 | | boolean 213 | | vararg 214 | | nil 215 | | nil_safe 216 | 217 | nil ::= 218 | 'nil' 219 | 220 | nil_safe ::= 221 | '?.' 222 | 223 | vararg ::= 224 | '...' 225 | 226 | boolean ::= 227 | 'true' 228 | | 'false' 229 | 230 | string ::= 231 | ':'[^(){}#x5B#x5D"'~;,@` #x09#x0A#x0B#x0C#x0D]+ 232 | | '"' ( [^"\]+ | escape_sequence )* '"' 233 | 234 | escape_sequence ::= 235 | ( '\\' ( [^xu0-9] | [0-9]'{1,3}' | 'x'[0-9a-fA-F]'{2}' | 'u{'[0-9a-fA-F]+'}' ) ) 236 | 237 | number ::= 238 | ( ( '-' | '+' )? ( [0-9][_0-9]* | '.' [0-9][_0-9]* | [0-9][_0-9]* '.' [0-9][_0-9]*? ) ( ( 'e' | 'E' ) ( '-' | '+' )? [0-9][_0-9]* )? | ( '-' | '+' )? ( '0x' | '0X' ) ( [a-fA-F0-9][_a-fA-F0-9]* | '.' [a-fA-F0-9][_a-fA-F0-9]* | [a-fA-F0-9][_a-fA-F0-9]* '.' [a-fA-F0-9][_a-fA-F0-9]*? ) ( ( 'p' | 'P' ) ( '-' | '+' )? [a-fA-F0-9][_a-fA-F0-9]* )? ) 239 | 240 | multi_symbol ::= 241 | symbol ( '.' symbol_immediate )+ 242 | 243 | multi_symbol_method ::= 244 | ( symbol | multi_symbol ) ':' symbol_immediate 245 | 246 | symbol ::= 247 | ( ':' | '.' [^(){}#x5B#x5D"'~;,@` #x09#x0A#x0B#x0C#x0D]* | [^#x23(){}#x5B#x5D"'~;,@`.: #x09#x0A#x0B#x0C#x0D][^(){}#x5B#x5D"'~;,@`.: #x09#x0A#x0B#x0C#x0D]* ) 248 | 249 | symbol_immediate ::= 250 | ( ':' | '.' [^(){}#x5B#x5D"'~;,@` #x09#x0A#x0B#x0C#x0D]* | [^#x23(){}#x5B#x5D"'~;,@`.: #x09#x0A#x0B#x0C#x0D][^(){}#x5B#x5D"'~;,@`.: #x09#x0A#x0B#x0C#x0D]* ) 251 | 252 | comment ::= 253 | ( ';' '.'* ) 254 | 255 | -------------------------------------------------------------------------------- /tree-sitter-graphql.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-graphql/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | source_file ::= 11 | Document 12 | 13 | comma ::= 14 | ',' 15 | 16 | Document ::= 17 | Definition+ 18 | 19 | Definition ::= 20 | ExecutableDefinition 21 | | TypeSystemDefinition 22 | | TypeSystemExtension 23 | 24 | ExecutableDefinition ::= 25 | OperationDefinition 26 | | FragmentDefinition 27 | 28 | OperationDefinition ::= 29 | SelectionSet 30 | | OperationType Name? VariableDefinitions? Directives? SelectionSet 31 | 32 | OperationType ::= 33 | 'query' 34 | | 'mutation' 35 | | 'subscription' 36 | 37 | SelectionSet ::= 38 | '{' Selection+ '}' 39 | 40 | Selection ::= 41 | Field 42 | | FragmentSpread 43 | | InlineFragment 44 | 45 | Field ::= 46 | Alias? Name Arguments? Directives? SelectionSet? 47 | 48 | Alias ::= 49 | Name ':' 50 | 51 | Arguments ::= 52 | '(' Argument+ ')' 53 | 54 | Argument ::= 55 | Name ':' Value 56 | 57 | FragmentSpread ::= 58 | '...' FragmentName Directives? 59 | 60 | InlineFragment ::= 61 | '...' TypeCondition? Directives? SelectionSet 62 | 63 | FragmentDefinition ::= 64 | 'fragment' FragmentName TypeCondition Directives? SelectionSet 65 | 66 | FragmentName ::= 67 | Name 68 | 69 | TypeCondition ::= 70 | 'on' NamedType 71 | 72 | Value ::= 73 | Variable 74 | | IntValue 75 | | FloatValue 76 | | StringValue 77 | | BooleanValue 78 | | NullValue 79 | | EnumValue 80 | | ListValue 81 | | ObjectValue 82 | 83 | BooleanValue ::= 84 | 'false' 85 | | 'true' 86 | 87 | NullValue ::= 88 | 'null' 89 | 90 | EnumValue ::= 91 | Name 92 | 93 | ListValue ::= 94 | '[' Value* ']' 95 | 96 | ObjectValue ::= 97 | '{' ObjectField* '}' 98 | 99 | ObjectField ::= 100 | Name ':' Value 101 | 102 | IntValue ::= 103 | '-'?('0'|[1-9][0-9]*) 104 | 105 | FloatValue ::= 106 | ( '-'?('0'|[1-9][0-9]*) ( '.'[0-9]+ | ('e'|'E')('\'+|'-')?[0-9]+ | '.'[0-9]+ ('e'|'E')('\'+|'-')?[0-9]+ ) ) 107 | 108 | StringValue ::= 109 | '"""' ([^"]|'#x0A'|'""'?[^"])* '"""' 110 | | '"' [^"\#x0A]* '"' 111 | 112 | VariableDefinitions ::= 113 | '(' VariableDefinition+ ')' 114 | 115 | VariableDefinition ::= 116 | Variable ':' Type DefaultValue? 117 | 118 | Variable ::= 119 | '$' Name 120 | 121 | DefaultValue ::= 122 | '=' Value 123 | 124 | Type ::= 125 | NamedType 126 | | ListType 127 | | NonNullType 128 | 129 | NamedType ::= 130 | Name 131 | 132 | ListType ::= 133 | '[' Type ']' 134 | 135 | NonNullType ::= 136 | ( NamedType | ListType ) '!' 137 | 138 | Directives ::= 139 | Directive+ 140 | 141 | Directive ::= 142 | '@' Name Arguments? 143 | 144 | TypeSystemDefinition ::= 145 | SchemaDefinition 146 | | TypeDefinition 147 | | DirectiveDefinition 148 | 149 | TypeSystemExtension ::= 150 | SchemaExtension 151 | | TypeExtension 152 | 153 | SchemaDefinition ::= 154 | 'schema' Directives? '{' OperationTypeDefinition+ '}' 155 | 156 | SchemaExtension ::= 157 | 'extend' 'schema' Directives? '{' OperationTypeDefinition+ '}' | 'extend' 'schema' Directives 158 | 159 | TypeExtension ::= 160 | ScalarTypeExtension 161 | | ObjectTypeExtension 162 | | InterfaceTypeExtension 163 | | UnionTypeExtension 164 | | EnumTypeExtension 165 | | InputObjectTypeExtension 166 | 167 | ScalarTypeExtension ::= 168 | 'extend' 'scalar' Name Directives 169 | 170 | ObjectTypeExtension ::= 171 | 'extend' 'type' Name ImplementsInterfaces? Directives? FieldsDefinition | 'extend' 'type' Name ImplementsInterfaces? Directives | 'extend' 'type' Name ImplementsInterfaces 172 | 173 | InterfaceTypeExtension ::= 174 | 'extend' 'interface' Name Directives? FieldsDefinition | 'extend' 'interface' Name Directives 175 | 176 | UnionTypeExtension ::= 177 | 'extend' 'union' Name Directives? UnionMemberTypes 178 | | 'extend' 'union' Name Directives 179 | 180 | EnumTypeExtension ::= 181 | 'extend' 'enum' Name Directives? EnumValuesDefinition | 'extend' 'enum' Name Directives 182 | 183 | InputObjectTypeExtension ::= 184 | 'extend' 'input' Name Directives? InputFieldsDefinition | 'extend' 'input' Name Directives 185 | 186 | OperationTypeDefinition ::= 187 | OperationType ':' NamedType 188 | 189 | Description ::= 190 | StringValue 191 | 192 | TypeDefinition ::= 193 | ScalarTypeDefinition 194 | | ObjectTypeDefinition 195 | | InterfaceTypeDefinition 196 | | UnionTypeDefinition 197 | | EnumTypeDefinition 198 | | InputObjectTypeDefinition 199 | 200 | ScalarTypeDefinition ::= 201 | Description? 'scalar' Name Directives? 202 | 203 | ObjectTypeDefinition ::= 204 | Description? 'type' Name ImplementsInterfaces? Directives? FieldsDefinition? 205 | 206 | ImplementsInterfaces ::= 207 | 'implements' '&'? NamedType ( '&' NamedType )* 208 | 209 | FieldsDefinition ::= 210 | '{' FieldDefinition+ '}' 211 | 212 | FieldDefinition ::= 213 | Description? Name ArgumentsDefinition? ':' Type Directive? 214 | 215 | ArgumentsDefinition ::= 216 | '(' InputValueDefinition+ ')' 217 | 218 | InputValueDefinition ::= 219 | Description? Name ':' Type DefaultValue? Directives? 220 | 221 | InterfaceTypeDefinition ::= 222 | Description? 'interface' Name Directives? FieldsDefinition? 223 | 224 | UnionTypeDefinition ::= 225 | Description? 'union' Name Directives? UnionMemberTypes? 226 | 227 | UnionMemberTypes ::= 228 | '=' '|'? NamedType ( '|' NamedType )* 229 | 230 | EnumTypeDefinition ::= 231 | Description? 'enum' Name Directives? EnumValuesDefinition? 232 | 233 | EnumValuesDefinition ::= 234 | '{' EnumValueDefinition+ '}' 235 | 236 | EnumValueDefinition ::= 237 | Description? EnumValue Directives? 238 | 239 | InputObjectTypeDefinition ::= 240 | Description? 'input' Name Directives? InputFieldsDefinition? 241 | 242 | InputFieldsDefinition ::= 243 | '{' InputValueDefinition+ '}' 244 | 245 | DirectiveDefinition ::= 246 | Description? 'directive' '@' Name ArgumentsDefinition? 'on' DirectiveLocations 247 | 248 | DirectiveLocations ::= 249 | '|'? DirectiveLocation ( '|' DirectiveLocation )* 250 | 251 | DirectiveLocation ::= 252 | ExecutableDirectiveLocation 253 | | TypeSystemDirectiveLocation 254 | 255 | ExecutableDirectiveLocation ::= 256 | 'QUERY' 257 | | 'MUTATION' 258 | | 'SUBSCRIPTION' 259 | | 'FIELD' 260 | | 'FRAGMENT_DEFINITION' 261 | | 'FRAGMENT_SPREAD' 262 | | 'INLINE_FRAGMENT' 263 | | 'VARIABLE_DEFINITION' 264 | 265 | TypeSystemDirectiveLocation ::= 266 | 'SCHEMA' 267 | | 'SCALAR' 268 | | 'OBJECT' 269 | | 'FIELD_DEFINITION' 270 | | 'ARGUMENT_DEFINITION' 271 | | 'INTERFACE' 272 | | 'UNION' 273 | | 'ENUM' 274 | | 'ENUM_VALUE' 275 | | 'INPUT_OBJECT' 276 | | 'INPUT_FIELD_DEFINITION' 277 | 278 | comment ::= 279 | ( '# ' '.'* ) 280 | 281 | Name ::= 282 | [_A-Za-z][_0-9A-Za-z]* 283 | 284 | -------------------------------------------------------------------------------- /tree-sitter-hcl.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-hcl/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | config_file ::= 11 | body | object 12 | 13 | body ::= 14 | ( attribute | block )+ 15 | 16 | attribute ::= 17 | identifier '=' expression 18 | 19 | block ::= 20 | identifier ( string_lit | identifier )* block_start body? block_end 21 | 22 | block_start ::= 23 | '{' 24 | 25 | block_end ::= 26 | '}' 27 | 28 | identifier ::= 29 | ( ( '\p{ID_Start}' | '_' ) ( '\p{ID_Continue}' | '-' )* ) 30 | 31 | expression ::= 32 | _expr_term | conditional 33 | 34 | _expr_term ::= 35 | literal_value 36 | | template_expr 37 | | collection_value 38 | | variable_expr 39 | | function_call 40 | | for_expr 41 | | operation 42 | | _expr_term index 43 | | _expr_term get_attr 44 | | _expr_term splat 45 | | '(' expression ')' 46 | 47 | literal_value ::= 48 | numeric_lit 49 | | bool_lit 50 | | null_lit 51 | | string_lit 52 | 53 | numeric_lit ::= 54 | [0-9]+('.'[0-9]+([eE][-+]?[0-9]+)?)? 55 | | '0x'[0-9a-zA-Z]+ 56 | 57 | bool_lit ::= 58 | 'true' 59 | | 'false' 60 | 61 | null_lit ::= 62 | 'null' 63 | 64 | string_lit ::= 65 | quoted_template_start template_literal? quoted_template_end 66 | 67 | collection_value ::= 68 | tuple 69 | | object 70 | 71 | _comma ::= 72 | ',' 73 | 74 | tuple ::= 75 | tuple_start _tuple_elems? tuple_end 76 | 77 | tuple_start ::= 78 | '[' 79 | 80 | tuple_end ::= 81 | ']' 82 | 83 | _tuple_elems ::= 84 | expression ( _comma expression )* _comma? 85 | 86 | object ::= 87 | object_start _object_elems? object_end 88 | 89 | object_start ::= 90 | '{' 91 | 92 | object_end ::= 93 | '}' 94 | 95 | _object_elems ::= 96 | object_elem ( _comma? object_elem )* _comma? 97 | 98 | object_elem ::= 99 | expression ( '=' | ':' ) expression 100 | 101 | index ::= 102 | new_index 103 | | legacy_index 104 | 105 | new_index ::= 106 | '[' expression ']' 107 | 108 | legacy_index ::= 109 | '.' [0-9]+ 110 | 111 | get_attr ::= 112 | '.' identifier 113 | 114 | splat ::= 115 | attr_splat 116 | | full_splat 117 | 118 | attr_splat ::= 119 | '.*' ( get_attr | index )* 120 | 121 | full_splat ::= 122 | '[*]' ( get_attr | index )* 123 | 124 | for_expr ::= 125 | for_tuple_expr 126 | | for_object_expr 127 | 128 | for_tuple_expr ::= 129 | tuple_start for_intro expression for_cond? tuple_end 130 | 131 | for_object_expr ::= 132 | object_start for_intro expression '=>' expression ellipsis? for_cond? object_end 133 | 134 | for_intro ::= 135 | 'for' identifier ( ',' identifier )? 'in' expression ':' 136 | 137 | for_cond ::= 138 | 'if' expression 139 | 140 | variable_expr ::= 141 | identifier 142 | 143 | function_call ::= 144 | identifier _function_call_start function_arguments? _function_call_end 145 | 146 | _function_call_start ::= 147 | '(' 148 | 149 | _function_call_end ::= 150 | ')' 151 | 152 | function_arguments ::= 153 | expression ( _comma expression )* ( _comma | ellipsis )? 154 | 155 | ellipsis ::= 156 | '...' 157 | 158 | conditional ::= 159 | expression '?' expression ':' expression 160 | 161 | operation ::= 162 | unary_operation 163 | | binary_operation 164 | 165 | unary_operation ::= 166 | ( '-' | '!' ) _expr_term 167 | 168 | binary_operation ::= 169 | _expr_term ( '*' | '/' | '%' ) _expr_term 170 | | _expr_term ( '+' | '-' ) _expr_term 171 | | _expr_term ( '>' | '>=' | '<' | '<=' ) _expr_term 172 | | _expr_term ( '==' | '!=' ) _expr_term 173 | | _expr_term ( '&&' ) _expr_term 174 | | _expr_term ( '||' ) _expr_term 175 | 176 | template_expr ::= 177 | quoted_template 178 | | heredoc_template 179 | 180 | quoted_template ::= 181 | quoted_template_start _template? quoted_template_end 182 | 183 | heredoc_template ::= 184 | heredoc_start heredoc_identifier _template? heredoc_identifier 185 | 186 | heredoc_start ::= 187 | '<<' 188 | | '<<-' 189 | 190 | strip_marker ::= 191 | '~' 192 | 193 | _template ::= 194 | ( template_interpolation | template_directive | template_literal )+ 195 | 196 | template_literal ::= 197 | _template_literal_chunk+ 198 | 199 | template_interpolation ::= 200 | template_interpolation_start strip_marker? expression? strip_marker? template_interpolation_end 201 | 202 | template_directive ::= 203 | template_for 204 | | template_if 205 | 206 | template_for ::= 207 | template_for_start _template? template_for_end 208 | 209 | template_for_start ::= 210 | template_directive_start strip_marker? 'for' identifier ( ',' identifier )? 'in' expression strip_marker? template_directive_end 211 | 212 | template_for_end ::= 213 | template_directive_start strip_marker? 'endfor' strip_marker? template_directive_end 214 | 215 | template_if ::= 216 | template_if_intro _template? ( template_else_intro _template? )? template_if_end 217 | 218 | template_if_intro ::= 219 | template_directive_start strip_marker? 'if' expression strip_marker? template_directive_end 220 | 221 | template_else_intro ::= 222 | template_directive_start strip_marker? 'else' strip_marker? template_directive_end 223 | 224 | template_if_end ::= 225 | template_directive_start strip_marker? 'endif' strip_marker? template_directive_end 226 | 227 | comment ::= 228 | ( '#' '.'* | '//' '.'* | '/*' [^*]*'\'*+([^/*][^*]*'\'*+)* '/' ) 229 | 230 | _whitespace ::= 231 | [ #x09#x0A#x0B#x0C#x0D] 232 | 233 | -------------------------------------------------------------------------------- /tree-sitter-html.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-html/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | fragment ::= 11 | _node* 12 | 13 | doctype ::= 14 | ']+ '>' 15 | 16 | _doctype ::= 17 | [Dd][Oo][Cc][Tt][Yy][Pp][Ee] 18 | 19 | _node ::= 20 | doctype 21 | | entity 22 | | text 23 | | element 24 | | script_element 25 | | style_element 26 | | erroneous_end_tag 27 | 28 | element ::= 29 | start_tag _node* ( end_tag | _implicit_end_tag ) 30 | | self_closing_tag 31 | 32 | script_element ::= 33 | script_start_tag raw_text? end_tag 34 | 35 | style_element ::= 36 | style_start_tag raw_text? end_tag 37 | 38 | start_tag ::= 39 | '<' _start_tag_name attribute* '>' 40 | 41 | script_start_tag ::= 42 | '<' _script_start_tag_name attribute* '>' 43 | 44 | style_start_tag ::= 45 | '<' _style_start_tag_name attribute* '>' 46 | 47 | self_closing_tag ::= 48 | '<' _start_tag_name attribute* '/>' 49 | 50 | end_tag ::= 51 | '' 52 | 53 | erroneous_end_tag ::= 54 | '' 55 | 56 | attribute ::= 57 | attribute_name ( '=' ( attribute_value | quoted_attribute_value ) )? 58 | 59 | attribute_name ::= 60 | [^<>"'/= #x09#x0A#x0B#x0C#x0D]+ 61 | 62 | attribute_value ::= 63 | [^<>"'= #x09#x0A#x0B#x0C#x0D]+ 64 | 65 | entity ::= 66 | '&'('#'([xX][0-9a-fA-F]'{1,6}'|[0-9]'{1,5}')|[A-Za-z]'{1,30}')';' 67 | 68 | quoted_attribute_value ::= 69 | "'" [^']+? "'" 70 | | '"' [^"]+? '"' 71 | 72 | text ::= 73 | [^<>& #x09#x0A#x0B#x0C#x0D]([^<>&]*[^<>& #x09#x0A#x0B#x0C#x0D])? 74 | 75 | -------------------------------------------------------------------------------- /tree-sitter-janet.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-janet/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | source_file ::= 11 | _expr* 12 | 13 | line_comment ::= 14 | ( '#' '.'* ) 15 | 16 | _expr ::= 17 | _literals 18 | | _identifier 19 | | _special_forms 20 | | _shorthand 21 | | _specials 22 | | array 23 | | sqr_array 24 | | tuple 25 | | sqr_tuple 26 | | struct 27 | | table 28 | | peg_set 29 | 30 | tuple ::= 31 | '(' _expr* ')' 32 | 33 | sqr_tuple ::= 34 | '[' _expr* ']' 35 | 36 | array ::= 37 | '@(' _expr* ')' 38 | 39 | sqr_array ::= 40 | '@[' _expr* ']' 41 | 42 | struct ::= 43 | '{' _struct_tables_commom* '}' 44 | 45 | table ::= 46 | '@{' _struct_tables_commom* '}' 47 | 48 | _struct_tables_commom ::= 49 | _expr _expr 50 | 51 | peg_set ::= 52 | '(' 'set' ( str_literal | long_str_literal | quote | short_quote ) ')' 53 | 54 | _special_forms ::= 55 | def 56 | | var 57 | | quote 58 | | splice 59 | | quasiquote 60 | | unquote 61 | | break 62 | | set 63 | | if 64 | | do 65 | | while 66 | | fn 67 | | upscope 68 | 69 | def ::= 70 | '(' 'def' _expr metadata* _expr ')' 71 | 72 | var ::= 73 | '(' 'var' _expr metadata* _expr ')' 74 | 75 | quote ::= 76 | '(' 'quote' _expr? ')' 77 | 78 | splice ::= 79 | '(' 'splice' _expr? ')' 80 | 81 | quasiquote ::= 82 | '(' 'quasiquote' _expr? ')' 83 | 84 | unquote ::= 85 | '(' 'unquote' _expr? ')' 86 | 87 | break ::= 88 | '(' 'break' _expr? ')' 89 | 90 | set ::= 91 | '(' 'set' _expr _expr ')' 92 | 93 | if ::= 94 | '(' 'if' _expr _expr _expr? ')' 95 | 96 | do ::= 97 | '(' 'do' body? ')' 98 | 99 | while ::= 100 | '(' 'while' _expr _expr* ')' 101 | 102 | fn ::= 103 | '(' 'fn' _name? _parameters body? ')' 104 | 105 | upscope ::= 106 | '(' 'upscope' body? ')' 107 | 108 | _parameters ::= 109 | _identifier | quote | splice | quasiquote | unquote | short_quote | short_splice | short_quasiquote | short_unquote | parameters | tuple_parameters 110 | 111 | parameters ::= 112 | '[' _expr* ( ( variadic_marker | optional_marker | keys_marker ) _expr* )? ']' 113 | 114 | tuple_parameters ::= 115 | '(' _expr* ( ( variadic_marker | optional_marker | keys_marker ) _expr* )? ')' 116 | 117 | variadic_marker ::= 118 | '&' 119 | 120 | optional_marker ::= 121 | '&opt' 122 | 123 | keys_marker ::= 124 | '&keys' 125 | 126 | _shorthand ::= 127 | short_quote 128 | | short_splice 129 | | short_quasiquote 130 | | short_unquote 131 | | short_fn 132 | 133 | short_quote ::= 134 | "'" _expr 135 | 136 | short_splice ::= 137 | ';' _expr 138 | 139 | short_quasiquote ::= 140 | '~' _expr 141 | 142 | short_unquote ::= 143 | ',' _expr 144 | 145 | short_fn ::= 146 | '|' _expr 147 | 148 | _specials ::= 149 | extra_defs 150 | 151 | extra_defs ::= 152 | '(' ( 'defn' | 'defn-' | 'varfn' | 'varfn-' | 'defmacro' | 'defmacro-' ) _name metadata* _parameters body? ')' 153 | 154 | _literals ::= 155 | bool_literal 156 | | nil_literal 157 | | number_literal 158 | | str_literal 159 | | long_str_literal 160 | | buffer_literal 161 | | long_buffer_literal 162 | 163 | str_literal ::= 164 | ( '"' ( [^"\]+ | '\'[^xu] | '\u'[0-9a-fA-F]'{4}' | '\u{'[0-9a-fA-F]+'}' | '\x'[0-9a-fA-F]'{2}' )* '"' ) 165 | 166 | long_str_literal ::= 167 | _long_str 168 | 169 | buffer_literal ::= 170 | ( '@"' ( [^"\]+ | '\'[^xu] | '\u'[0-9a-fA-F]'{4}' | '\u{'[0-9a-fA-F]+'}' | '\x'[0-9a-fA-F]'{2}' )* '"' ) 171 | 172 | long_buffer_literal ::= 173 | _long_buffer 174 | 175 | number_literal ::= 176 | [-+]?([0-9][_0-9]*|[0-9][_0-9]*'.'[_0-9]*|'.'[_0-9]+)([eE&][+-]?[0-9]+)? 177 | | [-+]?'0x'([_0-9a-fA-F]+|[_0-9a-fA-F]+'.'[_0-9a-fA-F]*|'.'[_0-9a-fA-F]+)('&'[+-]?[0-9a-fA-F]+)? 178 | | [-+]?[0-9][0-9]?'r'([_a-zA-Z_]+|[_a-zA-Z_]+'.'[_a-zA-Z_]*|'.'[_a-zA-Z_]+)('&'[+-]?[a-zA-Z_]+)? 179 | 180 | bool_literal ::= 181 | 'true' 182 | | 'false' 183 | 184 | nil_literal ::= 185 | 'nil' 186 | 187 | escape_sequence ::= 188 | ( '\'[^xu] | '\u'[0-9a-fA-F]'{4}' | '\u{'[0-9a-fA-F]+'}' | '\x'[0-9a-fA-F]'{2}' ) 189 | 190 | metadata ::= 191 | keyword | str_literal | long_str_literal | struct | quote | splice | quasiquote | unquote | short_quote | short_splice | short_quasiquote | short_unquote 192 | 193 | _name ::= 194 | _identifier | quote | splice | quasiquote | unquote | short_quote | short_splice | short_quasiquote | short_unquote 195 | 196 | doc_str ::= 197 | str_literal 198 | | long_str_literal 199 | 200 | body ::= 201 | _expr+ 202 | 203 | _identifier ::= 204 | symbol 205 | | keyword 206 | 207 | keyword ::= 208 | ':'[^({#x5B"'|`;,~#x5D} #x09#x0A#x0B#x0C#x0D)]* 209 | 210 | symbol ::= 211 | [^({#x5B"'|`;,~#x5D} #x09#x0A#x0B#x0C#x0D):][^({#x5B"'|`;,~#x5D} #x09#x0A#x0B#x0C#x0D)]* 212 | 213 | -------------------------------------------------------------------------------- /tree-sitter-jsdoc.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-jsdoc/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | document ::= 11 | _begin description? tag* _end 12 | 13 | description ::= 14 | _text ( _text | inline_tag | _inline_tag_false_positive )* 15 | 16 | tag ::= 17 | tag_name_with_argument ( '{' type '}' )? _expression? description? 18 | | tag_name_with_type ( '{' type '}' )? description? 19 | | tag_name description? 20 | 21 | inline_tag ::= 22 | '{' tag_name description '}' 23 | 24 | _inline_tag_false_positive ::= 25 | '\{'[^@}]+'\}'? 26 | 27 | tag_name_with_argument ::= 28 | ( '@access' | '@alias' | '@api' | '@augments' | '@borrows' | '@callback' | '@constructor' | '@event' | '@exports' | '@external' | '@extends' | '@fires' | '@function' | '@mixes' | '@name' | '@namespace' | '@param' | '@property' | '@prop' | '@satisfies' | '@typedef' ) 29 | 30 | tag_name_with_type ::= 31 | ( '@return' | '@returns' | '@throw' | '@throws' | '@type' ) 32 | 33 | tag_name ::= 34 | '@'[a-zA-Z_]+ 35 | 36 | _expression ::= 37 | identifier 38 | | optional_identifier 39 | | member_expression 40 | | path_expression 41 | | qualified_expression 42 | 43 | qualified_expression ::= 44 | identifier ':' _expression 45 | 46 | path_expression ::= 47 | identifier '/' identifier 48 | 49 | member_expression ::= 50 | _expression ( '.' | '#' | '~' ) ( identifier | qualified_expression ) 51 | 52 | optional_identifier ::= 53 | '[' identifier ']' 54 | 55 | identifier ::= 56 | [a-zA-Z_$][a-zA-Z_$0-9]* 57 | 58 | _text ::= 59 | [^*{}@ #x09#x0A#x0B#x0C#x0D][^*{}#x0A]*([^*/{}#x0A][^*{}#x0A]*'\'*+)* 60 | 61 | _begin ::= 62 | ( '/' '*'* ) 63 | 64 | _end ::= 65 | '/' 66 | 67 | -------------------------------------------------------------------------------- /tree-sitter-json5.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-json5/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | file ::= 11 | object | array 12 | 13 | comment ::= 14 | ( '//' [^#x0A]* | '/*' '.'* '*/' ) 15 | 16 | object ::= 17 | '{' ( member ( ',' member )* ','? )? '}' 18 | 19 | member ::= 20 | name ':' _value 21 | 22 | name ::= 23 | string 24 | | identifier 25 | 26 | identifier ::= 27 | ( [\$_\p{L}] ( [\$_\p{L}] | [0-9] )* ) 28 | 29 | array ::= 30 | '[' ( _value ( ',' _value )* ','? )? ']' 31 | 32 | string ::= 33 | ( '"' ( '\\' ( '"' | '\\' | 'b' | 'f' | 'n' | 'r' | 't' | 'v' ) | [^"\] )* '"' | "'" ( '\\' ( "'" | '\\' | 'b' | 'f' | 'n' | 'r' | 't' | 'v' ) | [^'\] )* "'" ) 34 | 35 | number ::= 36 | ( [+-]? ( '0' [xX] [0-9a-fA-F]+ | ( '0' | [1-9] [0-9]* ) '.' [0-9]* ( [eE] [+-]? [0-9]+ )? | '.' [0-9]* ( [eE] [+-]? [0-9]+ )? | ( '0' | [1-9] [0-9]* ) ( [eE] [+-]? [0-9]+ )? | 'Infinity' | 'NaN' ) ) 37 | 38 | null ::= 39 | 'null' 40 | 41 | true ::= 42 | 'true' 43 | 44 | false ::= 45 | 'false' 46 | 47 | _value ::= 48 | object 49 | | array 50 | | number 51 | | string 52 | | null 53 | | true 54 | | false 55 | 56 | -------------------------------------------------------------------------------- /tree-sitter-lbnf.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-lbnf/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | grammar ::= 11 | ( def ';' )* 12 | 13 | def ::= 14 | label '.' cat '::=' item* 15 | | 'comment' string 16 | | 'comment' string string 17 | | 'internal' label '.' cat '::=' item* 18 | | 'token' ident reg 19 | | 'position' 'token' ident reg 20 | | 'entrypoints' ident ( ',' ident )* 21 | | 'separator' 'nonempty'? cat string 22 | | 'terminator' 'nonempty'? cat string 23 | | 'coercions' ident integer 24 | | 'rules' ident '::=' item* ( '|' item* )* 25 | | 'layout' string ( ',' string )* 26 | | 'layout' 'stop' string ( ',' string )* 27 | | 'layout' 'toplevel' 28 | 29 | item ::= 30 | string 31 | | cat 32 | 33 | cat ::= 34 | '[' cat ']' 35 | | ident 36 | 37 | label ::= 38 | label_id 39 | | label_id prof_item* 40 | | label_id label_id prof_item* 41 | 42 | label_id ::= 43 | ident 44 | | '_' 45 | | '[' ']' 46 | | '(' ':' ')' 47 | | '(' ':' '[' ']' ')' 48 | 49 | prof_item ::= 50 | '(' '[' ( int_list ( ',' int_list )* )? ']' ',' '[' ( integer ( ',' integer )* )? ']' ')' 51 | 52 | int_list ::= 53 | '[' ( integer ( ',' integer )* )? ']' 54 | 55 | reg2 ::= 56 | reg2 reg3 57 | | reg3 58 | 59 | reg1 ::= 60 | reg1 '|' reg2 61 | | reg2 '-' reg2 62 | | reg2 63 | 64 | reg3 ::= 65 | reg3 '*' 66 | | reg3 '+' 67 | | reg3 '?' 68 | | 'eps' 69 | | char 70 | | '[' string ']' 71 | | '{' string '}' 72 | | 'digit' 73 | | 'letter' 74 | | 'upper' 75 | | 'lower' 76 | | 'char' 77 | | '(' reg ')' 78 | 79 | reg ::= 80 | reg1 81 | 82 | integer ::= 83 | [0-9]+ 84 | 85 | char ::= 86 | "'" ( escape_sequence | [^#x0A'] ) "'" 87 | 88 | string ::= 89 | '"' ( [^\"#x0A]+ | escape_sequence )* '"' 90 | 91 | escape_sequence ::= 92 | ( '\\' ( [^xuU] | [0-9]'{2,3}' | 'x'[0-9a-fA-F]'{2,}' | 'u'[0-9a-fA-F]'{4}' | 'U'[0-9a-fA-F]'{8}' ) ) 93 | 94 | ident ::= 95 | [a-zA-Z][a-zA-Z_]* 96 | 97 | comment ::= 98 | ( '--' '.'* | '{-' ( [^-] | '-'[^}] )* '-}' ) 99 | 100 | -------------------------------------------------------------------------------- /tree-sitter-ledger.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-ledger/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | source_file ::= 11 | ( journal_item | '\n' )* 12 | 13 | journal_item ::= 14 | comment 15 | | block_comment 16 | | test 17 | | directive 18 | | xact 19 | 20 | comment ::= 21 | ( ( ';' | '#' | '%' | '|' | '*' ) '.'*'#x0A' ) 22 | 23 | block_comment ::= 24 | 'comment' ( whitespace '.'* )? '\n' ( ( whitespace? '.'* )? '\n' )* ( 'end' | 'end comment' | 'end' '.'* ) 25 | 26 | test ::= 27 | 'test' ( whitespace '.'* )? '\n' ( ( whitespace? '.'* )? '\n' )* ( 'end' | 'end test' | 'end' '.'* ) 28 | 29 | option ::= 30 | ( '-' | '--' ) [^ =#x0A]+ ( ( whitespace | '=' ) option_value )? '\n' 31 | 32 | option_value ::= 33 | '.'+ 34 | 35 | indented_line ::= 36 | whitespace [^#x0A]+'#x0A' 37 | 38 | directive ::= 39 | option 40 | | account_directive 41 | | commodity_directive 42 | | tag_directive 43 | | word_directive '\n' 44 | | char_directive '\n' 45 | 46 | account_directive ::= 47 | 'account' whitespace account '\n' account_subdirective* 48 | 49 | account_subdirective ::= 50 | alias_subdirective 51 | | default_subdirective 52 | | note_subdirective 53 | | assert_subdirective 54 | | check_subdirective 55 | | whitespace 'eval' whitespace '.'+'#x0A' 56 | | whitespace 'payee' whitespace '.'+'#x0A' 57 | 58 | commodity_directive ::= 59 | 'commodity' whitespace commodity '\n' commodity_subdirective* 60 | 61 | commodity_subdirective ::= 62 | alias_subdirective 63 | | default_subdirective 64 | | format_subdirective 65 | | note_subdirective 66 | | whitespace 'nomarket' '\n' 67 | 68 | tag_directive ::= 69 | 'tag' whitespace '\p{L}'+'#x0A' ( assert_subdirective | check_subdirective )* 70 | 71 | word_directive ::= 72 | 'include' whitespace filename 73 | | 'end' 74 | | 'alias' whitespace [^=]+ '=' '.'+ 75 | | 'def' whitespace '.'+ 76 | | 'year' whitespace [0-9]'{4}' 77 | | 'bucket' whitespace account 78 | 79 | filename ::= 80 | '.'+ 81 | 82 | char_directive ::= 83 | check_in 84 | | check_out 85 | | 'A' whitespace account 86 | | 'Y' whitespace [0-9]'{4}' 87 | | 'N' whitespace commodity 88 | | 'D' whitespace amount 89 | | 'C' whitespace commodity whitespace? '=' whitespace? amount 90 | | 'P' whitespace date whitespace commodity whitespace? amount 91 | 92 | alias_subdirective ::= 93 | whitespace 'alias' whitespace '.'+'#x0A' 94 | 95 | default_subdirective ::= 96 | whitespace 'default' '\n' 97 | 98 | format_subdirective ::= 99 | whitespace 'format' whitespace amount 100 | 101 | note_subdirective ::= 102 | whitespace 'note' whitespace '.'+'#x0A' 103 | 104 | assert_subdirective ::= 105 | whitespace 'assert' whitespace '.'+'#x0A' 106 | 107 | check_subdirective ::= 108 | whitespace 'check' whitespace '.'+'#x0A' 109 | 110 | check_in ::= 111 | ( 'i' | 'I' ) whitespace? date whitespace? time whitespace? account ( spacer whitespace? payee )? 112 | 113 | check_out ::= 114 | ( 'o' | 'O' ) whitespace? date whitespace? time 115 | 116 | xact ::= 117 | plain_xact 118 | | periodic_xact 119 | | automated_xact 120 | 121 | plain_xact ::= 122 | _xact_date ( whitespace status )? ( whitespace code )? ( whitespace payee )? ( note | '\n' ) ( posting | whitespace note '\n' )+ 123 | 124 | periodic_xact ::= 125 | '~' whitespace interval ( note | '\n' ) ( posting | whitespace note '\n' )+ 126 | 127 | interval ::= 128 | [eE][vV][eE][rR][yY][ ][dD][aA][yY] 129 | | [eE][vV][eE][rR][yY][ ][wW][eE][eE][kK] 130 | | [eE][vV][eE][rR][yY][ ][mM][oO][nN][tT][hH] 131 | | [eE][vV][eE][rR][yY][ ][qQ][uU][aA][rR][tT][eE][rR] 132 | | [eE][vV][eE][rR][yY][ ][yY][eE][aA][rR] 133 | | [eE][vV][eE][rR][yY]' '[0-9]+' '[dD][aA][yY][sS] 134 | | [eE][vV][eE][rR][yY]' '[0-9]+' '[wW][eE][eE][kK][sS] 135 | | [eE][vV][eE][rR][yY]' '[0-9]+' '[mM][oO][nN][tT][hH][sS] 136 | | [eE][vV][eE][rR][yY]' '[0-9]+' '[qQ][uU][aA][rR][tT][eE][rR][sS] 137 | | [eE][vV][eE][rR][yY]' '[0-9]+' '[yY][eE][aA][rR][sS] 138 | | [dD][aA][iI][lL][yY] 139 | | [wW][eE][eE][kK][lL][yY] 140 | | [bB][iI][wW][eE][eE][kK][lL][yY] 141 | | [mM][oO][nN][tT][hH][lL][yY] 142 | | [bB][iI][mM][oO][nN][tT][hH][lL][yY] 143 | | [qQ][uU][aA][rR][tT][eE][rR][lL][yY] 144 | | [yY][eE][aA][rR][lL][yY] 145 | 146 | automated_xact ::= 147 | '=' whitespace query ( note | '\n' ) ( posting | whitespace note '\n' )+ 148 | 149 | _xact_date ::= 150 | date effective_date? 151 | 152 | date ::= 153 | _single_date 154 | 155 | effective_date ::= 156 | '=' _single_date 157 | 158 | _dsep ::= 159 | [-.\/] 160 | 161 | _2d ::= 162 | [0-9]'{1,2}' 163 | 164 | _4d ::= 165 | [0-9]'{4}' 166 | 167 | _single_date ::= 168 | _4d _dsep _2d _dsep _2d 169 | | _2d _dsep _2d _dsep _2d 170 | | _2d _dsep _2d 171 | 172 | time ::= 173 | [0-9]'{2}:'[0-9]'{2}:'[0-9]'{2}' 174 | 175 | status ::= 176 | '*' 177 | | '!' 178 | 179 | code ::= 180 | '(' [^)]* ')' 181 | 182 | payee ::= 183 | [^(*!#x0A][^*!#x0A]* 184 | 185 | query ::= 186 | [^#x0A]+ 187 | 188 | note ::= 189 | ';' whitespace ( '[' effective_date ']' | [^#x5B][^=#x0A]* ) 190 | 191 | posting ::= 192 | whitespace ( status whitespace? )? account ( spacer ( whitespace? amount )? ( whitespace? price )? ( whitespace? balance_assertion )? ( whitespace? note )? )? '\n' 193 | 194 | account ::= 195 | ( account_name | '(' account_name ')' | '[' account_name ']' ) 196 | 197 | account_name ::= 198 | [^ ;]('\S \S'|'\S')* 199 | 200 | amount ::= 201 | quantity 202 | | negative_quantity 203 | | ( quantity | negative_quantity ) whitespace? commodity 204 | | commodity whitespace? ( quantity | negative_quantity ) 205 | 206 | _quantity ::= 207 | [0-9]([0-9., ]*[0-9])? 208 | 209 | quantity ::= 210 | '+'? _quantity 211 | 212 | negative_quantity ::= 213 | '-' _quantity 214 | 215 | commodity ::= 216 | '\p{L}'+ 217 | | '\p{Sc}' 218 | | '"'[^"#x0A]*'"' 219 | 220 | price ::= 221 | ( '@' | '@@' ) whitespace? amount 222 | 223 | balance_assertion ::= 224 | '=' whitespace? ( amount ) 225 | 226 | whitespace ::= 227 | ( ' ' | '\t' )+ 228 | 229 | spacer ::= 230 | ' ' 231 | | '\t' 232 | | ' \t' 233 | 234 | -------------------------------------------------------------------------------- /tree-sitter-linkerscript.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-linkerscript/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | linkerscript ::= 11 | entry_command? _command* 12 | 13 | entry_command ::= 14 | 'ENTRY' '(' symbol ')' 15 | 16 | _command ::= 17 | assignment 18 | | sections_command 19 | | memory_command 20 | | phdrs_command 21 | 22 | sections_command ::= 23 | 'SECTIONS' '{' _output_section_command* '}' 24 | 25 | _output_section_command ::= 26 | output_section 27 | | overlay_command 28 | | assignment 29 | | assert_command 30 | 31 | output_section ::= 32 | ( symbol | '/DISCARD/' ) expression? section_type? ':'? _at? '{' ( ( input_section | assignment | keep_command | provide_command ) ';'? )+ '}' region? lma_region? phdr? fillexp? 33 | 34 | _at ::= 35 | 'AT' '(' expression ')' 36 | 37 | region ::= 38 | '>' symbol 39 | 40 | lma_region ::= 41 | 'AT' '>' symbol 42 | 43 | phdr ::= 44 | ':' symbol 45 | 46 | fillexp ::= 47 | '=' expression 48 | 49 | section_type ::= 50 | '(' ( 'NOLOAD' | 'DSECT' | 'COPY' | 'INFO' | 'OVERLAY' ) ')' 51 | 52 | input_section ::= 53 | ( wildcard_pattern | filename | symbol ) ( '(' ( filename | expression | wildcard_pattern )+ ')' )? 54 | 55 | wildcard_pattern ::= 56 | ( '[' symbol ']' )? '*' 57 | 58 | overlay_command ::= 59 | 'OVERLAY' expression? ':' 'NOCROSSREFS'? _at? '{' _output_section_command* '}' region? phdr? fillexp? 60 | 61 | assignment ::= 62 | ( symbol | '.' ) ( '=' | '+=' | '-=' | '*=' | '/=' | '<<=' | '>>=' | '&=' | '|=' ) expression ';' 63 | 64 | assert_command ::= 65 | 'ASSERT' '(' expression ( ',' expression )* ')' 66 | 67 | keep_command ::= 68 | 'KEEP' '(' input_section? ')' 69 | 70 | provide_command ::= 71 | ( 'PROVIDE' | 'PROVIDE_HIDDEN' ) '(' symbol '=' expression ')' ';' 72 | 73 | memory_command ::= 74 | 'MEMORY' '{' _memory* '}' 75 | 76 | _memory ::= 77 | symbol ( '(' attributes ')' | attributes )? ':' ( 'ORIGIN' | 'org' | 'o' ) '=' expression ',' ( 'LENGTH' | 'len' | 'l' ) '=' expression 78 | 79 | attributes ::= 80 | [rwxail!]+ 81 | 82 | phdrs_command ::= 83 | 'PHDRS' '{' _phdr* '}' 84 | 85 | _phdr ::= 86 | symbol symbol 'FILEHDR'? 'PHDRS'? _at? ';' 87 | 88 | expression ::= 89 | conditional_expression 90 | | unary_expression 91 | | binary_expression 92 | | parenthesized_expression 93 | | call_expression 94 | | symbol 95 | | quoted_symbol 96 | | number 97 | | '.' 98 | 99 | conditional_expression ::= 100 | expression '?' expression? ':' expression 101 | 102 | unary_expression ::= 103 | ( '!' | '~' | '-' ) expression 104 | 105 | binary_expression ::= 106 | expression '+' expression 107 | | expression '-' expression 108 | | expression '*' expression 109 | | expression '/' expression 110 | | expression '%' expression 111 | | expression '||' expression 112 | | expression '&&' expression 113 | | expression '|' expression 114 | | expression '&' expression 115 | | expression '==' expression 116 | | expression '!=' expression 117 | | expression '>' expression 118 | | expression '>=' expression 119 | | expression '<=' expression 120 | | expression '<' expression 121 | | expression '<<' expression 122 | | expression '>>' expression 123 | 124 | parenthesized_expression ::= 125 | '(' expression ')' 126 | 127 | call_expression ::= 128 | expression argument_list 129 | 130 | argument_list ::= 131 | '(' ( ( expression | input_section ) ( ',' ( expression | input_section ) )* )? ')' 132 | 133 | number ::= 134 | ( '0'[xX][a-fA-F0-9]+ | '0'[bB][01]+ | '0'[0-7]+ | '0'|[1-9][0-9]*('h'|'H'|'o'|'O'|'b'|'B'|'d'|'D'|'K'|'M')? ) 135 | 136 | symbol ::= 137 | [a-zA-Z_.][a-zA-Z0-9_.-]* 138 | 139 | quoted_symbol ::= 140 | '"' [^"]* '"' 141 | 142 | filename ::= 143 | [^(){};=, #x09#x0A#x0B#x0C#x0D]+ 144 | 145 | comment ::= 146 | ( '//' ('\'+('.'|'#x0D'?'#x0A')|[^\#x0A])* | '/*' [^*]*'\'*+([^/*][^*]*'\'*+)* '/' ) 147 | 148 | -------------------------------------------------------------------------------- /tree-sitter-lp.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-lp/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | program ::= 11 | _statement* 12 | 13 | _statement ::= 14 | fact 15 | | rule 16 | | integrity_constraint 17 | | optimization 18 | | show_statement 19 | 20 | fact ::= 21 | head '.' 22 | 23 | rule ::= 24 | head ':-' body '.' 25 | 26 | integrity_constraint ::= 27 | ':-' body '.' 28 | 29 | optimization ::= 30 | ':~' body '.' ( '[' ( prioritized_term ( ',' prioritized_term )* )? ']' )? 31 | 32 | head ::= 33 | disjunction 34 | | condition 35 | | choice 36 | 37 | disjunction ::= 38 | classical_literal ( ';' classical_literal )* 39 | 40 | classical_literal ::= 41 | '-'? ( constant | function ) 42 | 43 | choice ::= 44 | left_guard? aggregate_function? '{' ( choice_element ( ';' choice_element )* )? '}' right_guard? 45 | 46 | choice_element ::= 47 | aggregate_literals ( ';' aggregate_literals )* 48 | | terms ( ':' ( _literal ( ':' aggregate_literals? )? )? )? 49 | 50 | aggregate_literals ::= 51 | _literal ( ',' _literal )* 52 | 53 | left_guard ::= 54 | _term ( '=' | '!=' | '<' | '<=' | '>' | '>=' | '==' | '/=' | '<>' )? 55 | 56 | right_guard ::= 57 | ( '=' | '!=' | '<' | '<=' | '>' | '>=' | '==' | '/=' | '<>' )? _term 58 | 59 | body ::= 60 | _literal ( ( ',' | ';' ) _literal )* 61 | 62 | aggregate ::= 63 | left_guard? aggregate_function? '{' ( aggregate_element ( ';' aggregate_element )* )? '}' right_guard? 64 | 65 | aggregate_function ::= 66 | ( '#' ( '_' | '’' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '+' )+ ) 67 | 68 | aggregate_element ::= 69 | aggregate_literals ( ';' aggregate_literals )* 70 | | terms ':' ( ':' aggregate_literals? )? 71 | 72 | literals ::= 73 | _literal ( ( ',' | ';' ) _literal )* 74 | 75 | _literal ::= 76 | comparison 77 | | condition 78 | | negation 79 | | _term 80 | | aggregate 81 | 82 | comparison ::= 83 | _term ( '=' | '!=' | '<' | '<=' | '>' | '>=' | '==' | '/=' | '<>' ) _term 84 | 85 | condition ::= 86 | _term ':' _literal ( ( ',' _literal )* )? 87 | 88 | negation ::= 89 | 'not' _literal 90 | 91 | _aggregate ::= 92 | terms 93 | | pooling 94 | 95 | terms ::= 96 | _term ( ',' _term )* 97 | 98 | pooling ::= 99 | terms ';' terms ( ';' terms )* 100 | 101 | _term ::= 102 | interval 103 | | tuple 104 | | _simpleterm 105 | | _function 106 | | prioritized_term 107 | 108 | _simpleterm ::= 109 | _constant 110 | | string 111 | | variable 112 | | anonymous_variable 113 | | special_constant 114 | 115 | prioritized_term ::= 116 | _term '@' integer 117 | 118 | _constant ::= 119 | constant 120 | | boolean 121 | | integer 122 | 123 | constant ::= 124 | ( '_'* ( 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' ) ( '_' | '’' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' )* ) 125 | 126 | boolean ::= 127 | '#true' 128 | | '#false' 129 | 130 | _digit ::= 131 | '0' 132 | | '1' 133 | | '2' 134 | | '3' 135 | | '4' 136 | | '5' 137 | | '6' 138 | | '7' 139 | | '8' 140 | | '9' 141 | 142 | _digit_immed ::= 143 | '0' 144 | | '1' 145 | | '2' 146 | | '3' 147 | | '4' 148 | | '5' 149 | | '6' 150 | | '7' 151 | | '8' 152 | | '9' 153 | 154 | integer ::= 155 | _digit _digit_immed* 156 | 157 | string ::= 158 | '"' ( [^"#x0A] | escape_sequence )* '"' 159 | 160 | escape_sequence ::= 161 | ( '\\' | '\n' | '\"' ) 162 | 163 | variable ::= 164 | ( '_'* ( 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' ) ( '_' | '’' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' )* ) 165 | 166 | _function ::= 167 | function 168 | | external_function 169 | | binary_arithmetic_function 170 | | unary_arithmetic_function 171 | 172 | function ::= 173 | constant '(' _aggregate ')' 174 | 175 | external_function ::= 176 | '@' constant '(' _aggregate ')' 177 | 178 | binary_arithmetic_function ::= 179 | _term ( '+' | '-' | '*' | '/' | '\\' | '**' | '&' | '?' | '^' ) _term 180 | 181 | unary_arithmetic_function ::= 182 | '|' _term '|' | ( '-' | '~' ) _term 183 | 184 | tuple ::= 185 | '(' _aggregate? ')' 186 | 187 | interval ::= 188 | _simpleterm '..' _simpleterm 189 | 190 | anonymous_variable ::= 191 | '_' 192 | 193 | special_constant ::= 194 | '#inf' 195 | | '#sup' 196 | 197 | show_statement ::= 198 | '#show' ( constant '/' integer | _term ':' literals )? '.' 199 | 200 | comment ::= 201 | '%'([^\*#x0A][^#x0A]*)? 202 | | '%\'*([^\*]|'\'*[^%])*'\'*'%' 203 | 204 | -------------------------------------------------------------------------------- /tree-sitter-lua.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-lua/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | chunk ::= 11 | shebang? _block? 12 | 13 | shebang ::= 14 | '#!.'* 15 | 16 | block ::= 17 | _block 18 | 19 | _block ::= 20 | return_statement 21 | | statement+ return_statement? 22 | 23 | return_statement ::= 24 | 'return' expression_list? empty_statement? 25 | 26 | statement ::= 27 | empty_statement 28 | | variable_assignment 29 | | local_variable_declaration 30 | | call 31 | | label_statement 32 | | goto_statement 33 | | break_statement 34 | | do_statement 35 | | while_statement 36 | | repeat_statement 37 | | if_statement 38 | | for_numeric_statement 39 | | for_generic_statement 40 | | function_definition_statement 41 | | local_function_definition_statement 42 | 43 | local_function_definition_statement ::= 44 | 'local' 'function' identifier _function_body 45 | 46 | function_definition_statement ::= 47 | 'function' ( identifier | _table_function_variable ) _function_body 48 | 49 | _table_function_variable ::= 50 | _table_identifier ( _named_field_identifier | _method_identifier ) 51 | 52 | _table_identifier ::= 53 | ( identifier | _table_field_variable ) 54 | 55 | _table_field_variable ::= 56 | _table_identifier _named_field_identifier 57 | 58 | for_generic_statement ::= 59 | 'for' _name_list 'in' _value_list 'do' block? 'end' 60 | 61 | _name_list ::= 62 | identifier ( ',' identifier )* 63 | 64 | _value_list ::= 65 | expression ( ',' expression )* 66 | 67 | for_numeric_statement ::= 68 | 'for' identifier '=' expression ',' expression ( ',' expression )? 'do' block? 'end' 69 | 70 | if_statement ::= 71 | 'if' expression 'then' block? elseif_clause* else_clause? 'end' 72 | 73 | elseif_clause ::= 74 | 'elseif' expression 'then' block? 75 | 76 | else_clause ::= 77 | 'else' block? 78 | 79 | repeat_statement ::= 80 | 'repeat' block? 'until' expression 81 | 82 | while_statement ::= 83 | 'while' expression 'do' block? 'end' 84 | 85 | do_statement ::= 86 | 'do' block? 'end' 87 | 88 | break_statement ::= 89 | 'break' 90 | 91 | goto_statement ::= 92 | 'goto' identifier 93 | 94 | label_statement ::= 95 | '::' identifier '::' 96 | 97 | local_variable_declaration ::= 98 | 'local' _local_variable_list ( '=' _value_list )? 99 | 100 | _local_variable_list ::= 101 | _local_variable ( ',' _local_variable )* 102 | 103 | _local_variable ::= 104 | identifier attribute? 105 | 106 | attribute ::= 107 | '<' identifier '>' 108 | 109 | variable_assignment ::= 110 | variable_list '=' _value_list 111 | 112 | variable_list ::= 113 | variable ( ',' variable )* 114 | 115 | empty_statement ::= 116 | ';' 117 | 118 | expression ::= 119 | nil 120 | | false 121 | | true 122 | | number 123 | | string 124 | | vararg_expression 125 | | function_definition 126 | | prefix_expression 127 | | table 128 | | unary_expression 129 | | binary_expression 130 | 131 | binary_expression ::= 132 | expression 'or' expression 133 | | expression 'and' expression 134 | | expression '==' expression 135 | | expression '~=' expression 136 | | expression '<' expression 137 | | expression '>' expression 138 | | expression '<=' expression 139 | | expression '>=' expression 140 | | expression '|' expression 141 | | expression '~' expression 142 | | expression '&' expression 143 | | expression '<<' expression 144 | | expression '>>' expression 145 | | expression '+' expression 146 | | expression '-' expression 147 | | expression '*' expression 148 | | expression '/' expression 149 | | expression '//' expression 150 | | expression '%' expression 151 | | expression '..' expression 152 | | expression '^' expression 153 | 154 | unary_expression ::= 155 | 'not' expression 156 | | '#' expression 157 | | '-' expression 158 | | '~' expression 159 | 160 | table ::= 161 | '{' field_list? '}' 162 | 163 | field_list ::= 164 | field ( field_separator field )* field_separator? 165 | 166 | field ::= 167 | ( ( identifier | '[' expression ']' ) '=' )? expression 168 | 169 | field_separator ::= 170 | ',' 171 | | ';' 172 | 173 | prefix ::= 174 | variable 175 | | call 176 | | parenthesized_expression 177 | 178 | prefix_expression ::= 179 | prefix 180 | 181 | _prefix_expression ::= 182 | prefix 183 | 184 | parenthesized_expression ::= 185 | '(' expression ')' 186 | 187 | call ::= 188 | ( _prefix_expression | _table_method_variable ) argument_list 189 | 190 | _table_method_variable ::= 191 | prefix_expression _method_identifier 192 | 193 | _method_identifier ::= 194 | ':' identifier 195 | 196 | argument_list ::= 197 | '(' expression_list? ')' 198 | | table 199 | | string 200 | 201 | expression_list ::= 202 | expression ( ',' expression )* 203 | 204 | variable ::= 205 | identifier 206 | | _table_variable 207 | 208 | _table_variable ::= 209 | ( identifier | _table_variable | call | parenthesized_expression ) ( _indexed_field_identifier | _named_field_identifier ) 210 | 211 | _named_field_identifier ::= 212 | '.' identifier 213 | 214 | _indexed_field_identifier ::= 215 | '[' expression ']' 216 | 217 | function_definition ::= 218 | 'function' _function_body 219 | 220 | _function_body ::= 221 | '(' parameter_list? ')' block? 'end' 222 | 223 | parameter_list ::= 224 | identifier ( ',' identifier )* ( ',' vararg_expression )? 225 | | vararg_expression 226 | 227 | vararg_expression ::= 228 | '...' 229 | 230 | string ::= 231 | _string_start _string_content? _string_end 232 | 233 | number ::= 234 | ( '-'? ( ( [0-9]+ | [0-9]+ '.' [0-9]* | [0-9]* '.' [0-9]+ ) ( ( 'e' | 'E' ) ( '+' | '-' )? [0-9]+ )? | ( '0x' | '0X' ) ( [0-9a-fA-F]+ | [0-9a-fA-F]+ '.' [0-9a-fA-F]* | [0-9a-fA-F]* '.' [0-9a-fA-F]+ ) ( ( 'p' | 'P' ) ( '+' | '-' )? [0-9]+ )? ) ) 235 | 236 | true ::= 237 | 'true' 238 | 239 | false ::= 240 | 'false' 241 | 242 | nil ::= 243 | 'nil' 244 | 245 | identifier ::= 246 | [a-zA-Z_][0-9a-zA-Z_]* 247 | 248 | comment ::= 249 | _comment_start _comment_content? _comment_end 250 | 251 | -------------------------------------------------------------------------------- /tree-sitter-make.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-make/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | makefile ::= 11 | _thing* 12 | 13 | _thing ::= 14 | rule 15 | | _variable_definition 16 | | _directive 17 | | _function [#x0D#x0A]+ 18 | 19 | rule ::= 20 | _ordinary_rule 21 | | _static_pattern_rule 22 | 23 | _ordinary_rule ::= 24 | _targets ( ':' | '&:' | '::' ) [#x09 ]+? _prerequisites? ( recipe | [#x0D#x0A]+ ) 25 | 26 | _static_pattern_rule ::= 27 | _targets ':' [#x09 ]+? _target_pattern ':' [#x09 ]+? _prerequisites_pattern? ( recipe | [#x0D#x0A]+ ) 28 | 29 | _targets ::= 30 | list 31 | 32 | _target_pattern ::= 33 | list 34 | 35 | _prerequisites ::= 36 | _normal_prerequisites 37 | | _normal_prerequisites? '|' _order_only_prerequisites 38 | 39 | _normal_prerequisites ::= 40 | list 41 | 42 | _order_only_prerequisites ::= 43 | list 44 | 45 | _prerequisites_pattern ::= 46 | list 47 | 48 | recipe ::= 49 | _attached_recipe_line [#x0D#x0A]+ ( conditional | _prefixed_recipe_line )* | [#x0D#x0A]+ ( conditional | _prefixed_recipe_line )+ 50 | 51 | _attached_recipe_line ::= 52 | ';' recipe_line? 53 | 54 | _prefixed_recipe_line ::= 55 | _recipeprefix recipe_line? [#x0D#x0A]+ 56 | 57 | recipe_line ::= 58 | ( '@' | '-' | '+' )? ( shell_text_with_split ( _recipeprefix? shell_text_with_split )* _recipeprefix? )? _shell_text_without_split 59 | 60 | _variable_definition ::= 61 | VPATH_assignment 62 | | RECIPEPREFIX_assignment 63 | | variable_assignment 64 | | shell_assignment 65 | | define_directive 66 | 67 | VPATH_assignment ::= 68 | 'VPATH' [#x09 ]+? ( '=' | ':=' | '::=' | '?=' | '+=' ) paths [#x0D#x0A]+ 69 | 70 | RECIPEPREFIX_assignment ::= 71 | '.RECIPEPREFIX' [#x09 ]+? ( '=' | ':=' | '::=' | '?=' | '+=' ) text [#x0D#x0A]+ 72 | 73 | variable_assignment ::= 74 | _target_or_pattern_assignment? _name [#x09 ]+? ( '=' | ':=' | '::=' | '?=' | '+=' ) [#x09 ]+? text? [#x0D#x0A]+ 75 | 76 | _target_or_pattern_assignment ::= 77 | list ':' [#x09 ]+? 78 | 79 | shell_assignment ::= 80 | word [#x09 ]+? '!=' [#x09 ]+? _shell_command [#x0D#x0A]+ 81 | 82 | define_directive ::= 83 | 'define' word [#x09 ]+? ( '=' | ':=' | '::=' | '?=' | '+=' )? [#x09 ]+? [#x0D#x0A]+ _rawline+? 'endef' [#x0D#x0A]+ 84 | 85 | _directive ::= 86 | include_directive 87 | | vpath_directive 88 | | export_directive 89 | | unexport_directive 90 | | override_directive 91 | | undefine_directive 92 | | private_directive 93 | | conditional 94 | 95 | include_directive ::= 96 | 'include' list [#x0D#x0A]+ 97 | | 'sinclude' list [#x0D#x0A]+ 98 | | '-include' list [#x0D#x0A]+ 99 | 100 | vpath_directive ::= 101 | 'vpath' [#x0D#x0A]+ 102 | | 'vpath' word [#x0D#x0A]+ 103 | | 'vpath' word paths [#x0D#x0A]+ 104 | 105 | export_directive ::= 106 | 'export' [#x0D#x0A]+ 107 | | 'export' list [#x0D#x0A]+ 108 | | 'export' variable_assignment 109 | 110 | unexport_directive ::= 111 | 'unexport' [#x0D#x0A]+ 112 | | 'unexport' list [#x0D#x0A]+ 113 | 114 | override_directive ::= 115 | 'override' define_directive 116 | | 'override' variable_assignment 117 | | 'override' undefine_directive 118 | 119 | undefine_directive ::= 120 | 'undefine' word [#x0D#x0A]+ 121 | 122 | private_directive ::= 123 | 'private' variable_assignment 124 | 125 | conditional ::= 126 | _conditional_directives _conditional_consequence? elsif_directive* else_directive? 'endif' [#x0D#x0A]+ 127 | 128 | elsif_directive ::= 129 | 'else' _conditional_directives _conditional_consequence? 130 | 131 | else_directive ::= 132 | 'else' [#x0D#x0A]+ _conditional_consequence? 133 | 134 | _conditional_directives ::= 135 | ifeq_directive 136 | | ifneq_directive 137 | | ifdef_directive 138 | | ifndef_directive 139 | 140 | _conditional_consequence ::= 141 | ( _thing | _prefixed_recipe_line )+ 142 | 143 | ifeq_directive ::= 144 | 'ifeq' _conditional_args_cmp [#x0D#x0A]+ 145 | 146 | ifneq_directive ::= 147 | 'ifneq' _conditional_args_cmp [#x0D#x0A]+ 148 | 149 | ifdef_directive ::= 150 | 'ifdef' _primary [#x0D#x0A]+ 151 | 152 | ifndef_directive ::= 153 | 'ifndef' _primary [#x0D#x0A]+ 154 | 155 | _conditional_args_cmp ::= 156 | '(' _primary? ',' _primary? ')' 157 | | _primary _primary 158 | 159 | _variable ::= 160 | variable_reference 161 | | substitution_reference 162 | | automatic_variable 163 | 164 | variable_reference ::= 165 | ( '$' | '$$' ) ( '(' _primary ')' | '{' _primary '}' | '.' ) 166 | 167 | substitution_reference ::= 168 | ( '$' | '$$' ) ( '(' _primary ':' _primary '=' _primary ')' | '{' _primary ':' _primary '=' _primary '}' ) 169 | 170 | automatic_variable ::= 171 | ( '$' | '$$' ) ( '@' | '%' | '<' | '?' | '^' | '+' | '/' | '*' | '(' ( '@' | '%' | '<' | '?' | '^' | '+' | '/' | '*' ) ( 'D' | 'F' )? ')' | '{' ( '@' | '%' | '<' | '?' | '^' | '+' | '/' | '*' ) ( 'D' | 'F' )? '}' ) 172 | 173 | _function ::= 174 | function_call 175 | | shell_function 176 | 177 | function_call ::= 178 | ( '$' | '$$' ) '(' ( 'subst' | 'patsubst' | 'strip' | 'findstring' | 'filter' | 'filter-out' | 'sort' | 'word' | 'words' | 'wordlist' | 'firstword' | 'lastword' | 'dir' | 'notdir' | 'suffix' | 'basename' | 'addsuffix' | 'addprefix' | 'join' | 'wildcard' | 'realpath' | 'abspath' | 'error' | 'warning' | 'info' | 'origin' | 'flavor' | 'foreach' | 'if' | 'or' | 'and' | 'call' | 'eval' | 'file' | 'value' ) [#x09 ]+? arguments ')' 179 | 180 | arguments ::= 181 | text ( ',' text )* 182 | 183 | shell_function ::= 184 | ( '$' | '$$' ) '(' 'shell' [#x09 ]+? _shell_command ')' 185 | 186 | list ::= 187 | _primary ( ( [#x09 ]+ | ( '\\' '#x0D'?'#x0A'|'#x0D' ) ) _primary )* [#x09 ]+? 188 | 189 | paths ::= 190 | _primary ( ( ':' | ';' ) _primary )* 191 | 192 | _primary ::= 193 | word 194 | | archive 195 | | _variable 196 | | _function 197 | | concatenation 198 | | string 199 | 200 | concatenation ::= 201 | _primary _primary+ 202 | 203 | _name ::= 204 | word 205 | 206 | string ::= 207 | ( '"' _string? '"' | "'" _string? "'" ) 208 | 209 | _string ::= 210 | ( _variable | _function | ([^'"$#x0D#x0A\]|"\\"|"\"[^#x0D#x0A])+ )+ 211 | 212 | word ::= 213 | ( [a-zA-Z0-9%\+#x2D-.@_\*\?\/] | '\'[abtnvfrE!"#x23\$&'\(\)\*,;<>\?#x5B\#x5D^`{\|}~] | '\'[0-9]'{3}' )+ 214 | 215 | archive ::= 216 | word '(' list ')' 217 | 218 | _recipeprefix ::= 219 | '\t' 220 | 221 | _rawline ::= 222 | '.'*[#x0D#x0A]+ 223 | 224 | _shell_text_without_split ::= 225 | ( [^\$#x0D#x0A\] | '\'[abtnvfrE!"#x23\$&'\(\)\*,;<>\?#x5B\#x5D^`{\|}~] | '\'[0-9]'{3}' | '\'[^#x0A#x0D] )+ ( ( _variable | _function | '$$' | '//' ) ( [^\$#x0D#x0A\] | '\'[abtnvfrE!"#x23\$&'\(\)\*,;<>\?#x5B\#x5D^`{\|}~] | '\'[0-9]'{3}' | '\'[^#x0A#x0D] )+? )* 226 | | ( _variable | _function | '$$' | '//' ) ( ( [^\$#x0D#x0A\] | '\'[abtnvfrE!"#x23\$&'\(\)\*,;<>\?#x5B\#x5D^`{\|}~] | '\'[0-9]'{3}' | '\'[^#x0A#x0D] )+? ( _variable | _function | '$$' | '//' ) )* ( [^\$#x0D#x0A\] | '\'[abtnvfrE!"#x23\$&'\(\)\*,;<>\?#x5B\#x5D^`{\|}~] | '\'[0-9]'{3}' | '\'[^#x0A#x0D] )+? 227 | 228 | shell_text_with_split ::= 229 | _shell_text_without_split ( '\\' '#x0D'?'#x0A'|'#x0D' ) 230 | 231 | _shell_command ::= 232 | text 233 | 234 | text ::= 235 | ( [^\$\(\)#x0A#x0D\] | ( '\\' '#x0D'?'#x0A'|'#x0D' ) | '\'[abtnvfrE!"#x23\$&'\(\)\*,;<>\?#x5B\#x5D^`{\|}~] | '\'[0-9]'{3}' | '\'[^#x0A#x0D] )+ ( ( _variable | _function | '$$' | '//' ) ( [^\$\(\)#x0A#x0D\] | ( '\\' '#x0D'?'#x0A'|'#x0D' ) | '\'[abtnvfrE!"#x23\$&'\(\)\*,;<>\?#x5B\#x5D^`{\|}~] | '\'[0-9]'{3}' | '\'[^#x0A#x0D] )+? )* 236 | | ( _variable | _function | '$$' | '//' ) ( ( [^\$\(\)#x0A#x0D\] | ( '\\' '#x0D'?'#x0A'|'#x0D' ) | '\'[abtnvfrE!"#x23\$&'\(\)\*,;<>\?#x5B\#x5D^`{\|}~] | '\'[0-9]'{3}' | '\'[^#x0A#x0D] )+? ( _variable | _function | '$$' | '//' ) )* ( [^\$\(\)#x0A#x0D\] | ( '\\' '#x0D'?'#x0A'|'#x0D' ) | '\'[abtnvfrE!"#x23\$&'\(\)\*,;<>\?#x5B\#x5D^`{\|}~] | '\'[0-9]'{3}' | '\'[^#x0A#x0D] )+? 237 | 238 | comment ::= 239 | '#.'* 240 | 241 | -------------------------------------------------------------------------------- /tree-sitter-menhir.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-menhir/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | source_file ::= 11 | declaration* '%%' rule* ( '%%' postlude? )? 12 | 13 | _high_prec_bar ::= 14 | '|' 15 | 16 | _low_prec_bar ::= 17 | '|' 18 | 19 | lid ::= 20 | [a-zß-öø-ÿ_][a-zA-Z_À-ÖØ-öø-ÿ0-9]* 21 | 22 | uid ::= 23 | [A-ZÀ-ÖØ-Þ][a-zA-Z_À-ÖØ-öø-ÿ0-9]* 24 | 25 | qid ::= 26 | '"'[\x23-\x5b\x5d-\x7e\x20\x21]+'"' 27 | 28 | symbol ::= 29 | lid 30 | | uid 31 | | qid 32 | 33 | declaration ::= 34 | header 35 | | '%parameter' type 36 | | '%token' type? terminal_alias_attrs ( ','? terminal_alias_attrs )* 37 | | priority_keyword symbol ( ','? symbol )* 38 | | '%type' type strict_actual ( ','? strict_actual )* 39 | | '%start' type? non_terminal ( ','? non_terminal )* 40 | | '%attribute' strict_actual ( ','? strict_actual )* attribute+ 41 | | grammar_attribute 42 | | '%on_error_reduce' strict_actual ( ','? strict_actual )* 43 | | ';' 44 | 45 | terminal_alias_attrs ::= 46 | uid qid? attribute* 47 | 48 | priority_keyword ::= 49 | '%left' 50 | | '%right' 51 | | '%nonassoc' 52 | 53 | non_terminal ::= 54 | lid 55 | 56 | rule ::= 57 | old_rule 58 | | new_rule 59 | 60 | old_rule ::= 61 | flags? symbol attribute* ( '(' symbol ( ',' symbol )* ')' )? ':' _low_prec_bar? production_group ( _high_prec_bar production_group )* ';'* 62 | 63 | flags ::= 64 | '%public' 65 | | '%inline' 66 | | '%public' '%inline' 67 | | '%inline' '%public' 68 | 69 | production_group ::= 70 | producer* precedence? ( _high_prec_bar producer* precedence? )* ( action | type ) precedence? 71 | 72 | precedence ::= 73 | '%prec' symbol 74 | 75 | producer ::= 76 | ( lid '=' )? actual attribute* ';'* 77 | 78 | strict_actual ::= 79 | symbol 80 | | symbol '(' strict_actual ( ',' strict_actual )* ')' 81 | | strict_actual modifier 82 | 83 | actual ::= 84 | symbol 85 | | symbol '(' lax_actual ( ',' lax_actual )* ')' 86 | | actual modifier 87 | 88 | lax_actual ::= 89 | symbol 90 | | symbol '(' lax_actual ( ',' lax_actual )* ')' 91 | | actual modifier 92 | | production_group ( _high_prec_bar production_group )* 93 | 94 | modifier ::= 95 | '?' 96 | | '*' 97 | | '+' 98 | 99 | new_rule ::= 100 | '%public'? 'let' lid attribute* ( '(' symbol ( ',' symbol )* ')' )? equality_symbol expression 101 | 102 | equality_symbol ::= 103 | '==' 104 | | ':=' 105 | 106 | expression ::= 107 | '|'? seq_expression ( '|' seq_expression )* 108 | 109 | seq_expression ::= 110 | symbol_expression continuation 111 | | pattern '=' symbol_expression continuation 112 | | symbol_expression 113 | | action_expression 114 | 115 | continuation ::= 116 | ';' seq_expression 117 | 118 | symbol_expression ::= 119 | symbol attribute* 120 | | symbol '(' expression ( ',' expression )* ')' attribute* 121 | | symbol_expression modifier attribute* 122 | 123 | action_expression ::= 124 | menhir_action 125 | | precedence menhir_action 126 | | menhir_action precedence 127 | 128 | menhir_action ::= 129 | action 130 | | type 131 | 132 | pattern ::= 133 | lid 134 | | '_' 135 | | '~' 136 | | '(' ')' 137 | | '(' pattern ( ',' pattern )* ')' 138 | 139 | line_comment ::= 140 | '\/\/.'* 141 | 142 | comment ::= 143 | ( '/*' [^*]*'\'*+([^/*][^*]*'\'*+)* '/' ) 144 | 145 | header ::= 146 | '%{' ocaml? '%}' 147 | 148 | action ::= 149 | '{' ocaml? '}' 150 | 151 | attribute ::= 152 | '[@' ocaml? ']' 153 | 154 | grammar_attribute ::= 155 | '%[@' ocaml? ']' 156 | 157 | type ::= 158 | '<' ocaml_type? '>' 159 | 160 | postlude ::= 161 | ocaml 162 | 163 | ocaml ::= 164 | _ocaml 165 | 166 | _ocaml ::= 167 | ( '{' _ocaml? '}' | '[' _ocaml? ']' | '"'([^"\]|'\x00'|'\'('.'|'#x0A'))*'"' | "'"([^'\]|"\x00"|"\"[\"'ntbr ]|"\"[0-9][0-9][0-9]|"\x"[0-9A-Fa-f][0-9A-Fa-f]|"\o"[0-3][0-7][0-7])"'" | "'"?[A-Za-z_][a-zA-Z0-9_']* | [^{}#x5B#x5D"'%(A-Za-z_]+ | '%' | '(' )+ 168 | 169 | ocaml_type ::= 170 | '->'?|'#x5B>'?|[^-#x5B>]++ 171 | 172 | -------------------------------------------------------------------------------- /tree-sitter-minizinc.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-minizinc/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | source_file ::= 11 | ( _item ';' )* _item? 12 | 13 | _item ::= 14 | annotation 15 | | assignment 16 | | constraint 17 | | declaration 18 | | enumeration 19 | | function_item 20 | | goal 21 | | include 22 | | output 23 | | predicate 24 | 25 | annotation ::= 26 | 'annotation' identifier _parameters? ( '=' _expression )? 27 | 28 | assignment ::= 29 | identifier '=' _expression 30 | 31 | constraint ::= 32 | 'constraint' _expression 33 | 34 | declaration ::= 35 | _type ':' identifier _annotations? ( '=' _expression )? 36 | 37 | enumeration ::= 38 | 'enum' identifier _annotations? ( '=' '{' ( ( identifier ',' )* identifier? ) '}' )? 39 | 40 | function_item ::= 41 | 'function' _type ':' identifier _parameters _annotations? ( '=' _expression )? 42 | 43 | goal ::= 44 | 'solve' ( 'satisfy' | 'maximize' _expression | 'minimize' _expression ) 45 | 46 | include ::= 47 | 'include' string_literal 48 | 49 | output ::= 50 | 'output' _expression 51 | 52 | predicate ::= 53 | ( 'predicate' | 'test' ) identifier _parameters _annotations? ( '=' _expression )? 54 | 55 | _annotations ::= 56 | ( '::' _expression )+ 57 | 58 | _parameters ::= 59 | '(' ( _type ( ':' identifier )? ',' )* ( _type ( ':' identifier )? )? ')' 60 | 61 | _expression ::= 62 | identifier 63 | | _literal 64 | | array_comprehension 65 | | call 66 | | generator_call 67 | | if_then_else 68 | | indexed_access 69 | | infix_operator 70 | | let_expression 71 | | prefix_operator 72 | | set_comprehension 73 | | string_interpolation 74 | | parenthesised_expression 75 | 76 | parenthesised_expression ::= 77 | '(' _expression ')' 78 | 79 | array_comprehension ::= 80 | '[' _expression '|' generator ( ',' generator )* ','? ']' 81 | 82 | call ::= 83 | identifier '(' ( ( _expression ',' )* _expression? ) ')' 84 | 85 | generator_call ::= 86 | identifier '(' ( generator ( ',' generator )* ','? ) ')' '(' _expression ')' 87 | 88 | generator ::= 89 | identifier 'in' _expression ( 'where' _expression )? 90 | 91 | if_then_else ::= 92 | 'if' _expression 'then' _expression ( 'elseif' _expression 'then' _expression )* ( 'else' _expression )? 'endif' 93 | 94 | indexed_access ::= 95 | _expression '[' ( _expression ( ',' _expression )* ) ']' 96 | 97 | infix_operator ::= 98 | _expression '<->' _expression 99 | | _expression ( '->' | '<-' ) _expression 100 | | _expression '\/' _expression 101 | | _expression 'xor' _expression 102 | | _expression '/\' _expression 103 | | _expression ( '=' | '==' | '!=' | '<' | '<=' | '>' | '>=' | 'in' | 'subset' | 'superset' ) _expression 104 | | _expression 'union' _expression 105 | | _expression 'diff' _expression 106 | | _expression 'symdiff' _expression 107 | | _expression 'intersect' _expression 108 | | _expression '..' _expression 109 | | _expression ( '+' | '-' | '++' ) _expression 110 | | _expression ( '*' | '/' | 'div' | 'mod' ) _expression 111 | | _expression '^' _expression 112 | | _expression '::' _expression 113 | 114 | let_expression ::= 115 | 'let' '{' ( ( ( declaration | constraint ) ( ',' | ';' ) )* ( declaration | constraint )? ) '}' 'in' _expression 116 | 117 | prefix_operator ::= 118 | ( '-' | 'not' | '¬' ) _expression 119 | 120 | set_comprehension ::= 121 | '{' _expression '|' generator ( ',' generator )* ','? '}' 122 | 123 | string_interpolation ::= 124 | '"' string_content? ( '\(' _expression ')' string_content? )+ '"' 125 | 126 | _type ::= 127 | array_type 128 | | type_base 129 | 130 | array_type ::= 131 | 'array' '[' type_base ( ',' type_base )* ','? ']' 'of' _type 132 | 133 | type_base ::= 134 | ( 'var' | 'par' )? 'opt'? ( 'set' 'of' )? ( primitive_type | _expression ) 135 | 136 | primitive_type ::= 137 | 'ann' 138 | | 'bool' 139 | | 'float' 140 | | 'int' 141 | | 'string' 142 | 143 | _literal ::= 144 | absent 145 | | array_literal 146 | | boolean_literal 147 | | float_literal 148 | | integer_literal 149 | | set_literal 150 | | string_literal 151 | 152 | absent ::= 153 | '<>' 154 | 155 | array_literal ::= 156 | '[' ( _expression ',' )* _expression? ']' 157 | 158 | boolean_literal ::= 159 | 'true' 160 | | 'false' 161 | 162 | float_literal ::= 163 | ( [0-9]+'.'[0-9]+ | [0-9]+('.'[0-9]+)?[Ee][+-]?[0-9]+ ) 164 | 165 | integer_literal ::= 166 | ( [0-9]+ | '0x'[0-9a-fA-F]+ | '0b'[01]+ | '0o'[0-7]+ ) 167 | 168 | set_literal ::= 169 | '{' ( _expression ',' )* _expression? '}' 170 | 171 | string_literal ::= 172 | '"' string_content? '"' 173 | 174 | string_content ::= 175 | ( [^"#x0A\]+ | escape_sequence )+ 176 | 177 | escape_sequence ::= 178 | ( '\\' ( [^xuU] | [0-9]'{2,3}' | 'x'[0-9a-fA-F]'{2,}' | 'u'[0-9a-fA-F]'{4}' | 'U'[0-9a-fA-F]'{8}' ) ) 179 | 180 | identifier ::= 181 | [A-Za-z][A-Za-z0-9_]* 182 | 183 | line_comment ::= 184 | ( '%' '.'* ) 185 | 186 | block_comment ::= 187 | ( '/*' ([^*]|'\'*[^\/]|'#x0A')*?'\'*? '*/' ) 188 | 189 | -------------------------------------------------------------------------------- /tree-sitter-nix.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-nix/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | source_code ::= 11 | _expression 12 | 13 | _expression ::= 14 | _expr_function_expression 15 | 16 | keyword ::= 17 | 'if'|'then'|'else'|'let'|'inherit'|'in'|'rec'|'with'|'assert' 18 | 19 | identifier ::= 20 | [a-zA-Z_][a-zA-Z0-9_\'#x2D-]* 21 | 22 | variable_expression ::= 23 | identifier 24 | 25 | integer_expression ::= 26 | [0-9]+ 27 | 28 | float_expression ::= 29 | (([1-9][0-9]*'.'[0-9]*)|('0'?'.'[0-9]+))([Ee][+-]?[0-9]+)? 30 | 31 | path_expression ::= 32 | _path_start ( path_fragment | _immediate_interpolation )* 33 | 34 | _hpath_start ::= 35 | '\~\/'[a-zA-Z0-9._#x2D-\+\/]+ 36 | 37 | hpath_expression ::= 38 | _hpath_start ( path_fragment | _immediate_interpolation )* 39 | 40 | spath_expression ::= 41 | '<'[a-zA-Z0-9._#x2D-\+]+('\/'[a-zA-Z0-9._#x2D-\+]+)*'>' 42 | 43 | uri_expression ::= 44 | [a-zA-Z][a-zA-Z0-9\+#x2D-.]*':'[a-zA-Z0-9%\/\?:@\&=\+\$,#x2D-_.\!\~\*\']+ 45 | 46 | _expr_function_expression ::= 47 | function_expression 48 | | assert_expression 49 | | with_expression 50 | | let_expression 51 | | _expr_if 52 | 53 | function_expression ::= 54 | identifier ':' _expr_function_expression 55 | | formals ':' _expr_function_expression 56 | | formals '@' identifier ':' _expr_function_expression 57 | | identifier '@' formals ':' _expr_function_expression 58 | 59 | formals ::= 60 | '{' '}' 61 | | '{' formal ( ',' formal )* '}' 62 | | '{' formal ( ',' formal )* ',' ellipses '}' 63 | | '{' ellipses '}' 64 | 65 | formal ::= 66 | identifier ( '?' _expression )? 67 | 68 | ellipses ::= 69 | '...' 70 | 71 | assert_expression ::= 72 | 'assert' _expression ';' _expr_function_expression 73 | 74 | with_expression ::= 75 | 'with' _expression ';' _expr_function_expression 76 | 77 | let_expression ::= 78 | 'let' binding_set? 'in' _expr_function_expression 79 | 80 | _expr_if ::= 81 | if_expression 82 | | _expr_op 83 | 84 | if_expression ::= 85 | 'if' _expression 'then' _expression 'else' _expression 86 | 87 | _expr_op ::= 88 | has_attr_expression 89 | | unary_expression 90 | | binary_expression 91 | | _expr_apply_expression 92 | 93 | has_attr_expression ::= 94 | _expr_op '?' attrpath 95 | 96 | unary_expression ::= 97 | '!' _expr_op 98 | | '-' _expr_op 99 | 100 | binary_expression ::= 101 | _expr_op '==' _expr_op 102 | | _expr_op '!=' _expr_op 103 | | _expr_op '<' _expr_op 104 | | _expr_op '<=' _expr_op 105 | | _expr_op '>' _expr_op 106 | | _expr_op '>=' _expr_op 107 | | _expr_op '&&' _expr_op 108 | | _expr_op '||' _expr_op 109 | | _expr_op '+' _expr_op 110 | | _expr_op '-' _expr_op 111 | | _expr_op '*' _expr_op 112 | | _expr_op '/' _expr_op 113 | | _expr_op '->' _expr_op 114 | | _expr_op '//' _expr_op 115 | | _expr_op '++' _expr_op 116 | 117 | _expr_apply_expression ::= 118 | apply_expression 119 | | _expr_select_expression 120 | 121 | apply_expression ::= 122 | _expr_apply_expression _expr_select_expression 123 | 124 | _expr_select_expression ::= 125 | select_expression 126 | | _expr_simple 127 | 128 | select_expression ::= 129 | _expr_simple '.' attrpath 130 | | _expr_simple '.' attrpath 'or' _expr_select_expression 131 | 132 | _expr_simple ::= 133 | variable_expression 134 | | integer_expression 135 | | float_expression 136 | | string_expression 137 | | indented_string_expression 138 | | path_expression 139 | | hpath_expression 140 | | spath_expression 141 | | uri_expression 142 | | parenthesized_expression 143 | | attrset_expression 144 | | let_attrset_expression 145 | | rec_attrset_expression 146 | | list_expression 147 | 148 | parenthesized_expression ::= 149 | '(' _expression ')' 150 | 151 | attrset_expression ::= 152 | '{' binding_set? '}' 153 | 154 | let_attrset_expression ::= 155 | 'let' '{' binding_set? '}' 156 | 157 | rec_attrset_expression ::= 158 | 'rec' '{' binding_set? '}' 159 | 160 | string_expression ::= 161 | '"' ( string_fragment | interpolation | escape_sequence | dollar_escape '$' )* '"' 162 | 163 | escape_sequence ::= 164 | '\'([^$]|[ #x09#x0A#x0B#x0C#x0D]) 165 | 166 | indented_string_expression ::= 167 | "''" ( _indented_string_fragment | interpolation | _indented_escape_sequence | _indented_dollar_escape '$' )* "''" 168 | 169 | _indented_escape_sequence ::= 170 | "'''"|"''\"([^$]|[ #x09#x0A#x0B#x0C#x0D]) 171 | 172 | binding_set ::= 173 | ( binding | inherit | inherit_from )+ 174 | 175 | binding ::= 176 | attrpath '=' _expression ';' 177 | 178 | inherit ::= 179 | 'inherit' inherited_attrs ';' 180 | 181 | inherit_from ::= 182 | 'inherit' '(' _expression ')' inherited_attrs ';' 183 | 184 | attrpath ::= 185 | ( identifier | string_expression | interpolation ) ( '.' ( identifier | string_expression | interpolation ) )* 186 | 187 | inherited_attrs ::= 188 | ( identifier | string_expression | interpolation )+ 189 | 190 | _immediate_interpolation ::= 191 | '${' _expression '}' 192 | 193 | interpolation ::= 194 | '${' _expression '}' 195 | 196 | list_expression ::= 197 | '[' _expr_select_expression* ']' 198 | 199 | comment ::= 200 | ( '#' '.'* | '/*' [^*]*'\'*+([^/*][^*]*'\'*+)* '/' ) 201 | 202 | -------------------------------------------------------------------------------- /tree-sitter-powershell.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-powershell/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | script ::= 11 | script_block? signature_block? 12 | 13 | script_block ::= 14 | param_block? statement_list 15 | 16 | param_block ::= 17 | [pP][aA][rR][aA][mM] parameter_list 18 | 19 | parameter_list ::= 20 | '(' ( parameter_declaration ( ',' parameter_declaration )* )? ')' 21 | 22 | parameter_declaration ::= 23 | attribute* user_variable 24 | 25 | attribute ::= 26 | '[' identifier attribute_arguments? ']' 27 | 28 | array_declaration ::= 29 | '[' ','*? ']' 30 | 31 | attribute_arguments ::= 32 | '(' ( attribute_argument ( ',' attribute_argument )* )? ')' 33 | 34 | attribute_argument ::= 35 | identifier ( '=' ( string | identifier | number ) )? 36 | 37 | statement_block ::= 38 | '{' statement_list? '}' 39 | 40 | statement_list ::= 41 | ( statement statement_terminator? )+ 42 | 43 | statement_terminator ::= 44 | ';' 45 | 46 | statement ::= 47 | function_definition 48 | | if 49 | | while 50 | | do 51 | | for 52 | | foreach 53 | | try 54 | | trap 55 | | data 56 | | switch 57 | | flow_control_statement 58 | | labeled_statement 59 | | user_variable 60 | | boolean_value 61 | | number 62 | | string 63 | | expandable_here_string 64 | 65 | pipeline ::= 66 | boolean_value 67 | | user_variable 68 | 69 | function_definition ::= 70 | ( [fF][uU][nN][cC][tT][iI][oO][nN] | [fF][iI][lL][tT][eE][rR] | [wW][oO][rR][kK][fF][lL][oO][wW] ) identifier parameter_list? '{' script_block '}' 71 | 72 | if ::= 73 | [iI][fF] '(' boolean_value ')' statement_block elseif* else? 74 | 75 | elseif ::= 76 | [eE][lL][sS][eE][iI][fF] statement_block 77 | 78 | else ::= 79 | [eE][lL][sS][eE] statement_block 80 | 81 | while ::= 82 | [wW][hH][iI][lL][eE] '(' boolean_value ')' statement_block 83 | 84 | do ::= 85 | [dD][oO] statement_block ( [wW][hH][iI][lL][eE] | [uU][nN][tT][iI][lL] ) '(' boolean_value ')' 86 | 87 | for ::= 88 | [fF][oO][rR] '(' ( pipeline statement_terminator? )? ( pipeline statement_terminator? )? pipeline? ')' statement_block 89 | 90 | foreach ::= 91 | [fF][oO][rR][eE][aA][cC][hH] foreach_parameter? '(' user_variable [iI][nN] user_variable ')' statement_block 92 | 93 | foreach_parameter ::= 94 | '-' [pP][aA][rR][aA][lL][lL][eE][lL] 95 | 96 | try ::= 97 | [tT][rR][yY] statement_block catch* finally? 98 | 99 | catch ::= 100 | [cC][aA][tT][cC][hH] type_literal* statement_block 101 | 102 | finally ::= 103 | [fF][iI][nN][aA][lL][lL][yY] statement_block 104 | 105 | trap ::= 106 | [tT][rR][aA][pP] type_literal? statement_block 107 | 108 | data ::= 109 | [dD][aA][tT][aA] identifier? statement_block 110 | 111 | labeled_statement ::= 112 | label ( switch | foreach | for | while | do ) 113 | 114 | label ::= 115 | ':' identifier 116 | 117 | flow_control_statement ::= 118 | flow_break_continue 119 | | [rR][eE][tT][uU][rR][nN] 120 | | [tT][hH][rR][oO][wW] 121 | | [eE][xX][iI][tT] 122 | 123 | flow_break_continue ::= 124 | ( [bB][rR][eE][aA][kK] | [cC][oO][nN][tT][iI][nN][uU][eE] ) identifier? 125 | 126 | switch ::= 127 | [sS][wW][iI][tT][cC][hH] switch_parameter* switch_condition switch_body 128 | 129 | switch_parameter ::= 130 | '-' ( [rR] | [rR][eE] | [rR][eE][gG] | [rR][eE][gG][eE] | [rR][eE][gG][eE][xX] | [wW] | [wW][iI] | [wW][iI][lL] | [wW][iI][lL][dD] | [wW][iI][lL][dD][cC] | [wW][iI][lL][dD][cC][aA] | [wW][iI][lL][dD][cC][aA][rR] | [wW][iI][lL][dD][cC][aA][rR][dD] | [eE] | [eE][xX] | [eE][xX][aA] | [eE][xX][aA][cC] | [eE][xX][aA][cC][tT] | [cC] | [cC][aA] | [cC][aA][sS] | [cC][aA][sS][eE] | [cC][aA][sS][eE][sS] | [cC][aA][sS][eE][sS][eE] | [cC][aA][sS][eE][sS][eE][nN] | [cC][aA][sS][eE][sS][eE][nN][sS] | [cC][aA][sS][eE][sS][eE][nN][sS][iI] | [cC][aA][sS][eE][sS][eE][nN][sS][iI][tT] | [cC][aA][sS][eE][sS][eE][nN][sS][iI][tT][iI] | [cC][aA][sS][eE][sS][eE][nN][sS][iI][tT][iI][vV] | [cC][aA][sS][eE][sS][eE][nN][sS][iI][tT][iI][vV][eE] | [pP] | [pP][aA] | [pP][aA][rR] | [pP][aA][rR][aA] | [pP][aA][rR][aA][lL] | [pP][aA][rR][aA][lL][lL] | [pP][aA][rR][aA][lL][lL][eE] | [pP][aA][rR][aA][lL][lL][eE][lL] ) 131 | 132 | switch_condition ::= 133 | '(' boolean_value ')' 134 | 135 | switch_body ::= 136 | '{' switch_clause* '}' 137 | 138 | switch_clause ::= 139 | switch_clause_condition statement_block 140 | 141 | switch_clause_condition ::= 142 | identifier 143 | 144 | type_literal ::= 145 | '[' identifier ( array_declaration | type_literal )? ']' 146 | 147 | boolean_value ::= 148 | ( '$' ( [tT][rR][uU][eE] | [fF][aA][lL][sS][eE] ) ) 149 | 150 | user_variable ::= 151 | '\$'[a-zA-Z][a-zA-Z_]* 152 | 153 | identifier ::= 154 | [a-zA-Z][a-zA-Z_]* 155 | 156 | string ::= 157 | ( '"' ( [^\"#x0A] | '\'('.'|'#x0A') )* '"' | "'" ( [^\'#x0A] | '\'('.'|'#x0A') )* "'" | "@'" [^(\'@)]* [#x0D|#x0D#x0A|#x0A]"'@" ) 158 | 159 | expandable_here_string ::= 160 | '@"' ( expandable_string_chars | expandable_string_part )* '"@' 161 | 162 | expandable_string_chars ::= 163 | ( [^"@$] | '\$'[^(] | '"'[^@] )+ 164 | 165 | expandable_string_part ::= 166 | '$' '(' statement ')' 167 | 168 | number ::= 169 | ( ( '0x' | '0X' ) [0-9a-fA-F]+ | ( '0' | [1-9] [0-9]+? ) '.' [0-9]+? ( ( 'e' | 'E' ) ( '-' | '+' )? [0-9]+ )? | '.' [0-9]+ ( ( 'e' | 'E' ) ( '-' | '+' )? [0-9]+ )? | ( '0' | [1-9] [0-9]+? ) ( ( 'e' | 'E' ) ( '-' | '+' )? [0-9]+ )? ) suffix* 170 | 171 | suffix ::= 172 | [lL] 173 | | [dD] 174 | | [kK][bB] 175 | | [mM][bB] 176 | | [gG][bB] 177 | | [tT][bB] 178 | | [pP][bB] 179 | 180 | comment ::= 181 | ( '#.'* | '<#' [^#x23]*'\#'+(?':'[^<#x23][^#x23]*'#'+)* '>' ) 182 | 183 | signature_block ::= 184 | '# SIG' 185 | 186 | -------------------------------------------------------------------------------- /tree-sitter-prolog.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-prolog/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | source_file ::= 11 | _topLevel* 12 | 13 | _topLevel ::= 14 | predicate_definition 15 | | dcg_definition 16 | | directive 17 | | query 18 | 19 | directive ::= 20 | ':-' values '.' 21 | 22 | query ::= 23 | '?-' values '.' 24 | 25 | predicate_definition ::= 26 | ( atom ':' )? ( atom | term ) ( ':-' values )? '.' 27 | 28 | dcg_definition ::= 29 | ( atom ':' )? ( atom | term ) ( ',' _value )? ( '-->' | '-->>' ) values '.' 30 | 31 | values ::= 32 | ( _value ',' )* _value 33 | 34 | term ::= 35 | atom '(' values ')' 36 | 37 | _simple_value ::= 38 | atom | term | string | list | number | var | char_code | dict | codes | quasiquote | '.' 39 | 40 | quasiquote ::= 41 | '{|' ( atom | term ) '||' ([^|]|('\'|[^}]))* '|}' 42 | 43 | dict_op_term ::= 44 | ( '.' ( [a-z][a-zA-Z0-9_]* | "'"([^'\]|("\."))*"'" | ( '!' | '=' | '-' | '/' | '+' | '*' | '#' | '>' | '<' | ':' | ';' | '?' | '\\' | '^' | '@' | '$' )+ | '..' ) '(' ) values ')' 45 | 46 | dict_operator ::= 47 | ( var | dict | dict_operator ) ( dict_op_term | ( '.' ( [a-z][a-zA-Z0-9_]* | "'"([^'\]|("\."))*"'" | ( '!' | '=' | '-' | '/' | '+' | '*' | '#' | '>' | '<' | ':' | ';' | '?' | '\\' | '^' | '@' | '$' )+ | '..' ) ) | ( '.' [_A-Z][a-zA-Z0-9_]* ) ) 48 | 49 | _value ::= 50 | dict_operator 51 | | _simple_value 52 | | curly_braced 53 | | parenthesized 54 | | binary_op 55 | | unary_op 56 | 57 | curly_braced ::= 58 | '{' values? '}' 59 | 60 | parenthesized ::= 61 | '(' values ')' 62 | 63 | atom ::= 64 | [a-z][a-zA-Z0-9_]* 65 | | "'"([^'\]|("\."))*"'" 66 | | _sym_atom 67 | | '..' 68 | 69 | _sym_atom ::= 70 | ( '!' | '=' | '-' | '/' | '+' | '*' | '#' | '>' | '<' | ':' | ';' | '?' | '\\' | '^' | '@' | '$' )+ 71 | 72 | var ::= 73 | [_A-Z][a-zA-Z0-9_]* 74 | 75 | unary_op ::= 76 | ( '\\' ) _value | ( '\+' ) _value | ( 'dynamic' | 'discontiguous' | 'initialization' | 'meta_predicate' | 'module_transparent' | 'multifile' | 'public' | 'thread_local' | 'thread_initialization' | 'volatile' ) _value | atom _value 77 | 78 | binary_op ::= 79 | _value ( '^' | '**' ) _value 80 | | _value ( '*' | '/' | '//' | 'div' | 'rdiv' | '<<' | '>>' | 'mod' | 'rem' ) _value 81 | | _value ( '+' | '-' | '/\' | '\/' | 'xor' ) _value 82 | | _value ( ':' ) _value 83 | | _value ( '<' | '=' | '=..' | '=@=' | '\=@=' | '=:=' | '=<' | '==' | '=\=' | '>' | '>=' | '@<' | '@=<' | '@>' | '@>=' | '\=' | '\==' | 'as' | 'is' | '>:<' | ':<' | '..' ) _value 84 | | _value ( ':=' ) _value 85 | | _value ( '->' | '*->' ) _value 86 | | _value ( ';' | '|' ) _value 87 | | _value atom _value 88 | 89 | string ::= 90 | '"'(([^"\])|('\'([^xu0-7]|[0-7]'{1,3}'|'x'[0-9a-fA-F]'{2}'|'u'[0-9a-fA-F]'{4}')))*'"' 91 | 92 | codes ::= 93 | '`'(([^`\])|('\'([^xu0-7]|[0-7]'{1,3}'|'x'[0-9a-fA-F]'{2}'|'u'[0-9a-fA-F]'{4}')))*'`' 94 | 95 | comment ::= 96 | '%' '.'* | '/*' ([^*]|('\'*+[^/*]))*'\'*+ '/' 97 | 98 | escape_sequence ::= 99 | ( '\\' ( [^xu0-7] | [0-7]'{1,3}' | 'x'[0-9a-fA-F]'{2}' | 'u'[0-9a-fA-F]'{4}' ) ) 100 | 101 | char_code ::= 102 | "0'" ( '.' | escape_sequence ) 103 | 104 | number ::= 105 | [-+]?[_0-9]+ 106 | | [-+]?[_0-9]+'.'[_0-9]+ 107 | | [-+]?'0b'[01_]+ 108 | | [-+]?'0x'[0-9a-fA-F_]+ 109 | | [-+]?'0c'[0-7_]+ 110 | | [-+]?([1-9]|[1-2][0-9]|'3'[0-6])"'"[_0-9a-zA-Z]+ 111 | | [-+]?[0-9_]+[/][1-9_]+ 112 | | [-+]?[0-9_]+'r'[1-9_]+ 113 | | [-+]?([0-9_]('.'[0-9_]+)?)+'e'[0-9_]+ 114 | | [-+]?[0-9]+[.][0-9]+'Inf' 115 | 116 | list ::= 117 | '[' values? ( '|' _value )? ']' 118 | 119 | dict ::= 120 | ( atom | var ) '{' dict_entries? '}' 121 | 122 | dict_entries ::= 123 | ( dict_entry ',' )* dict_entry 124 | 125 | dict_entry ::= 126 | atom ':' _value 127 | 128 | -------------------------------------------------------------------------------- /tree-sitter-ql.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-ql/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | ql ::= 11 | moduleMember* 12 | 13 | module ::= 14 | 'module' moduleName ( '<' moduleParam ( ',' moduleParam )* '>' )? ( 'implements' signatureExpr ( ',' signatureExpr )* )? ( '{' moduleMember* '}' | moduleAliasBody ) 15 | 16 | moduleMember ::= 17 | annotation* ( importDirective | classlessPredicate | dataclass | datatype | select | module ) 18 | | qldoc 19 | 20 | importDirective ::= 21 | 'import' importModuleExpr ( 'as' moduleName )? 22 | 23 | moduleAliasBody ::= 24 | '=' moduleExpr ';' 25 | 26 | predicateAliasBody ::= 27 | '=' predicateExpr ';' 28 | 29 | typeAliasBody ::= 30 | '=' typeExpr ';' 31 | 32 | typeUnionBody ::= 33 | '=' typeExpr 'or' ( typeExpr ( 'or' typeExpr )* )? ';' 34 | 35 | classlessPredicate ::= 36 | ( predicate | typeExpr ) predicateName ( '(' ( varDecl ( ',' varDecl )* )? ')' _optbody | predicateAliasBody ) 37 | 38 | datatype ::= 39 | 'newtype' className '=' datatypeBranches 40 | 41 | datatypeBranches ::= 42 | datatypeBranch ( 'or' datatypeBranch )* 43 | 44 | datatypeBranch ::= 45 | qldoc? annotation? className '(' ( varDecl ( ',' varDecl )* )? ')' body? 46 | 47 | select ::= 48 | ( 'from' ( varDecl ( ',' varDecl )* )? )? ( 'where' _exprOrTerm )? 'select' asExprs orderBys? 49 | 50 | dataclass ::= 51 | 'class' className ( ( 'extends' typeExpr ( ',' typeExpr )* )? ( 'instanceof' typeExpr ( ',' typeExpr )* )? ( '{' classMember* '}' | ';' ) | typeAliasBody | typeUnionBody ) 52 | 53 | classMember ::= 54 | annotation* ( charpred | memberPredicate | field ) 55 | | qldoc 56 | 57 | charpred ::= 58 | className '(' ')' '{' _exprOrTerm '}' 59 | 60 | memberPredicate ::= 61 | ( predicate | typeExpr ) predicateName '(' ( varDecl ( ',' varDecl )* )? ')' _optbody 62 | 63 | field ::= 64 | varDecl ';' 65 | 66 | _optbody ::= 67 | empty 68 | | body 69 | | higherOrderTerm 70 | 71 | empty ::= 72 | ';' 73 | 74 | body ::= 75 | '{' _exprOrTerm '}' 76 | 77 | higherOrderTerm ::= 78 | '=' literalId '(' ( predicateExpr ( ',' predicateExpr )* )? ')' '(' ( _call_arg ( ',' _call_arg )* )? ')' 79 | 80 | special_call ::= 81 | specialId '(' ')' 82 | 83 | prefix_cast ::= 84 | '(' typeExpr ')' _exprOrTerm 85 | 86 | unary_expr ::= 87 | unop _exprOrTerm 88 | 89 | mul_expr ::= 90 | _exprOrTerm mulop _exprOrTerm 91 | 92 | add_expr ::= 93 | _exprOrTerm addop _exprOrTerm 94 | 95 | in_expr ::= 96 | _exprOrTerm 'in' _primary 97 | 98 | comp_term ::= 99 | _exprOrTerm compop _exprOrTerm 100 | 101 | instance_of ::= 102 | _exprOrTerm 'instanceof' typeExpr 103 | 104 | negation ::= 105 | 'not' _exprOrTerm 106 | 107 | if_term ::= 108 | 'if' _exprOrTerm 'then' _exprOrTerm 'else' _exprOrTerm 109 | 110 | conjunction ::= 111 | _exprOrTerm 'and' _exprOrTerm 112 | 113 | disjunction ::= 114 | _exprOrTerm 'or' _exprOrTerm 115 | 116 | implication ::= 117 | _exprOrTerm 'implies' _exprOrTerm 118 | 119 | quantified ::= 120 | quantifier '(' ( ( varDecl ( ',' varDecl )* )? ( '|' _exprOrTerm ( '|' _exprOrTerm )? )? | _exprOrTerm ) ')' 121 | 122 | specialId ::= 123 | 'none' 124 | 125 | quantifier ::= 126 | 'exists' 127 | | 'forall' 128 | | 'forex' 129 | 130 | _call_arg ::= 131 | _exprOrTerm 132 | | underscore 133 | 134 | underscore ::= 135 | '_' 136 | 137 | qualifiedRhs ::= 138 | predicateName closure? '(' ( _call_arg ( ',' _call_arg )* )? ')' 139 | | '(' typeExpr ')' 140 | 141 | call_body ::= 142 | '(' ( _call_arg ( ',' _call_arg )* )? ')' 143 | 144 | unqual_agg_body ::= 145 | '(' ( varDecl ( ',' varDecl )* )? '|' _exprOrTerm? ( '|' asExprs )? ')' 146 | 147 | _call_or_unqual_agg_body ::= 148 | call_body 149 | | unqual_agg_body 150 | 151 | call_or_unqual_agg_expr ::= 152 | aritylessPredicateExpr closure? _call_or_unqual_agg_body 153 | 154 | qualified_expr ::= 155 | _primary '.' qualifiedRhs 156 | 157 | super_ref ::= 158 | ( typeExpr '.' )? super 159 | 160 | full_aggregate_body ::= 161 | ( varDecl ( ',' varDecl )* )? '|' _exprOrTerm? ( '|' asExprs orderBys? )? 162 | | varDecl ( ',' varDecl )* 163 | 164 | expr_aggregate_body ::= 165 | asExprs orderBys? 166 | 167 | aggregate ::= 168 | aggId ( '[' _exprOrTerm ( ',' _exprOrTerm )* ']' )? '(' ( full_aggregate_body | expr_aggregate_body )? ')' 169 | 170 | range ::= 171 | '[' _exprOrTerm '..' _exprOrTerm ']' 172 | 173 | set_literal ::= 174 | '[' ( _exprOrTerm ( ',' _exprOrTerm )* )? ','? ']' 175 | 176 | par_expr ::= 177 | '(' _exprOrTerm ')' 178 | 179 | expr_annotation ::= 180 | annotName '[' annotName ']' '(' _exprOrTerm ')' 181 | 182 | _exprOrTerm ::= 183 | special_call 184 | | prefix_cast 185 | | _primary 186 | | unary_expr 187 | | mul_expr 188 | | add_expr 189 | | in_expr 190 | | comp_term 191 | | instance_of 192 | | negation 193 | | if_term 194 | | conjunction 195 | | disjunction 196 | | implication 197 | | quantified 198 | 199 | _primary ::= 200 | call_or_unqual_agg_expr 201 | | qualified_expr 202 | | literal 203 | | variable 204 | | super_ref 205 | | aggregate 206 | | range 207 | | set_literal 208 | | par_expr 209 | | expr_annotation 210 | 211 | literal ::= 212 | integer 213 | | float 214 | | bool 215 | | string 216 | 217 | bool ::= 218 | true 219 | | false 220 | 221 | variable ::= 222 | this 223 | | result 224 | | varName 225 | 226 | compop ::= 227 | '=' 228 | | '!=' 229 | | '<' 230 | | '>' 231 | | '<=' 232 | | '>=' 233 | 234 | unop ::= 235 | '+' 236 | | '-' 237 | 238 | mulop ::= 239 | '*' 240 | | '/' 241 | | '%' 242 | 243 | addop ::= 244 | '+' 245 | | '-' 246 | 247 | closure ::= 248 | '*' 249 | | '+' 250 | 251 | direction ::= 252 | 'asc' 253 | | 'desc' 254 | 255 | varDecl ::= 256 | typeExpr varName 257 | 258 | moduleParam ::= 259 | signatureExpr simpleId 260 | 261 | asExprs ::= 262 | asExpr ( ',' asExpr )* 263 | 264 | asExpr ::= 265 | _exprOrTerm ( 'as' varName )? 266 | 267 | orderBys ::= 268 | 'order' 'by' orderBy ( ',' orderBy )* 269 | 270 | orderBy ::= 271 | _exprOrTerm direction? 272 | 273 | qldoc ::= 274 | '\/\'*'\'*[^*]*'\'*+([^/*][^*]*'\'*+)*'\/' 275 | 276 | literalId ::= 277 | _lower_id 278 | | _upper_id 279 | 280 | annotation ::= 281 | annotName 282 | | annotName '[' ( annotArg ( ',' annotArg )* ) ']' 283 | 284 | annotName ::= 285 | _lower_id 286 | 287 | annotArg ::= 288 | simpleId 289 | | this 290 | | result 291 | 292 | moduleName ::= 293 | simpleId 294 | 295 | importModuleExpr ::= 296 | ( simpleId '.' )* moduleExpr 297 | 298 | moduleExpr ::= 299 | simpleId 300 | | moduleInstantiation 301 | | moduleExpr '::' ( simpleId | moduleInstantiation ) 302 | 303 | moduleInstantiation ::= 304 | moduleName '<' signatureExpr ( ',' signatureExpr )* '>' 305 | 306 | primitiveType ::= 307 | 'boolean' 308 | | 'date' 309 | | 'float' 310 | | 'int' 311 | | 'string' 312 | 313 | simpleId ::= 314 | _lower_id 315 | | _upper_id 316 | 317 | className ::= 318 | _upper_id 319 | 320 | dbtype ::= 321 | '@'[a-z][A-Za-z0-9_]* 322 | 323 | typeExpr ::= 324 | ( moduleExpr '::' )? className 325 | | dbtype 326 | | primitiveType 327 | 328 | signatureExpr ::= 329 | typeExpr 330 | | moduleExpr 331 | | predicateExpr 332 | 333 | predicateName ::= 334 | _lower_id 335 | 336 | aritylessPredicateExpr ::= 337 | ( moduleExpr '::' )? literalId 338 | 339 | predicateExpr ::= 340 | aritylessPredicateExpr '/' integer 341 | 342 | varName ::= 343 | simpleId 344 | 345 | aggId ::= 346 | 'avg' 347 | | 'concat' 348 | | 'strictconcat' 349 | | 'count' 350 | | 'max' 351 | | 'min' 352 | | 'rank' 353 | | 'strictcount' 354 | | 'strictsum' 355 | | 'sum' 356 | | 'any' 357 | | 'unique' 358 | 359 | _upper_id ::= 360 | [A-Z][A-Za-z0-9_]* 361 | 362 | _lower_id ::= 363 | [a-z][A-Za-z0-9_]* 364 | 365 | integer ::= 366 | [0-9]+ 367 | 368 | float ::= 369 | [0-9]+'.'[0-9]+ 370 | 371 | string ::= 372 | '"'([^"\#x0D#x0A#x09]|'\'["\nrt])*'"' 373 | 374 | line_comment ::= 375 | '\/\/'[^#x0D#x0A]* 376 | 377 | block_comment ::= 378 | '\/\'*([^*]+'\'*+([^/*][^*]*'\'*+)*|'\'*)'\/' 379 | 380 | false ::= 381 | 'false' 382 | 383 | predicate ::= 384 | 'predicate' 385 | 386 | result ::= 387 | 'result' 388 | 389 | super ::= 390 | 'super' 391 | 392 | this ::= 393 | 'this' 394 | 395 | true ::= 396 | 'true' 397 | 398 | -------------------------------------------------------------------------------- /tree-sitter-quakec.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-quakec/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | source_file ::= 11 | _top_level* 12 | 13 | _top_level ::= 14 | function_declaration 15 | | variable_definition 16 | | field_definition 17 | | function_definition 18 | | enum_definition 19 | | modelgen_pragma 20 | | _preprocessor_top_level 21 | 22 | function_declaration ::= 23 | simple_type ( identifier parameter_list | parameter_list identifier ) ';' 24 | 25 | function_definition ::= 26 | simple_type ( parameter_list identifier | identifier parameter_list ) '='? _frame_specifier? ( builtin_literal | _statement ) ';'? 27 | 28 | enum_definition ::= 29 | 'enum' ( 'class' identifier )? ( ':' simple_type )? '{' ( _enum_constant_specifier ( ',' _enum_constant_specifier )* )* '}' ';'? 30 | 31 | _enum_constant_specifier ::= 32 | identifier ( '=' _expression )? 33 | 34 | _frame_specifier ::= 35 | '[' ( frame_identifier | integer_frame_literal ) ',' identifier ']' 36 | 37 | variable_definition ::= 38 | _type_modifier*? simple_type ( _variable_name_specifier ( '=' _expression )? ) ( ',' ( _variable_name_specifier ( '=' _expression )? ) )* ';' 39 | 40 | _variable_name_specifier ::= 41 | identifier _array_declarator? 42 | 43 | _variable_def_type ::= 44 | simple_type 45 | | function_ref_type 46 | 47 | _array_declarator ::= 48 | '[' _expression? ']' 49 | 50 | field_definition ::= 51 | '.' ( _field_variable_definition | _field_function_definition ) ';' 52 | 53 | _field_variable_definition ::= 54 | simple_type identifier ( ',' identifier )* 55 | 56 | _field_function_definition ::= 57 | simple_type parameter_list identifier ( ',' identifier )* 58 | 59 | parameter_list ::= 60 | '(' ( parameter ( ',' parameter )* )? ( ','? '...' )? ')' 61 | 62 | parameter ::= 63 | ( simple_type | field_ptr_type | function_ref_type ) identifier ( '=' _parameter_initializer )? 64 | 65 | _parameter_initializer ::= 66 | _literal 67 | | identifier 68 | 69 | modelgen_pragma ::= 70 | '$' ( 'flags' | 'base' | 'cd' | 'frame' | 'modelname' | 'origin' | 'scale' | 'skin' | 'spritename' | 'type' | 'load' ) [^#x0A]+ 71 | 72 | _preprocessor_top_level ::= 73 | preproc_ifdef_top_level 74 | | preproc_def 75 | | preproc_undef 76 | 77 | _preprocessor_local ::= 78 | preproc_ifdef_local 79 | | preproc_def 80 | | preproc_undef 81 | 82 | preproc_ifdef_top_level ::= 83 | ( '#ifdef' | '#ifndef' ) identifier '#x0D'?'#x0A' _top_level* ( '#else' '#x0D'?'#x0A' _top_level* )? '#endif' '#x0D'?'#x0A' 84 | 85 | preproc_ifdef_local ::= 86 | ( '#ifdef' | '#ifndef' ) identifier '#x0D'?'#x0A' _simple_statement* ( '#else' '#x0D'?'#x0A' _simple_statement* )? '#endif' '#x0D'?'#x0A' 87 | 88 | preproc_def ::= 89 | '#define' identifier _preproc_arg? '#x0D'?'#x0A' 90 | 91 | preproc_undef ::= 92 | '#undef' identifier '#x0D'?'#x0A' 93 | 94 | _preproc_arg ::= 95 | '\S'([^/#x0A]|'\/'[^*]|'\#x0D'?'#x0A')* 96 | 97 | _statement ::= 98 | case_statement 99 | | _non_case_statement 100 | 101 | _non_case_statement ::= 102 | compound_statement 103 | | _simple_statement 104 | 105 | compound_statement ::= 106 | '{' _statement* '}' 107 | 108 | _simple_statement ::= 109 | switch_statement 110 | | break_statement 111 | | continue_statement 112 | | if_statement 113 | | for_statement 114 | | while_statement 115 | | do_while_statement 116 | | return_statement 117 | | _variable_definition_statement 118 | | _expression_statement 119 | | _preprocessor_local 120 | 121 | switch_statement ::= 122 | 'switch' _parenthesized_expression compound_statement 123 | 124 | case_statement ::= 125 | ( 'case' _expression | 'default' ) ':' _non_case_statement* 126 | 127 | break_statement ::= 128 | 'break' ';' 129 | 130 | continue_statement ::= 131 | 'continue' ';' 132 | 133 | for_statement ::= 134 | 'for' '(' _expression ';' _expression ';' _expression ')' _statement 135 | 136 | if_statement ::= 137 | 'if' _parenthesized_expression _statement ( 'else' _statement )? 138 | 139 | while_statement ::= 140 | 'while' _parenthesized_expression _statement 141 | 142 | do_while_statement ::= 143 | 'do' _statement 'while' _parenthesized_expression ';' 144 | 145 | return_statement ::= 146 | 'return' _expression? ';' 147 | 148 | _variable_definition_statement ::= 149 | variable_definition 150 | 151 | _expression_statement ::= 152 | _expression ';' 153 | 154 | _expression ::= 155 | identifier 156 | | frame_identifier 157 | | _literal 158 | | unary_expression 159 | | update_expression 160 | | binary_expression 161 | | conditional_expression 162 | | assignment_expression 163 | | field_expression 164 | | funcall_expression 165 | | subscript_expression 166 | | _parenthesized_expression 167 | 168 | update_expression ::= 169 | ( '--' | '++' ) _expression | _expression ( '--' | '++' ) 170 | 171 | unary_expression ::= 172 | ( '-' | '+' | '~' | '!' ) _expression 173 | 174 | binary_expression ::= 175 | _expression '+' _expression 176 | | _expression '-' _expression 177 | | _expression '*' _expression 178 | | _expression '/' _expression 179 | | _expression '%' _expression 180 | | _expression '||' _expression 181 | | _expression '&&' _expression 182 | | _expression '|' _expression 183 | | _expression '&' _expression 184 | | _expression '==' _expression 185 | | _expression '!=' _expression 186 | | _expression '>' _expression 187 | | _expression '>=' _expression 188 | | _expression '<=' _expression 189 | | _expression '<' _expression 190 | 191 | conditional_expression ::= 192 | _expression '?' _expression? ':' _expression 193 | 194 | assignment_expression ::= 195 | ( identifier | field_expression ) ( '=' | '+=' | '-=' | '*=' | '/=' | '|=' | '&=' | '&~=' | '%=' | '(-)' | '(+)' | '^=' ) _expression 196 | 197 | subscript_expression ::= 198 | _expression '[' _expression ']' 199 | 200 | field_expression ::= 201 | _expression ( '.' | '->' ) identifier 202 | 203 | funcall_expression ::= 204 | _expression '(' ( _expression ( ',' _expression )* )? ')' 205 | 206 | _parenthesized_expression ::= 207 | '(' _expression ')' 208 | 209 | _type_modifier ::= 210 | 'var' 211 | | 'const' 212 | | 'static' 213 | | 'nosave' 214 | | 'local' 215 | 216 | simple_type ::= 217 | 'void' 218 | | 'entity' 219 | | 'float' 220 | | 'vector' 221 | | 'string' 222 | | 'int' 223 | | 'integer' 224 | 225 | field_ptr_type ::= 226 | '.' simple_type 227 | 228 | function_ref_type ::= 229 | simple_type parameter_list 230 | 231 | identifier ::= 232 | [a-zA-Z_][a-zA-Z0-9_]* 233 | 234 | frame_identifier ::= 235 | '$' [a-zA-Z_][a-zA-Z0-9_.]* 236 | 237 | _literal ::= 238 | numeric_literal 239 | | vector_literal 240 | | array_literal 241 | | string_literal 242 | 243 | numeric_literal ::= 244 | _integer_literal 245 | | _float_literal 246 | 247 | _integer_literal ::= 248 | '-'?[0-9]+'i'? 249 | 250 | _float_literal ::= 251 | '-'?([0-9]+)?'.'([0-9]+'f'?)? 252 | 253 | vector_literal ::= 254 | "'" numeric_literal numeric_literal numeric_literal "'" 255 | 256 | array_literal ::= 257 | '{' _expression ( ',' _expression )* '}' 258 | 259 | string_literal ::= 260 | '"' ( [^\"#x0A]+ | _escape_sequence )* [^"]* '"' 261 | 262 | _escape_sequence ::= 263 | '\\' ( 'n' | 'r' | '"' | "'" | '\\' | [0-9] ) 264 | 265 | builtin_literal ::= 266 | '#'[0-9]+(':'[a-zA-Z_][a-zA-Z0-9_]*)? 267 | 268 | integer_frame_literal ::= 269 | _integer_literal 270 | 271 | comment ::= 272 | ( '//' '.'* | '/*' [^*]*'\'*+([^/*][^*]*'\'*+)* '/' ) 273 | 274 | -------------------------------------------------------------------------------- /tree-sitter-r.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-r/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | program ::= 11 | ( _expression ( '\n' | ';' )? )* 12 | 13 | _definition ::= 14 | function_definition 15 | | lambda_function 16 | 17 | function_definition ::= 18 | 'function' formal_parameters _expression 19 | 20 | lambda_function ::= 21 | '\\' formal_parameters _expression 22 | 23 | if ::= 24 | 'if' '(' _expression ')' _expression ( 'else' _expression )? 25 | 26 | while ::= 27 | 'while' '(' _expression ')' _expression 28 | 29 | repeat ::= 30 | 'repeat' _expression 31 | 32 | for ::= 33 | 'for' '(' identifier 'in' _expression ')' _expression 34 | 35 | switch ::= 36 | 'switch' '(' _expression ',' arguments ')' 37 | 38 | formal_parameters ::= 39 | '(' ( _formal_parameter ( ',' _formal_parameter )* ','? )? ')' 40 | 41 | default_parameter ::= 42 | identifier '=' _expression 43 | 44 | _formal_parameter ::= 45 | identifier 46 | | default_parameter 47 | | dots 48 | 49 | block ::= 50 | '{' _expression* '}' 51 | 52 | arguments ::= 53 | ( _argument | ',' )+ 54 | 55 | default_argument ::= 56 | ( identifier | string | dots ) '=' _expression? 57 | 58 | _argument ::= 59 | _expression | default_argument 60 | 61 | call ::= 62 | _expression '(' arguments? ')' 63 | 64 | _assignment ::= 65 | equals_assignment 66 | | left_assignment 67 | | left_assignment2 68 | | right_assignment 69 | | super_assignment 70 | | super_right_assignment 71 | 72 | left_assignment ::= 73 | _expression '<-' _expression 74 | 75 | left_assignment2 ::= 76 | _expression ':=' _expression 77 | 78 | equals_assignment ::= 79 | _expression '=' _expression 80 | 81 | super_assignment ::= 82 | _expression '<<-' _expression 83 | 84 | super_right_assignment ::= 85 | _expression '->>' _expression 86 | 87 | right_assignment ::= 88 | _expression '->' _expression 89 | 90 | brace_list ::= 91 | '{' ( _expression ( '\n' | ';' )? )* '}' 92 | 93 | paren_list ::= 94 | '(' _expression* ')' 95 | 96 | subset ::= 97 | _expression '[' arguments? ']' 98 | 99 | subset2 ::= 100 | _expression '[[' arguments? ']]' 101 | 102 | dollar ::= 103 | _expression '$' ( identifier | string ) 104 | 105 | slot ::= 106 | _expression '@' identifier 107 | 108 | namespace_get ::= 109 | identifier '::' identifier 110 | 111 | namespace_get_internal ::= 112 | identifier ':::' identifier 113 | 114 | help ::= 115 | _expression '?' _expression 116 | 117 | dots ::= 118 | '...' 119 | 120 | placeholder ::= 121 | '_' 122 | 123 | pipe_placeholder_argument ::= 124 | identifier '=' placeholder 125 | 126 | _pipe_rhs_argument ::= 127 | _expression | default_argument | pipe_placeholder_argument 128 | 129 | pipe_rhs_arguments ::= 130 | ( _pipe_rhs_argument | ',' )+ 131 | 132 | pipe_rhs ::= 133 | _expression '(' pipe_rhs_arguments? ')' 134 | 135 | pipe ::= 136 | _expression '|>' pipe_rhs 137 | 138 | unary ::= 139 | ( '-' | '+' ) _expression 140 | | '!' _expression 141 | | '~' _expression 142 | | '?' _expression 143 | 144 | binary ::= 145 | _expression ( '+' | '-' ) _expression 146 | | _expression ( '*' | '/' ) _expression 147 | | _expression '^' _expression 148 | | _expression ( '<' | '>' | '<=' | '>=' | '==' | '!=' ) _expression 149 | | _expression ( '||' | '|' ) _expression 150 | | _expression ( '&&' | '&' ) _expression 151 | | _expression special _expression 152 | | _expression ':' _expression 153 | | _expression '~' _expression 154 | 155 | break ::= 156 | 'break' 157 | 158 | next ::= 159 | 'next' 160 | 161 | true ::= 162 | 'TRUE' 163 | 164 | false ::= 165 | 'FALSE' 166 | 167 | null ::= 168 | 'NULL' 169 | 170 | inf ::= 171 | 'Inf' 172 | 173 | nan ::= 174 | 'NaN' 175 | 176 | na ::= 177 | 'NA' 178 | | 'NA_character_' 179 | | 'NA_complex_' 180 | | 'NA_integer_' 181 | | 'NA_real_' 182 | 183 | _expression ::= 184 | identifier | integer | float | complex | string | call | function_definition | lambda_function | _assignment | brace_list | paren_list | binary | unary | pipe | subset | subset2 | dollar | slot | namespace_get | namespace_get_internal | help | if | for | while | repeat | switch | break | next | true | false | null | inf | nan | na | dots 185 | 186 | identifier ::= 187 | [.\p{XID_Start}][._\p{XID_Continue}]* 188 | | '`' ( [^`\#x0A]+|'\#x0D'?'#x0A' | escape_sequence )* '`' 189 | 190 | integer ::= 191 | ( ( '0x' | '0X' ) [A-Fa-f0-9]+ | [0-9]+ ) 'L' 192 | 193 | float ::= 194 | [0-9]+ '.'? [0-9]+? ( [eE][\+-]? [0-9]+ )? | [0-9]+? '.' [0-9]+ ( [eE][\+-]? [0-9]+ )? | [0-9]+ [eE][\+-]? [0-9]+ | ( '0x' | '0X' ) [A-Fa-f0-9]+ 195 | 196 | complex ::= 197 | float 'i' 198 | 199 | comment ::= 200 | '#' '.'* 201 | 202 | string ::= 203 | _raw_string_literal 204 | | '"' ( [^"\#x0A]+|'\#x0D'?'#x0A' | escape_sequence )* '"' 205 | | "'" ( [^'\#x0A]+|"\#x0D"?"#x0A" | escape_sequence )* "'" 206 | 207 | special ::= 208 | '%' ( [^%\#x0A]+|'\#x0D'?'#x0A' | escape_sequence )* '%' 209 | 210 | escape_sequence ::= 211 | ( '\\' ( [^xu0-7] | [0-7]'{1,3}' | 'x'[0-9a-fA-F]'{2}' | 'u'[0-9a-fA-F]'{4}' | 'u{'[0-9a-fA-F]+'}' ) ) 212 | 213 | -------------------------------------------------------------------------------- /tree-sitter-regex.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-regex/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | pattern ::= 11 | alternation 12 | | term 13 | 14 | alternation ::= 15 | term? ( '|' term? )+ 16 | 17 | term ::= 18 | ( ( start_assertion | end_assertion | boundary_assertion | non_boundary_assertion | lookaround_assertion | pattern_character | character_class | any_character | decimal_escape | character_class_escape | _character_escape | backreference_escape | anonymous_capturing_group | named_capturing_group | non_capturing_group ) ( zero_or_more | one_or_more | optional | count_quantifier )? )+ 19 | 20 | any_character ::= 21 | '.' 22 | 23 | start_assertion ::= 24 | '^' 25 | 26 | end_assertion ::= 27 | '$' 28 | 29 | boundary_assertion ::= 30 | '\b' 31 | 32 | non_boundary_assertion ::= 33 | '\B' 34 | 35 | lookaround_assertion ::= 36 | _lookahead_assertion 37 | | _lookbehind_assertion 38 | 39 | _lookahead_assertion ::= 40 | '(?' ( '=' | '!' ) pattern ')' 41 | 42 | _lookbehind_assertion ::= 43 | '(?<' ( '=' | '!' ) pattern ')' 44 | 45 | pattern_character ::= 46 | [^\^\$\.\*\+\?\(\)#x5B#x5D\|#x0D?#x0A] 47 | 48 | character_class ::= 49 | '[' '^'? ( class_range | _class_atom )* ']' 50 | 51 | class_range ::= 52 | _class_atom '-' _class_atom 53 | 54 | _class_atom ::= 55 | '-' 56 | | class_character 57 | | '\-' 58 | | character_class_escape 59 | | _character_escape 60 | 61 | class_character ::= 62 | [^\#x5D#x2D-] 63 | 64 | anonymous_capturing_group ::= 65 | '(' pattern ')' 66 | 67 | named_capturing_group ::= 68 | '(?<' group_name '>' pattern ')' 69 | 70 | non_capturing_group ::= 71 | '(?:' pattern ')' 72 | 73 | zero_or_more ::= 74 | '*' '?'? 75 | 76 | one_or_more ::= 77 | '+' '?'? 78 | 79 | optional ::= 80 | '?' '?'? 81 | 82 | count_quantifier ::= 83 | '{' decimal_digits ( ',' decimal_digits )? '}' '?'? 84 | 85 | backreference_escape ::= 86 | '\k' group_name 87 | 88 | decimal_escape ::= 89 | '\'[1-9][0-9]* 90 | 91 | character_class_escape ::= 92 | '\'[dDsSwW] 93 | | '\'[pP] '{' unicode_property_value_expression '}' 94 | 95 | unicode_property_value_expression ::= 96 | ( unicode_property '=' )? unicode_property 97 | 98 | unicode_property ::= 99 | [a-zA-Z_0-9]+ 100 | 101 | _character_escape ::= 102 | control_escape 103 | | control_letter_escape 104 | | identity_escape 105 | 106 | control_escape ::= 107 | '\'[bfnrtv0] 108 | 109 | control_letter_escape ::= 110 | '\c'[a-zA-Z] 111 | 112 | identity_escape ::= 113 | ( '\\' [^kdDsSpPwWbfnrtv0-9] ) 114 | 115 | group_name ::= 116 | [A-Za-z0-9]+ 117 | 118 | decimal_digits ::= 119 | [0-9]+ 120 | 121 | -------------------------------------------------------------------------------- /tree-sitter-sexp.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-sexp/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | sexp ::= 11 | _sexp 12 | 13 | _sexp ::= 14 | atom 15 | | list 16 | 17 | atom ::= 18 | [_@a-zA-Z0-9\xC0-\xD6\xD8-\xDE\xDF-\xF6\xF8-\xFF:-]+ 19 | 20 | list ::= 21 | '(' _sexp* ')' 22 | 23 | -------------------------------------------------------------------------------- /tree-sitter-souffle.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-souffle/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | program ::= 11 | ( block_comment | line_comment | pragma | functor_decl | component_decl | component_init | directive | _rule | fact | relation_decl | type_decl | legacy_type_decl | preprocessor )* 12 | 13 | preprocessor ::= 14 | '#line' [0-9]+ string 15 | 16 | block_comment ::= 17 | '/*' [^*]*'\'*+([^/*][^*]*'\'*+)* '/' 18 | 19 | line_comment ::= 20 | '//' [^#x0A]* '\n' 21 | 22 | pragma ::= 23 | '.pragma' string string? 24 | 25 | functor_decl ::= 26 | '.functor' ident '(' ( _type_name | attribute )? ( ',' ( _type_name | attribute ) )* ')' ':' _type_name 'stateful'? 27 | 28 | component_decl ::= 29 | '.comp' component_type ( ':' component_type ( ',' component_type )* )? '{' ( block_comment | line_comment | component_decl | component_init | directive | fact | relation_decl | _rule | type_decl | preprocessor | '.override' ident )* '}' 30 | 31 | component_type ::= 32 | ident ( '<' ident ( ',' ident )* '>' )? 33 | 34 | component_init ::= 35 | '.init' ident '=' component_type 36 | 37 | directive ::= 38 | _directive_qualifier qualified_name ( ',' qualified_name )* ( '(' ( ident '=' _directive_value )? ( ',' ident '=' _directive_value )* ')' )? 39 | 40 | _directive_qualifier ::= 41 | '.input' 42 | | '.limitsize' 43 | | '.output' 44 | | '.printsize' 45 | 46 | _directive_value ::= 47 | string 48 | | ident 49 | | number 50 | 51 | bool ::= 52 | 'true' 53 | | 'false' 54 | 55 | _rule ::= 56 | monotonic_rule 57 | | subsumptive_rule 58 | 59 | monotonic_rule ::= 60 | ( atom ( ',' atom )* ) ':-' disjunction '.' query_plan? 61 | 62 | subsumptive_rule ::= 63 | atom '<=' atom ':-' disjunction '.' query_plan? 64 | 65 | query_plan ::= 66 | '.plan' [0-9]+ ':' '(' [0-9]+? ( ',' [0-9]+ )* ')' ( ',' [0-9]+ ':' '(' [0-9]+? ( ',' [0-9]+ )* ')' )* 67 | 68 | disjunction ::= 69 | conjunction ( ';' conjunction )* 70 | 71 | negation ::= 72 | '!' 73 | 74 | conjunction ::= 75 | negation* ( atom | _constraint | '(' disjunction ')' ) ( ',' negation* ( atom | _constraint | '(' disjunction ')' ) )* 76 | 77 | _constraint ::= 78 | bool 79 | | comparison 80 | | match 81 | | contains 82 | 83 | match ::= 84 | 'match' '(' _argument? ( ',' _argument )* ')' 85 | 86 | contains ::= 87 | 'contains' '(' _argument? ( ',' _argument )* ')' 88 | 89 | comparison ::= 90 | _argument ( '=' | '!=' | '<=' | '>=' | '<' | '>' ) _argument 91 | 92 | fact ::= 93 | atom '.' 94 | 95 | atom ::= 96 | qualified_name '(' _argument? ( ',' _argument )* ')' 97 | 98 | _argument ::= 99 | anonymous 100 | | constant 101 | | variable 102 | | nil 103 | | record_constructor 104 | | adt_constructor 105 | | '(' _argument ')' 106 | | as 107 | | functor_call 108 | | aggregator 109 | | unary_op 110 | | binary_op 111 | 112 | adt_constructor ::= 113 | '$' qualified_name ( '(' _argument? ( ',' _argument )* ')' )? 114 | 115 | record_constructor ::= 116 | '[' _argument? ( ',' _argument )* ']' 117 | 118 | constant ::= 119 | ipv4 120 | | number 121 | | string 122 | 123 | ipv4 ::= 124 | [0-9]'{0,3}.'[0-9]'{0,3}.'[0-9]'{0,3}.'[0-9]'{0,3}' 125 | 126 | string ::= 127 | '"'([^"]|'\"')*'"' 128 | 129 | number ::= 130 | float 131 | | integer 132 | | unsigned 133 | 134 | integer ::= 135 | decimal 136 | | hex 137 | | binary 138 | 139 | decimal ::= 140 | '-'?[0-9]+ 141 | 142 | unsigned ::= 143 | [0-9]+'u' 144 | 145 | hex ::= 146 | '0x'([0-9]|[A-F]|[a-f])+ 147 | 148 | binary ::= 149 | '0b'[0-1]+ 150 | 151 | float ::= 152 | '-'?[0-9]+'.'[0-9]+ 153 | 154 | variable ::= 155 | ident 156 | 157 | nil ::= 158 | 'nil' 159 | 160 | anonymous ::= 161 | '_' 162 | 163 | as ::= 164 | 'as' '(' _argument ',' _type_name ')' 165 | 166 | functor_call ::= 167 | ( user_defined_functor | intrinsic_functor ) '(' _argument? ( ',' _argument )* ')' 168 | 169 | user_defined_functor ::= 170 | '@' ident 171 | 172 | intrinsic_functor ::= 173 | 'acos' | 'acosh' | 'asin' | 'asinh' | 'atan' | 'atanh' | 'cos' | 'cosh' | 'exp' | 'log' | 'sin' | 'sinh' | 'tan' | 'tanh' | 'autoinc' | 'cat' | 'max' | 'min' | 'ord' | 'strlen' | 'substr' | 'to_float' | 'to_number' | 'to_string' | 'to_unsigned' 174 | 175 | aggregator ::= 176 | ( ( ( 'max' | 'mean' | 'min' | 'sum' ) _argument | 'count' ) ':' ( atom | '{' disjunction '}' ) | range ) 177 | 178 | range ::= 179 | 'range' '(' _argument ',' _argument ( ',' _argument )? ')' 180 | 181 | _unary_operator ::= 182 | 'bnot' | 'lnot' | '-' | '~' | '!' 183 | 184 | unary_op ::= 185 | _unary_operator _argument 186 | 187 | binary_op ::= 188 | _argument '+' _argument 189 | | _argument '-' _argument 190 | | _argument '*' _argument 191 | | _argument '/' _argument 192 | | _argument '%' _argument 193 | | _argument '^' _argument 194 | | _argument 'land' _argument 195 | | _argument 'lor' _argument 196 | | _argument 'lxor' _argument 197 | | _argument 'band' _argument 198 | | _argument 'bor' _argument 199 | | _argument 'bxor' _argument 200 | | _argument 'bshl' _argument 201 | | _argument 'bshr' _argument 202 | | _argument 'bshru' _argument 203 | | _argument '&' _argument 204 | | _argument '|' _argument 205 | | _argument '&&' _argument 206 | | _argument '||' _argument 207 | | _argument '**' _argument 208 | | _argument '^^' _argument 209 | | _argument '<<' _argument 210 | | _argument '>>' _argument 211 | | _argument '>>>' _argument 212 | 213 | relation_decl ::= 214 | '.decl' ( ident? ( ',' ident )* ) '(' attribute? ( ',' attribute )* ')' _relation_qualifier* choice_domain? 215 | 216 | _relation_qualifier ::= 217 | 'brie' 218 | | 'btree' 219 | | 'btree_delete' 220 | | 'eqrel' 221 | | 'inline' 222 | | 'magic' 223 | | 'no_inline' 224 | | 'no_magic' 225 | | 'override' 226 | | 'overridable' 227 | | 'input' 228 | | 'output' 229 | | 'printsize' 230 | 231 | choice_domain ::= 232 | 'choice-domain' ( ident | '(' ident ( ',' ident )* ')' ) ( ',' ( ident | '(' ident ( ',' ident )* ')' ) )* 233 | 234 | legacy_type_decl ::= 235 | ( '.number_type' | '.symbol_type' ) _type_name 236 | 237 | type_decl ::= 238 | '.type' ( type_synonym | subtype | type_union | type_record | adt | legacy_bare_type_decl ) 239 | 240 | legacy_bare_type_decl ::= 241 | ident 242 | 243 | subtype ::= 244 | ident '<:' _type_name 245 | 246 | type_synonym ::= 247 | ident '=' _type_name 248 | 249 | type_union ::= 250 | ident '=' ( _type_name ( '|' _type_name )+ ) 251 | 252 | type_record ::= 253 | ident '=' '[' attribute? ( ',' attribute )* ']' 254 | 255 | adt ::= 256 | ident '=' ( _adt_branch ( '|' _adt_branch )* ) 257 | 258 | _adt_branch ::= 259 | ident '{' attribute? ( ',' attribute )* '}' 260 | 261 | _type_name ::= 262 | primitive_type 263 | | qualified_name 264 | 265 | primitive_type ::= 266 | 'number' 267 | | 'symbol' 268 | | 'unsigned' 269 | | 'float' 270 | 271 | attribute ::= 272 | ident ':' _type_name 273 | 274 | qualified_name ::= 275 | ident ( '.' ident )* 276 | 277 | ident ::= 278 | ('_'|'\'?|[A-Z]|[a-z])(([A-Z]|[a-z])|[0-9]|'_'|'\'?)* 279 | 280 | -------------------------------------------------------------------------------- /tree-sitter-svelte.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-svelte/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | document ::= 11 | _node* 12 | 13 | _node ::= 14 | script_element 15 | | style_element 16 | | _statement 17 | 18 | _statement ::= 19 | comment 20 | | _text 21 | | element 22 | | if_statement 23 | | key_statement 24 | | each_statement 25 | | await_statement 26 | 27 | element ::= 28 | start_tag _node* ( end_tag | _implicit_end_tag ) 29 | | self_closing_tag 30 | 31 | start_tag ::= 32 | '<' _start_tag_name attribute* '>' 33 | 34 | self_closing_tag ::= 35 | '<' _start_tag_name attribute* '/>' 36 | 37 | end_tag ::= 38 | '' 39 | 40 | erroneous_end_tag ::= 41 | '' 42 | 43 | script_element ::= 44 | script_start_tag raw_text? end_tag 45 | 46 | script_start_tag ::= 47 | '<' _script_start_tag_name attribute* '>' 48 | 49 | style_element ::= 50 | style_start_tag raw_text? end_tag 51 | 52 | style_start_tag ::= 53 | '<' _style_start_tag_name attribute* '>' 54 | 55 | attribute ::= 56 | attribute_name ( '=' ( attribute_value | quoted_attribute_value | expr_attribute_value ) )? 57 | | expression 58 | 59 | attribute_name ::= 60 | [^<>{}"'/= #x09#x0A#x0B#x0C#x0D]+ 61 | 62 | attribute_value ::= 63 | [^<>{}"'/= #x09#x0A#x0B#x0C#x0D]+ 64 | 65 | expr_attribute_value ::= 66 | expression 67 | 68 | quoted_attribute_value ::= 69 | "'" [^']+? "'" 70 | | '"' [^"]+? '"' 71 | 72 | _text ::= 73 | [^<>{} #x09#x0A#x0B#x0C#x0D]([^<>{}]*[^<>{} #x09#x0A#x0B#x0C#x0D])? 74 | | _expression 75 | 76 | _expression ::= 77 | expression 78 | | html_expr 79 | | const_expr 80 | | '{}' 81 | 82 | expression ::= 83 | '{' raw_text_expr '}' 84 | 85 | html_expr ::= 86 | '{' '@' 'html' raw_text_expr? '}' 87 | 88 | const_expr ::= 89 | '{' '@' 'const' raw_text_expr? '}' 90 | 91 | if_statement ::= 92 | if_start_expr _node* ( else_if_statement | else_statement | if_end_expr ) 93 | 94 | else_if_statement ::= 95 | else_if_expr _node* ( if_end_expr | else_statement | else_if_statement ) 96 | 97 | else_statement ::= 98 | else_expr _node* if_end_expr 99 | 100 | if_start_expr ::= 101 | '{' '#' 'if' raw_text_expr '}' 102 | 103 | else_expr ::= 104 | '{' ':' 'else' '}' 105 | 106 | else_if_expr ::= 107 | '{' ':' 'else' 'if' raw_text_expr? '}' 108 | 109 | if_end_expr ::= 110 | '{' '/' 'if' '}' 111 | 112 | each_statement ::= 113 | each_start_expr _node* ( else_each_statement | each_end_expr ) 114 | 115 | each_start_expr ::= 116 | '{' '#' 'each' ( raw_text_expr | raw_text_each 'as' raw_text_expr ) '}' 117 | 118 | else_each_statement ::= 119 | else_expr _node* each_end_expr 120 | 121 | each_end_expr ::= 122 | '{' '/' 'each' '}' 123 | 124 | await_statement ::= 125 | await_start_expr _node* ( then_statement | catch_statement | await_end_expr ) 126 | 127 | then_statement ::= 128 | then_expr _node* ( await_end_expr | catch_statement ) 129 | 130 | catch_statement ::= 131 | catch_expr _node* await_end_expr 132 | 133 | await_start_expr ::= 134 | '{' '#' 'await' ( raw_text_expr | raw_text_await 'then' raw_text_expr ) '}' 135 | 136 | then_expr ::= 137 | '{' ':' 'then' raw_text_expr? '}' 138 | 139 | catch_expr ::= 140 | '{' ':' 'catch' raw_text_expr? '}' 141 | 142 | await_end_expr ::= 143 | '{' '/' 'await' '}' 144 | 145 | key_statement ::= 146 | key_start_expr _node* key_end_expr 147 | 148 | key_start_expr ::= 149 | '{' '#' 'key' ( raw_text_expr ) '}' 150 | 151 | key_end_expr ::= 152 | '{' '/' 'key' '}' 153 | 154 | -------------------------------------------------------------------------------- /tree-sitter-tablegen.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-tablegen/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | file ::= 11 | statement* 12 | 13 | comment ::= 14 | '\/\/'[^#x0A#x0D]* 15 | 16 | number ::= 17 | [+-]?[0-9]+|'0x'[0-9a-fA-F]+|'0b'[01]+ 18 | 19 | identifier ::= 20 | [a-zA-Z_0-9]*[a-zA-Z_][a-zA-Z_0-9]* 21 | 22 | string_string ::= 23 | '"'('\\'|"\'"|"\""|"\t"|"\n"|[^\"])*""" 24 | 25 | code_string ::= 26 | '#x5B\{'([^}]|'\}'+[^}#x5D])*'\}#x5D' 27 | 28 | string ::= 29 | string_string 30 | | code_string 31 | 32 | var ::= 33 | '\$'[a-zA-Z_][a-zA-Z_0-9]* 34 | 35 | include ::= 36 | 'include' string_string 37 | 38 | preprocessor ::= 39 | ( ( '#define' | '#ifdef' | '#ifndef' ) [ #x09#x0A#x0B#x0C#x0D]+ [a-zA-Z_][a-zA-Z_0-9]* | '#else' | '#endif' ) 40 | 41 | statement ::= 42 | assert 43 | | class 44 | | def 45 | | defm 46 | | defset 47 | | defvar 48 | | foreach 49 | | if 50 | | let 51 | | multiclass 52 | | include 53 | 54 | statement_or_block ::= 55 | statement 56 | | '{' statement* '}' 57 | 58 | class ::= 59 | 'class' identifier template_args? parent_class_list? record_body 60 | 61 | parent_class_list ::= 62 | ':' identifier ( '<' ( value ( ',' value )* )? '>' )? ( ',' identifier ( '<' ( value ( ',' value )* )? '>' )? )* 63 | 64 | template_args ::= 65 | '<' ( template_arg ( ',' template_arg )* )? '>' 66 | 67 | template_arg ::= 68 | type identifier ( '=' value )? 69 | 70 | record_body ::= 71 | ';' 72 | | '{' body_item* '}' 73 | 74 | body_item ::= 75 | instruction 76 | | let_inst 77 | | def_var 78 | | assert 79 | 80 | instruction ::= 81 | 'field'? ( type | 'code' ) identifier ( '=' value )? ';' 82 | 83 | let_inst ::= 84 | 'let' identifier ( '{' ( value ( ',' value )* )? '}' )? '=' value ';' 85 | 86 | def_var ::= 87 | 'defvar' identifier '=' value ';' 88 | 89 | def ::= 90 | 'def' value? parent_class_list? record_body 91 | 92 | let ::= 93 | 'let' let_item ( ',' let_item )* 'in' ( statement | '{' statement* '}' ) 94 | 95 | let_item ::= 96 | identifier ( '<' ( value ( ',' value )* )? '>' )? '=' value 97 | 98 | multiclass ::= 99 | 'multiclass' identifier template_args? parent_class_list? multiclass_body 100 | 101 | multiclass_body ::= 102 | ';' 103 | | '{' multiclass_statement* '}' 104 | 105 | multiclass_statement ::= 106 | assert 107 | | def 108 | | defm 109 | | defvar 110 | | foreach 111 | | if 112 | | let 113 | 114 | defm ::= 115 | 'defm' value? parent_class_list ';' 116 | 117 | defset ::= 118 | 'defset' type identifier '=' '{' statement* '}' 119 | 120 | defvar ::= 121 | 'defvar' identifier '=' value ';' 122 | 123 | foreach ::= 124 | 'foreach' identifier '=' value 'in' statement_or_block 125 | 126 | if ::= 127 | 'if' value 'then' statement_or_block ( 'else' statement_or_block )? 128 | 129 | assert ::= 130 | 'assert' value ',' value ';' 131 | 132 | type ::= 133 | 'bit' 134 | | 'int' 135 | | 'string' 136 | | 'dag' 137 | | 'bits' '<' number '>' 138 | | 'list' '<' type '>' 139 | | identifier 140 | 141 | value ::= 142 | _simple_value value_suffix* 143 | | _value_concat 144 | 145 | _value_concat ::= 146 | value '#' value?+ 147 | 148 | _simple_value ::= 149 | number 150 | | identifier 151 | | string_string 152 | | _repeated_string 153 | | code_string 154 | | 'true' 155 | | 'false' 156 | | '?' 157 | | '{' ( value ( ',' value )* )? ','? '}' 158 | | '[' ( value ( ',' value )* )? ','? ']' ( '<' type '>' )? 159 | | '(' dag_arg ( dag_arg ( ',' dag_arg )* )? ')' 160 | | identifier '<' ( value ( ',' value )* )? '>' 161 | | operator 162 | 163 | _repeated_string ::= 164 | string_string+ 165 | 166 | operator ::= 167 | operator_keyword ( '<' type '>' )? '(' ( value ( ',' value )* )? ','? ')' 168 | | '!cond' '(' ( ( value ':' value ) ( ',' ( value ':' value ) )* )? ','? ')' 169 | 170 | dag_arg ::= 171 | value ( ':' var )? 172 | | var 173 | 174 | value_suffix ::= 175 | '{' ( value ( ',' value )* )? '}' | '[' ( value ( ',' value )* )? ']' | '.' identifier | ( '...' | '-' ) value 176 | 177 | operator_keyword ::= 178 | '!' ( 'add' | 'and' | 'cast' | 'con' | 'dag' | 'empty' | 'eq' | 'filter' | 'find' | 'foldl' | 'foreach' | 'ge' | 'getdagop' | 'gt' | 'head' | 'if' | 'interleave' | 'isa' | 'le' | 'listconcat' | 'listsplat' | 'lt' | 'mul' | 'ne' | 'not' | 'or' | 'setdagop' | 'shl' | 'size' | 'sra' | 'srl' | 'strconcat' | 'sub' | 'subst' | 'substr' | 'tail' | 'xor' ) 179 | 180 | -------------------------------------------------------------------------------- /tree-sitter-teal.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-teal/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | program ::= 11 | '#!'[^#x0A#x0D]*? _statement* 12 | 13 | _statement ::= 14 | ( var_declaration | var_assignment | type_declaration | record_declaration | enum_declaration | return_statement | break | _for_statement | do_statement | while_statement | repeat_statement | function_call | function_statement | if_statement | '::' identifier '::' | goto ) ';'? 15 | 16 | return_statement ::= 17 | 'return' ( _expression ( ',' _expression )* | '(' _expression ( ',' _expression )* ')' )? 18 | 19 | break ::= 20 | 'break' 21 | 22 | if_statement ::= 23 | 'if' _expression 'then' _statement* elseif_block* else_block? 'end' 24 | 25 | elseif_block ::= 26 | 'elseif' _expression 'then' _statement* 27 | 28 | else_block ::= 29 | 'else' _statement* 30 | 31 | numeric_for_statement ::= 32 | 'for' identifier '=' _expression ',' _expression ( ',' _expression )? do_statement 33 | 34 | generic_for_statement ::= 35 | 'for' ( identifier ( ',' identifier )* ) 'in' ( _expression ( ',' _expression )* ) do_statement 36 | 37 | _for_statement ::= 38 | numeric_for_statement 39 | | generic_for_statement 40 | 41 | while_statement ::= 42 | 'while' _expression do_statement 43 | 44 | repeat_statement ::= 45 | 'repeat' _statement* 'until' _expression 46 | 47 | do_statement ::= 48 | 'do' _statement* 'end' 49 | 50 | _expression ::= 51 | identifier 52 | | _var 53 | | number 54 | | string 55 | | boolean 56 | | nil 57 | | table_constructor 58 | | anon_function 59 | | function_call 60 | | _prefix_expression 61 | | bin_op 62 | | unary_op 63 | | varargs 64 | | type_cast 65 | 66 | unary_op ::= 67 | ( 'not' | '#' | '-' | '~' ) _expression 68 | 69 | bin_op ::= 70 | _expression 'or' _expression 71 | | _expression 'and' _expression 72 | | _expression '<' _expression 73 | | _expression '<=' _expression 74 | | _expression '==' _expression 75 | | _expression '~=' _expression 76 | | _expression '>=' _expression 77 | | _expression '>' _expression 78 | | _expression '|' _expression 79 | | _expression '~' _expression 80 | | _expression '&' _expression 81 | | _expression '<<' _expression 82 | | _expression '>>' _expression 83 | | _expression '+' _expression 84 | | _expression '-' _expression 85 | | _expression '*' _expression 86 | | _expression '/' _expression 87 | | _expression '//' _expression 88 | | _expression '%' _expression 89 | | _expression '..' _expression 90 | | _expression '^' _expression 91 | | _expression 'is' _type 92 | 93 | type_cast ::= 94 | _expression 'as' ( _type | type_tuple ) 95 | 96 | type_tuple ::= 97 | '(' _type ( ',' _type )* ')' 98 | 99 | type_union ::= 100 | _type '|' _type 101 | 102 | var_declarator ::= 103 | identifier ( '<' identifier '>' )? 104 | 105 | var_declarators ::= 106 | var_declarator ( ',' var_declarator )* 107 | 108 | expressions ::= 109 | _expression ( ',' _expression )* 110 | 111 | var_declaration ::= 112 | scope var_declarators type_annotation? ( '=' expressions )? 113 | 114 | _type_def ::= 115 | 'type' identifier '=' ( _type | _newtype ) 116 | 117 | type_declaration ::= 118 | scope _type_def 119 | | record_declaration 120 | | enum_declaration 121 | 122 | assignment_variables ::= 123 | _var ( ',' _var )* 124 | 125 | var_assignment ::= 126 | assignment_variables '=' expressions 127 | 128 | _prefix_expression ::= 129 | _var | function_call | '(' _expression ')' 130 | 131 | method_index ::= 132 | _prefix_expression ':' identifier 133 | 134 | arguments ::= 135 | '(' ( _expression ( ',' _expression )* )? ')' 136 | | string 137 | | table_constructor 138 | 139 | function_call ::= 140 | ( _prefix_expression | method_index ) arguments 141 | 142 | table_entry ::= 143 | '[' _expression ']' '=' _expression 144 | | identifier ( ':' _type )? '=' _expression 145 | | _expression 146 | 147 | table_constructor ::= 148 | '{' ( table_entry ( ( ',' | ';' ) table_entry )* )? ( ',' | ';' )? '}' 149 | 150 | function_name ::= 151 | identifier ( ( '.' identifier )* ':' identifier | ( '.' identifier )+ ) 152 | 153 | scope ::= 154 | ( 'local' | 'global' ) 155 | 156 | function_statement ::= 157 | scope 'function' identifier function_signature function_body 158 | | 'function' function_name function_signature function_body 159 | 160 | variadic_type ::= 161 | _type '...' 162 | 163 | _type_list_maybe_vararg ::= 164 | _type ( ',' _type )* ( ',' variadic_type )? 165 | 166 | return_type ::= 167 | variadic_type 168 | | _type_list_maybe_vararg 169 | | '(' _type_list_maybe_vararg ')' 170 | 171 | _partypelist ::= 172 | _partype ( ',' _partype )* 173 | 174 | _partype ::= 175 | ( identifier ':' )? _type 176 | 177 | _parnamelist ::= 178 | _parname ( ',' _parname )* 179 | 180 | _parname ::= 181 | identifier ( ':' _type )? 182 | 183 | typeargs ::= 184 | '<' identifier ( ',' identifier )* '>' 185 | 186 | anon_function ::= 187 | 'function' function_signature function_body 188 | 189 | _annotated_var_arg ::= 190 | '...' ':' _type 191 | 192 | signature_arguments ::= 193 | '(' ( _parnamelist | _parnamelist ',' _annotated_var_arg | _annotated_var_arg )? ')' 194 | 195 | function_signature ::= 196 | typeargs? signature_arguments ( ':' return_type )? 197 | 198 | function_body ::= 199 | _statement* 'end' 200 | 201 | record_field ::= 202 | identifier ':' _type 203 | | '[' string ']' ':' _type 204 | | 'type' ':' _type 205 | | 'record' ':' _type 206 | | 'enum' ':' _type 207 | | 'userdata' ':' _type 208 | | 'metamethod' ':' _type 209 | 210 | _record_entry ::= 211 | record_field 212 | | _type_def 213 | | _record_def 214 | | _enum_def 215 | 216 | metamethod_annotation ::= 217 | 'metamethod' identifier ':' _type 218 | 219 | record_body ::= 220 | ( '{' _type '}' )? ( _record_entry | 'userdata' | metamethod_annotation )* 'end' 221 | 222 | _record_def ::= 223 | 'record' identifier typeargs? record_body 224 | 225 | record_declaration ::= 226 | scope _record_def 227 | 228 | enum_body ::= 229 | string* 'end' 230 | 231 | _enum_def ::= 232 | 'enum' identifier enum_body 233 | 234 | enum_declaration ::= 235 | scope _enum_def 236 | 237 | anon_record ::= 238 | 'record' typeargs? record_body 239 | 240 | _anon_enum ::= 241 | 'enum' enum_body 242 | 243 | _newtype ::= 244 | _anon_enum 245 | | anon_record 246 | 247 | type_annotation ::= 248 | ':' _type ( ',' _type )* 249 | 250 | _type ::= 251 | simple_type | type_index | table_type | function_type | type_union | '(' _type ')' 252 | 253 | typearg_params ::= 254 | '<' _type ( ',' _type )* '>' 255 | 256 | type_index ::= 257 | ( identifier | type_index ) '.' identifier typearg_params? 258 | 259 | simple_type ::= 260 | identifier typearg_params? 261 | 262 | table_type ::= 263 | '{' ( _type | _type ':' _type | _type ( ',' _type )+ ) '}' 264 | 265 | function_type_args ::= 266 | '(' ( _partypelist ( ',' _annotated_var_arg )? | _annotated_var_arg )? ')' 267 | 268 | function_type ::= 269 | 'function' typeargs? ( function_type_args ( ':' return_type )? )? 270 | 271 | goto ::= 272 | 'goto' identifier 273 | 274 | index ::= 275 | _prefix_expression ( ( '.' identifier ) | ( '[' _expression ']' ) ) 276 | 277 | _var ::= 278 | identifier | index 279 | 280 | varargs ::= 281 | '...' 282 | 283 | identifier ::= 284 | [a-zA-Z_][a-zA-Z_0-9]* 285 | 286 | number ::= 287 | [0-9]+('.'[0-9]+)?('e'[0-9]+)? 288 | | '.'[0-9]+('e'[0-9]+)? 289 | | '0x'[0-9a-fA-F]+('.'[0-9a-fA-F]+)?('p'[0-9]+)? 290 | 291 | boolean ::= 292 | 'true' 293 | | 'false' 294 | 295 | _short_string_content ::= 296 | ( format_specifier | escape_sequence | '%' | _short_string_char )+ 297 | 298 | _long_string_content ::= 299 | ( format_specifier | _long_string_char | '%' )+ 300 | 301 | string ::= 302 | _short_string_start _short_string_content? _short_string_end | _long_string_start _long_string_content? _long_string_end 303 | 304 | format_specifier ::= 305 | '%' ( '%' | ( '+' | '-' )? ' '? '#'? [0-9]+? '.'? [0-9]+? [AaEefGgcdiouXxpqs] ) 306 | 307 | escape_sequence ::= 308 | '\\' ( [abfnrtvz"'\] | 'x' [0-9a-fA-F]'{2}' | 'd' [0-7]'{3}' | 'u{' [0-9a-fA-F]'{1,8}' '}' ) 309 | 310 | nil ::= 311 | 'nil' 312 | 313 | -------------------------------------------------------------------------------- /tree-sitter-toml.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-toml/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | document ::= 11 | ( pair | '#x0D'?'#x0A' )* ( table | table_array_element )* 12 | 13 | comment ::= 14 | '#' [^\u0000-\u0008\u000a-\u001f\u007f]* 15 | 16 | table ::= 17 | '[' ( dotted_key | _key ) ']' _line_ending_or_eof ( pair | '#x0D'?'#x0A' )* 18 | 19 | table_array_element ::= 20 | '[[' ( dotted_key | _key ) ']]' _line_ending_or_eof ( pair | '#x0D'?'#x0A' )* 21 | 22 | pair ::= 23 | _inline_pair _line_ending_or_eof 24 | 25 | _inline_pair ::= 26 | ( dotted_key | _key ) '=' _inline_value 27 | 28 | _key ::= 29 | bare_key 30 | | quoted_key 31 | 32 | dotted_key ::= 33 | ( dotted_key | _key ) '.' _key 34 | 35 | bare_key ::= 36 | [A-Za-z0-9_-]+ 37 | 38 | quoted_key ::= 39 | _basic_string 40 | | _literal_string 41 | 42 | _inline_value ::= 43 | string 44 | | integer 45 | | float 46 | | boolean 47 | | offset_date_time 48 | | local_date_time 49 | | local_date 50 | | local_time 51 | | array 52 | | inline_table 53 | 54 | string ::= 55 | _basic_string 56 | | _multiline_basic_string 57 | | _literal_string 58 | | _multiline_literal_string 59 | 60 | _basic_string ::= 61 | '"' ( [^\u0000-\u0008\u000a-\u001f\u0022\u005c\u007f]+ | escape_sequence )* '"' 62 | 63 | _multiline_basic_string ::= 64 | '"""' ( [^\u0000-\u0008\u000a-\u001f\u0022\u005c\u007f]+ | _multiline_basic_string_content | '#x0D'?'#x0A' | escape_sequence | _escape_line_ending )* _multiline_basic_string_end 65 | 66 | escape_sequence ::= 67 | '\'([btnfr"\]|'u'[0-9a-fA-F]'{4}'|'U'[0-9a-fA-F]'{8}') 68 | 69 | _escape_line_ending ::= 70 | ( '\' '#x0D'?'#x0A' ) 71 | 72 | _literal_string ::= 73 | "'" [^\u0000-\u0008\u000a-\u001f\u0027\u007f]+? "'" 74 | 75 | _multiline_literal_string ::= 76 | "'''" ( [^\u0000-\u0008\u000a-\u001f\u0027\u007f]+ | _multiline_literal_string_content | '#x0D'?'#x0A' )* _multiline_literal_string_end 77 | 78 | integer ::= 79 | [+-]?('0'|[1-9]('_'?[0-9])*) 80 | | '0x'[0-9a-fA-F]('_'?[0-9a-fA-F])* 81 | | '0o'[0-7]('_'?[0-7])* 82 | | '0b'[01]('_'?[01])* 83 | 84 | float ::= 85 | ( [+-]?('0'|[1-9]('_'?[0-9])*) ( [.][0-9]('_'?[0-9])* | [.][0-9]('_'?[0-9])*? [eE] [+-]?[0-9]('_'?[0-9])* ) ) 86 | | [+-]?('inf'|'nan') 87 | 88 | boolean ::= 89 | 'true'|'false' 90 | 91 | offset_date_time ::= 92 | ( ([0-9]+)'-'('0'[1-9]|'1'[012])'-'('0'[1-9]|[12][0-9]|'3'[01]) [ tT] ([01][0-9]|'2'[0-3])':'([0-5][0-9])':'([0-5][0-9]|'60')([.][0-9]+)? ([zZ])|([+-]([01][0-9]|'2'[0-3])':'[0-5][0-9]) ) 93 | 94 | local_date_time ::= 95 | ( ([0-9]+)'-'('0'[1-9]|'1'[012])'-'('0'[1-9]|[12][0-9]|'3'[01]) [ tT] ([01][0-9]|'2'[0-3])':'([0-5][0-9])':'([0-5][0-9]|'60')([.][0-9]+)? ) 96 | 97 | local_date ::= 98 | ([0-9]+)'-'('0'[1-9]|'1'[012])'-'('0'[1-9]|[12][0-9]|'3'[01]) 99 | 100 | local_time ::= 101 | ([01][0-9]|'2'[0-3])':'([0-5][0-9])':'([0-5][0-9]|'60')([.][0-9]+)? 102 | 103 | array ::= 104 | '[' '#x0D'?'#x0A'* ( _inline_value '#x0D'?'#x0A'* ( ',' '#x0D'?'#x0A'* _inline_value '#x0D'?'#x0A'* )* ( ',' '#x0D'?'#x0A'* )? )? ']' 105 | 106 | inline_table ::= 107 | '{' ( _inline_pair ( ',' _inline_pair )* )? '}' 108 | 109 | -------------------------------------------------------------------------------- /tree-sitter-turtle.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-turtle/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | turtle_doc ::= 11 | statement* 12 | 13 | comment ::= 14 | '#.'* 15 | 16 | statement ::= 17 | directive 18 | | triples '.' 19 | 20 | directive ::= 21 | prefix_id 22 | | base 23 | | sparql_prefix 24 | | sparql_base 25 | 26 | prefix_id ::= 27 | '@prefix' namespace iri_reference '.' 28 | 29 | base ::= 30 | '@base' iri_reference '.' 31 | 32 | sparql_base ::= 33 | [Bb][Aa][Ss][Ee] iri_reference 34 | 35 | sparql_prefix ::= 36 | [Pp][Rr][Ee][Ff][Ii][Xx] namespace iri_reference 37 | 38 | triples ::= 39 | subject property_list 40 | | blank_node_property_list property_list? 41 | 42 | property_list ::= 43 | property ( ';' property? )* 44 | 45 | property ::= 46 | predicate object_list 47 | 48 | object_list ::= 49 | _object ( ',' _object )* 50 | 51 | predicate ::= 52 | _iri 53 | | 'a' 54 | 55 | subject ::= 56 | _iri 57 | | _blank_node 58 | | collection 59 | 60 | _object ::= 61 | _iri 62 | | _blank_node 63 | | collection 64 | | blank_node_property_list 65 | | _literal 66 | 67 | _literal ::= 68 | rdf_literal 69 | | _numeric_literal 70 | | boolean_literal 71 | 72 | blank_node_property_list ::= 73 | '[' property_list ']' 74 | 75 | collection ::= 76 | '(' object_collection? ')' 77 | 78 | object_collection ::= 79 | _object+ 80 | 81 | _numeric_literal ::= 82 | integer 83 | | decimal 84 | | double 85 | 86 | string ::= 87 | _string_literal_quote 88 | | _string_literal_single_quote 89 | | _string_literal_long_quote 90 | | _string_literal_long_single_quote 91 | 92 | iri_reference ::= 93 | '<' ( ([^<>"{}|^`\\x00-\x20]) | ('\u'[0-9A-Fa-f]'{4}'|'\U'[0-9A-Fa-f]'{8}') )* '>' 94 | 95 | integer ::= 96 | [+-]?[0-9]+ 97 | 98 | decimal ::= 99 | ( [+-]? [0-9]* '.' [0-9]+ ) 100 | 101 | double ::= 102 | ( [+-]? ( [0-9]+ '.' [0-9]* [eE] [+-]? [0-9]+ | '.' [0-9]+ [eE] [+-]? [0-9]+ | [0-9]+ [eE] [+-]? [0-9]+ ) ) 103 | 104 | _string_literal_quote ::= 105 | '"' ( [^\x22\x5C\x0A\x0D] | echar | ('\u'[0-9A-Fa-f]'{4}'|'\U'[0-9A-Fa-f]'{8}') )* '"' 106 | 107 | _string_literal_single_quote ::= 108 | "'" ( [^\x27\x5C\x0A\x0D] | echar | ('\u'[0-9A-Fa-f]'{4}'|'\U'[0-9A-Fa-f]'{8}') )* "'" 109 | 110 | _string_literal_long_single_quote ::= 111 | "'''" ( ( "'" | "''" )? ( [^'\] | echar | ('\u'[0-9A-Fa-f]'{4}'|'\U'[0-9A-Fa-f]'{8}') ) )* "'''" 112 | 113 | _string_literal_long_quote ::= 114 | '"""' ( ( '"' | '""' )? ( [^"\] | echar | ('\u'[0-9A-Fa-f]'{4}'|'\U'[0-9A-Fa-f]'{8}') ) )* '"""' 115 | 116 | rdf_literal ::= 117 | string ( lang_tag | ( '^^' _iri ) )? 118 | 119 | boolean_literal ::= 120 | 'true' 121 | | 'false' 122 | 123 | _iri ::= 124 | iri_reference 125 | | prefixed_name 126 | 127 | prefixed_name ::= 128 | namespace pn_local? 129 | 130 | _blank_node ::= 131 | blank_node_label 132 | | anon 133 | 134 | namespace ::= 135 | pn_prefix? ':' 136 | 137 | blank_node_label ::= 138 | '_:' ( ( [A-Z] | [a-z] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u02FF] | [\u0370-\u037D] | [\u037F-\u1FFF] | [\u200C-\u200D] | [\u2070-\u218F] | [\u2C00-\u2FEF] | [\u3001-\uD7FF] | [\uF900-\uFDCF] | [\uFDF0-\uFFFD] | [\u{10000}-\u{EFFFF}] | '_' | [0-9] ) ( ( [A-Z] | [a-z] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u02FF] | [\u0370-\u037D] | [\u037F-\u1FFF] | [\u200C-\u200D] | [\u2070-\u218F] | [\u2C00-\u2FEF] | [\u3001-\uD7FF] | [\uF900-\uFDCF] | [\uFDF0-\uFFFD] | [\u{10000}-\u{EFFFF}] | '_' | '-' | [0-9] | [\u00B7] | [\u0300-\u036F] | [\u203F-\u2040] | '.' )* ( [A-Z] | [a-z] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u02FF] | [\u0370-\u037D] | [\u037F-\u1FFF] | [\u200C-\u200D] | [\u2070-\u218F] | [\u2C00-\u2FEF] | [\u3001-\uD7FF] | [\uF900-\uFDCF] | [\uFDF0-\uFFFD] | [\u{10000}-\u{EFFFF}] | '_' | '-' | [0-9] | [\u00B7] | [\u0300-\u036F] | [\u203F-\u2040] ) )? ) 139 | 140 | lang_tag ::= 141 | ( '@' [a-zA-Z]+ ( '-' [a-zA-Z0-9]+ )* ) 142 | 143 | echar ::= 144 | '\'[tbnrf\"'] 145 | 146 | anon ::= 147 | ( '[' ( '\x20' | '\x09' | '\x0D' | '\x0A' )* ']' ) 148 | 149 | pn_prefix ::= 150 | ( ( [A-Z] | [a-z] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u02FF] | [\u0370-\u037D] | [\u037F-\u1FFF] | [\u200C-\u200D] | [\u2070-\u218F] | [\u2C00-\u2FEF] | [\u3001-\uD7FF] | [\uF900-\uFDCF] | [\uFDF0-\uFFFD] | [\u{10000}-\u{EFFFF}] ) ( ( [A-Z] | [a-z] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u02FF] | [\u0370-\u037D] | [\u037F-\u1FFF] | [\u200C-\u200D] | [\u2070-\u218F] | [\u2C00-\u2FEF] | [\u3001-\uD7FF] | [\uF900-\uFDCF] | [\uFDF0-\uFFFD] | [\u{10000}-\u{EFFFF}] | '_' | '-' | [0-9] | [\u00B7] | [\u0300-\u036F] | [\u203F-\u2040] | '.' )* ( [A-Z] | [a-z] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u02FF] | [\u0370-\u037D] | [\u037F-\u1FFF] | [\u200C-\u200D] | [\u2070-\u218F] | [\u2C00-\u2FEF] | [\u3001-\uD7FF] | [\uF900-\uFDCF] | [\uFDF0-\uFFFD] | [\u{10000}-\u{EFFFF}] | '_' | '-' | [0-9] | [\u00B7] | [\u0300-\u036F] | [\u203F-\u2040] ) )? ) 151 | 152 | pn_local ::= 153 | ( ( [A-Z] | [a-z] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u02FF] | [\u0370-\u037D] | [\u037F-\u1FFF] | [\u200C-\u200D] | [\u2070-\u218F] | [\u2C00-\u2FEF] | [\u3001-\uD7FF] | [\uF900-\uFDCF] | [\uFDF0-\uFFFD] | [\u{10000}-\u{EFFFF}] | '_' | ':' | [0-9] | '%' ( [0-9] | [A-F] | [a-f] ) ( [0-9] | [A-F] | [a-f] ) | '\_' | '\~' | '\.' | '\-' | '\!' | '\$' | '\&' | "\'" | '\(' | '\)' | '\*' | '\+' | '\,' | '\;' | '\=' | '\/' | '\?' | '\#' | '\@' | '\%' ) ( ( [A-Z] | [a-z] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u02FF] | [\u0370-\u037D] | [\u037F-\u1FFF] | [\u200C-\u200D] | [\u2070-\u218F] | [\u2C00-\u2FEF] | [\u3001-\uD7FF] | [\uF900-\uFDCF] | [\uFDF0-\uFFFD] | [\u{10000}-\u{EFFFF}] | '_' | '-' | [0-9] | [\u00B7] | [\u0300-\u036F] | [\u203F-\u2040] | '.' | ':' | '%' ( [0-9] | [A-F] | [a-f] ) ( [0-9] | [A-F] | [a-f] ) | '\_' | '\~' | '\.' | '\-' | '\!' | '\$' | '\&' | "\'" | '\(' | '\)' | '\*' | '\+' | '\,' | '\;' | '\=' | '\/' | '\?' | '\#' | '\@' | '\%' )* ( [A-Z] | [a-z] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u02FF] | [\u0370-\u037D] | [\u037F-\u1FFF] | [\u200C-\u200D] | [\u2070-\u218F] | [\u2C00-\u2FEF] | [\u3001-\uD7FF] | [\uF900-\uFDCF] | [\uFDF0-\uFFFD] | [\u{10000}-\u{EFFFF}] | '_' | '-' | [0-9] | [\u00B7] | [\u0300-\u036F] | [\u203F-\u2040] | ':' | '%' ( [0-9] | [A-F] | [a-f] ) ( [0-9] | [A-F] | [a-f] ) | '\_' | '\~' | '\.' | '\-' | '\!' | '\$' | '\&' | "\'" | '\(' | '\)' | '\*' | '\+' | '\,' | '\;' | '\=' | '\/' | '\?' | '\#' | '\@' | '\%' ) )? ) 154 | 155 | -------------------------------------------------------------------------------- /tree-sitter-vue.ebnf: -------------------------------------------------------------------------------- 1 | // 2 | // From tree-sitter-vue/src/grammar.json 3 | // 4 | // 5 | // EBNF to generate railroad diagram at 6 | // (IPV6) https://www.bottlecaps.de/rr/ui 7 | // (IPV4) https://rr.red-dove.com/ui 8 | // 9 | 10 | component ::= 11 | ( comment | element | template_element | script_element | style_element )* 12 | 13 | _node ::= 14 | comment 15 | | text 16 | | interpolation 17 | | element 18 | | template_element 19 | | script_element 20 | | style_element 21 | | erroneous_end_tag 22 | 23 | element ::= 24 | start_tag _node* ( end_tag | _implicit_end_tag ) 25 | | self_closing_tag 26 | 27 | template_element ::= 28 | template_start_tag _node* end_tag 29 | 30 | script_element ::= 31 | script_start_tag raw_text? end_tag 32 | 33 | style_element ::= 34 | style_start_tag raw_text? end_tag 35 | 36 | start_tag ::= 37 | '<' _start_tag_name ( attribute | directive_attribute )* '>' 38 | 39 | template_start_tag ::= 40 | '<' _template_start_tag_name ( attribute | directive_attribute )* '>' 41 | 42 | script_start_tag ::= 43 | '<' _script_start_tag_name ( attribute | directive_attribute )* '>' 44 | 45 | style_start_tag ::= 46 | '<' _style_start_tag_name ( attribute | directive_attribute )* '>' 47 | 48 | self_closing_tag ::= 49 | '<' _start_tag_name ( attribute | directive_attribute )* '/>' 50 | 51 | end_tag ::= 52 | '' 53 | 54 | erroneous_end_tag ::= 55 | '' 56 | 57 | attribute ::= 58 | attribute_name ( '=' ( attribute_value | quoted_attribute_value ) )? 59 | 60 | attribute_name ::= 61 | [^<>"'=/ #x09#x0A#x0B#x0C#x0D]+ 62 | 63 | attribute_value ::= 64 | [^<>"'= #x09#x0A#x0B#x0C#x0D]+ 65 | 66 | quoted_attribute_value ::= 67 | "'" [^']+? "'" 68 | | '"' [^"]+? '"' 69 | 70 | text ::= 71 | _text_fragment 72 | | '{{' 73 | 74 | interpolation ::= 75 | '{{' _interpolation_text? '}}' 76 | 77 | directive_attribute ::= 78 | ( directive_name ( ':' ( directive_argument | directive_dynamic_argument ) )? | directive_shorthand ( directive_argument | directive_dynamic_argument ) ) directive_modifiers? ( '=' ( attribute_value | quoted_attribute_value ) )? 79 | 80 | directive_name ::= 81 | 'v-'[^<>'"=/ #x09#x0A#x0B#x0C#x0D:.]+ 82 | 83 | directive_shorthand ::= 84 | ':' | '@' | '#' 85 | 86 | directive_argument ::= 87 | [^<>"'/= #x09#x0A#x0B#x0C#x0D.]+ 88 | 89 | directive_dynamic_argument ::= 90 | '[' directive_dynamic_argument_value? ']' 91 | 92 | directive_dynamic_argument_value ::= 93 | [^<>"'/= #x09#x0A#x0B#x0C#x0D#x5D]+ 94 | 95 | directive_modifiers ::= 96 | ( '.' directive_modifier )+ 97 | 98 | directive_modifier ::= 99 | [^<>"'/= #x09#x0A#x0B#x0C#x0D.]+ 100 | 101 | -------------------------------------------------------------------------------- /typescript.ebnf: -------------------------------------------------------------------------------- 1 | //From https://github.com/frenchy64/typescript-parser/blob/master/typescript.ebnf 2 | /*The syntax of this file should be mostly self explanatory if you understand EBNF 3 | and regular expressions, The one unique feature is that a literal or a rule 4 | can be excluded from the resulting parse tree by surronding it with angle brackets*/ 5 | DeclarationSourceFile ::= ws-opt DeclarationElement* 6 | TypeParameters ::= '' TypeParameter (',' TypeParameter)* '' 7 | TypeParameter ::= ws-opt Identifier (ws Constraint)? ws-opt 8 | Identifier ::= [a-zA-Z_][a-zA-Z0-9_]* //"[$_\p{L}][$_\p{L}\p{N}]*" 9 | Constraint ::= 'extends' ws Type 10 | Type ::= TypeLiteral 11 | | TypeReference 12 | | TypeQuery 13 | /*| PredefinedType*/ 14 | 15 | /*PredefinedType ::= "any" 16 | | "number" 17 | | "boolean" 18 | | "string" 19 | | "void"*/ 20 | TypeReference ::= QualifiedIdentifier (ws-opt TypeArguments)? 21 | QualifiedIdentifier ::= Identifier 22 | | ModuleName '.' Identifier 23 | /*This isn't really necessary, but it's useful to seperate the module name*/ 24 | ModuleName ::= Identifier ('.' Identifier)* 25 | TypeArguments ::= '' TypeArgumentList '' 26 | TypeArgumentList ::= TypeArgument (',' TypeArgument)* 27 | TypeArgument ::= ws-opt Type ws-opt 28 | TypeQuery ::= "typeof" ws QualifiedIdentifier 29 | TypeLiteral ::= ObjectType 30 | | ArrayType 31 | | FunctionType 32 | | ConstructorType 33 | ArrayType ::= ElementType lbrace rbrace 34 | ElementType ::= TypeQuery 35 | | TypeReference 36 | /* some ambiguity with predefined types and type references */ 37 | /*| PredefinedType*/ 38 | | ObjectType 39 | | ArrayType 40 | FunctionType ::= 41 | TypeParameters? lparen Parameter-List? rparen "=>" ws-opt Type 42 | ConstructorType ::= "new" ws FunctionType 43 | ObjectType ::= '{' ws-opt (TypeBody ws-opt)? '}' 44 | TypeBody ::= TypeMemberList ws-opt ';'? 45 | TypeMemberList ::= TypeMember ws-opt (';' ws-opt TypeMember)* 46 | TypeMember ::= PropertySignature 47 | | CallSignature 48 | | ConstructSignature 49 | | IndexSignature 50 | | MethodSignature 51 | PropertySignature ::= PropertyName '?'? ws-opt TypeAnnotation? 52 | PropertyName ::= Identifier 53 | | StringLiteral 54 | | NumericLiteral 55 | CallSignature ::= 56 | (TypeParameters ws-opt)? '(' ws-opt (Parameter-List ws-opt)? ')' ws-opt TypeAnnotation? 57 | Parameter-List ::= 58 | RequiredParameterList 59 | | OptionalParameterList 60 | | RestParameter 61 | | RequiredParameterList comma OptionalParameterList 62 | | RequiredParameterList comma RestParameter 63 | | OptionalParameterList comma RestParameter 64 | | RequiredParameterList comma OptionalParameterList comma RestParameter 65 | RequiredParameterList ::= RequiredParameter (comma RequiredParameter)* ws-opt 66 | RequiredParameter ::= 67 | AccessLevel? Identifier TypeAnnotation? 68 | | Identifier ':' ws-opt StringLiteral 69 | OptionalParameterList ::= OptionalParameter (comma OptionalParameter)* ws-opt 70 | OptionalParameter ::= 71 | AccessLevel? Identifier '?' TypeAnnotation? 72 | | AccessLevel? Identifier TypeAnnotation? Initialiser 73 | Initialiser ::= equals LiteralValue 74 | RestParameter ::= "..." Identifier TypeAnnotation? ws-opt 75 | ConstructSignature ::= "new" ws-opt CallSignature 76 | IndexSignature ::= 77 | ('[' ws-opt)? Identifier ws-opt ':' ws-opt ("string"|"number") rbrace TypeAnnotation 78 | MethodSignature ::= '!'("new" ws | "new(") PropertyName '?'? ws-opt CallSignature 79 | TypeAnnotation ::= ws-opt ':' ws Type 80 | InterfaceDeclaration ::= 81 | "interface" ws Identifier ((TypeParameters ws)? | ws-opt) (InterfaceExtendsClause ws)? ObjectType 82 | InterfaceExtendsClause ::= "extends" ws ClassOrInterfaceTypeList 83 | ClassOrInterfaceTypeList ::= 84 | TypeReference (comma TypeReference)* ws-opt 85 | ClassHeritage ::= ClassExtendsClause? ImplementsClause? 86 | ClassExtendsClause ::= "extends" ws TypeReference 87 | ImplementsClause ::= "implements" ws ClassOrInterfaceTypeList 88 | DeclarationElement ::= ExportAssignment ws-opt 89 | | ("export" ws)? InterfaceDeclaration ws-opt 90 | | ("export" ws)? ImportDeclarartion ws-opt 91 | | ("export" ws)? ExternalImportDeclaration ws-opt 92 | | ("export" ws)? AmbientDeclaration ws-opt 93 | ImportDeclarartion ::= "import" ws Identifier equals QualifiedIdentifier ';' 94 | ExternalImportDeclaration ::= 95 | "import" ws Identifier equals ExternalModuleReference ';' 96 | ExternalModuleReference ::= 97 | "require" lparen StringLiteral rparen 98 | ExportAssignment ::= "export" equals Identifier ';' 99 | AmbientDeclaration ::= "declare" ws AmbientVariableDeclaration 100 | | "declare" ws AmbientFunctionDeclaration 101 | | "declare" ws AmbientClassDeclaration 102 | | "declare" ws AmbientEnumDeclaration 103 | | "declare" ws AmbientModuleDeclaration 104 | | "declare" ws AmbientExternalModuleDeclaration 105 | AmbientVariableDeclaration ::= "var" ws Identifier TypeAnnotation? (ws-opt ';')? 106 | AmbientFunctionDeclaration ::= "function" ws Identifier ws-opt CallSignature ';' 107 | AmbientClassDeclaration ::= 108 | "class" ws Identifier TypeParameters? ClassHeritage '{' AmbientClassBody '}' 109 | AmbientClassBody ::= AmbientClassBodyElement* 110 | AmbientClassBodyElement ::= AmbientConstructorDeclaration 111 | | AmbientPropertyMemberDeclaration 112 | | IndexSignature 113 | AmbientConstructorDeclaration ::= "constructor" ws '(' Parameter-List? ')' ';' 114 | AmbientPropertyMemberDeclaration ::= 115 | AccessLevel? ("static" ws)? PropertyName TypeAnnotation? ';' 116 | AccessLevel? ("static" ws)? PropertyName CallSignature ';' 117 | AmbientEnumDeclaration ::= "enum" Identifier '{' AmbientEnumBody? '}' 118 | AmbientEnumBody ::= AmbientEnumMember (',' AmbientEnumMember)* ','? 119 | AmbientEnumMember ::= PropertyName (equals [0-9]+|"0x"[0-9a-fA-F]+ /*"[0-9]+|0x\p{XDigit}+"*/)? 120 | AmbientModuleDeclaration ::= 121 | "module" ws QualifiedIdentifier ws-opt '{' AmbientModuleBody '}' 122 | AmbientModuleBody ::= (ws-opt AmbientModuleElement)* ws-opt 123 | AmbientModuleElement ::= ("export" ws)? AmbientVariableDeclaration 124 | | ("export" ws)? AmbientFunctionDeclaration 125 | | ("export" ws)? AmbientClassDeclaration 126 | | ("export" ws)? AmbientEnumDeclaration 127 | | ("export" ws)? AmbientModuleDeclaration 128 | | ("export" ws)? AmbientExternalModuleDeclaration 129 | | ("export" ws)? InterfaceDeclaration 130 | | ("export" ws)? ImportDeclarartion 131 | AmbientExternalModuleDeclaration ::= 132 | "module" StringLiteral '{' AmbientExternalModuleBody '}' 133 | AmbientExternalModuleBody ::= AmbientExternalModuleElement* 134 | AmbientExternalModuleElement ::= AmbientModuleElement 135 | | ExportAssignment 136 | | ("export" ws)? ExternalImportDeclaration 137 | 138 | LiteralValue ::= ("true"|"false") 139 | | "null" 140 | | StringLiteral 141 | | NumericLiteral 142 | StringLiteral ::= '"'.*'"' 143 | NumericLiteral ::= 144 | /*Decimal: optional integer followed by optional '.' followed by mandatory 145 | integer followed by optional exponent*/ 146 | [0-9]*.[0-9]+[Ee][-+]?[0-9]+ //"((?:(?:[0-9]*/?\.?[0-f]+(?:[Ee][-+]?[0-9]+))|0[Xx]\p{XDigit}+)" 147 | SingleLineComment ::= '//' [^\n]* 148 | MultiLineComment ::= '/*' InsideMultiLineComment* '*/' 149 | InsideMultiLineComment ::= '!'( '*/' | '/*' ) ("." | [\n\r]) | MultiLineComment 150 | Whitespace ::= ([\s]+ | SingleLineComment | MultiLineComment) 151 | AccessLevel ::= ("public"|"private") ws 152 | /*these are all for making the grammer easer to read*/ 153 | 154 | ws ::= Whitespace+ 155 | ws-opt ::= Whitespace* 156 | lparen ::= ws-opt '(' ws-opt 157 | rparen ::= ws-opt ')' ws-opt 158 | lbrace ::= ws-opt '[' ws-opt 159 | rbrace ::= ws-opt ']' ws-opt 160 | comma ::= ws-opt ',' ws-opt 161 | equals ::= ws-opt '=' ws-opt --------------------------------------------------------------------------------