piggly 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +84 -0
- data/Rakefile +19 -0
- data/bin/piggly +245 -0
- data/lib/piggly/compiler/cache.rb +151 -0
- data/lib/piggly/compiler/pretty.rb +67 -0
- data/lib/piggly/compiler/queue.rb +46 -0
- data/lib/piggly/compiler/tags.rb +244 -0
- data/lib/piggly/compiler/trace.rb +91 -0
- data/lib/piggly/compiler.rb +5 -0
- data/lib/piggly/config.rb +43 -0
- data/lib/piggly/filecache.rb +40 -0
- data/lib/piggly/installer.rb +95 -0
- data/lib/piggly/parser/grammar.tt +747 -0
- data/lib/piggly/parser/nodes.rb +319 -0
- data/lib/piggly/parser/parser.rb +11783 -0
- data/lib/piggly/parser/traversal.rb +48 -0
- data/lib/piggly/parser/treetop_ruby19_patch.rb +17 -0
- data/lib/piggly/parser.rb +67 -0
- data/lib/piggly/profile.rb +87 -0
- data/lib/piggly/reporter/html.rb +207 -0
- data/lib/piggly/reporter/piggly.css +187 -0
- data/lib/piggly/reporter/sortable.js +493 -0
- data/lib/piggly/reporter.rb +21 -0
- data/lib/piggly/task.rb +64 -0
- data/lib/piggly/util.rb +28 -0
- data/lib/piggly/version.rb +15 -0
- data/lib/piggly.rb +18 -0
- data/spec/compiler/cache_spec.rb +9 -0
- data/spec/compiler/pretty_spec.rb +9 -0
- data/spec/compiler/queue_spec.rb +3 -0
- data/spec/compiler/rewrite_spec.rb +3 -0
- data/spec/compiler/tags_spec.rb +285 -0
- data/spec/compiler/trace_spec.rb +173 -0
- data/spec/config_spec.rb +58 -0
- data/spec/filecache_spec.rb +70 -0
- data/spec/fixtures/snippets.sql +158 -0
- data/spec/grammar/expression_spec.rb +302 -0
- data/spec/grammar/statements/assignment_spec.rb +70 -0
- data/spec/grammar/statements/exception_spec.rb +52 -0
- data/spec/grammar/statements/if_spec.rb +178 -0
- data/spec/grammar/statements/loop_spec.rb +41 -0
- data/spec/grammar/statements/sql_spec.rb +71 -0
- data/spec/grammar/tokens/comment_spec.rb +58 -0
- data/spec/grammar/tokens/datatype_spec.rb +52 -0
- data/spec/grammar/tokens/identifier_spec.rb +58 -0
- data/spec/grammar/tokens/keyword_spec.rb +44 -0
- data/spec/grammar/tokens/label_spec.rb +40 -0
- data/spec/grammar/tokens/literal_spec.rb +30 -0
- data/spec/grammar/tokens/lval_spec.rb +50 -0
- data/spec/grammar/tokens/number_spec.rb +34 -0
- data/spec/grammar/tokens/sqlkeywords_spec.rb +45 -0
- data/spec/grammar/tokens/string_spec.rb +54 -0
- data/spec/grammar/tokens/whitespace_spec.rb +40 -0
- data/spec/parser_spec.rb +8 -0
- data/spec/profile_spec.rb +5 -0
- data/spec/reporter/html_spec.rb +0 -0
- data/spec/spec_helper.rb +61 -0
- data/spec/spec_suite.rb +5 -0
- metadata +121 -0
| @@ -0,0 +1,747 @@ | |
| 1 | 
            +
            grammar Piggly
         | 
| 2 | 
            +
              # include Keywords
         | 
| 3 | 
            +
              # include Expressions
         | 
| 4 | 
            +
              # include Statements
         | 
| 5 | 
            +
              # include Tokens
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              rule start
         | 
| 8 | 
            +
                procedure+
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
              
         | 
| 11 | 
            +
              # elements[20] is procedure body
         | 
| 12 | 
            +
              rule procedure
         | 
| 13 | 
            +
                procedureHeader
         | 
| 14 | 
            +
                name:tIdentifier tSpace?
         | 
| 15 | 
            +
                parameters:parameterList tSpace
         | 
| 16 | 
            +
                procedureReturn tSpace
         | 
| 17 | 
            +
                return:tType tSpace kwAS tSpace
         | 
| 18 | 
            +
                procedureBody
         | 
| 19 | 
            +
                procedureFooter <Procedure>
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              rule procedureHeader
         | 
| 23 | 
            +
                tSpace? 'create' tSpace 'or' tSpace 'replace' tSpace 'function' tSpace <TextNode>
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              rule procedureReturn
         | 
| 27 | 
            +
                'returns' tSpace 'setof'? <TextNode>
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              rule procedureBody
         | 
| 31 | 
            +
                dollarQuoteMarker tSpace? body:block ';'? tSpace? dollarQuoteMarker 
         | 
| 32 | 
            +
                / "'"             tSpace? body:block ';'? tSpace? "'"
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              rule procedureFooter
         | 
| 36 | 
            +
                expressionUntilSemiColon ';' tSpace?  <TextNode>
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
              
         | 
| 39 | 
            +
              rule parameterList
         | 
| 40 | 
            +
                '(' ( tSpace? name:tIdentifier tSpace type:tType tSpace? ',' )*
         | 
| 41 | 
            +
                    ( tSpace? name:tIdentifier tSpace type:tType )? tSpace? ')'
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              rule statement
         | 
| 45 | 
            +
                inner:( block ';'
         | 
| 46 | 
            +
                      / stmtAssignment
         | 
| 47 | 
            +
                      / stmtIf
         | 
| 48 | 
            +
                      / stmtCase
         | 
| 49 | 
            +
                      / stmtLoop
         | 
| 50 | 
            +
                      / stmtWhileLoop
         | 
| 51 | 
            +
                      / stmtForLoop
         | 
| 52 | 
            +
                      / stmtExit
         | 
| 53 | 
            +
                      / stmtContinue
         | 
| 54 | 
            +
                      / stmtReturn
         | 
| 55 | 
            +
                      / stmtRaise
         | 
| 56 | 
            +
                      / stmtExecSql
         | 
| 57 | 
            +
                      / stmtNull
         | 
| 58 | 
            +
                      / stmtPerform
         | 
| 59 | 
            +
                      / stmtDynamicExecute
         | 
| 60 | 
            +
                      / stmtGetDiag
         | 
| 61 | 
            +
                      / stmtOpen
         | 
| 62 | 
            +
                      / stmtFetch
         | 
| 63 | 
            +
                      / stmtMove
         | 
| 64 | 
            +
                      / stmtClose ) tail:tSpace? <Statement>
         | 
| 65 | 
            +
              end
         | 
| 66 | 
            +
              
         | 
| 67 | 
            +
              rule block
         | 
| 68 | 
            +
                label_open:tLabel tSpace
         | 
| 69 | 
            +
                blockDeclarations:stmtDeclare*
         | 
| 70 | 
            +
                kwBEGIN
         | 
| 71 | 
            +
                  bodySpace:tSpace
         | 
| 72 | 
            +
                  bodyStub:stubNode
         | 
| 73 | 
            +
                  body:statement*
         | 
| 74 | 
            +
                blockExceptions?
         | 
| 75 | 
            +
                kwEND
         | 
| 76 | 
            +
                ( tSpace label_close:tLabel )?
         | 
| 77 | 
            +
                tSpace? <Block>
         | 
| 78 | 
            +
                / 
         | 
| 79 | 
            +
                blockDeclarations:stmtDeclare*
         | 
| 80 | 
            +
                kwBEGIN
         | 
| 81 | 
            +
                  bodySpace:tSpace
         | 
| 82 | 
            +
                  bodyStub:stubNode
         | 
| 83 | 
            +
                  body:statement*
         | 
| 84 | 
            +
                blockExceptions?
         | 
| 85 | 
            +
                kwEND
         | 
| 86 | 
            +
                tSpace? <Block>
         | 
| 87 | 
            +
              end
         | 
| 88 | 
            +
             | 
| 89 | 
            +
              rule stmtAssignment
         | 
| 90 | 
            +
                lval:lValue tSpace? kwASSIGN ws? rval:expressionUntilSemiColon ';' <Assignment>
         | 
| 91 | 
            +
              end
         | 
| 92 | 
            +
             | 
| 93 | 
            +
              rule stmtCase
         | 
| 94 | 
            +
                kwCASE tSpace 
         | 
| 95 | 
            +
                cases:condWhen+
         | 
| 96 | 
            +
                else:stmtElse?
         | 
| 97 | 
            +
                kwEND tSpace kwCASE tSpace? ';' <Cond>
         | 
| 98 | 
            +
                /
         | 
| 99 | 
            +
                kwCASE tSpace
         | 
| 100 | 
            +
                expr:expressionUntilWhen
         | 
| 101 | 
            +
                cases:caseWhen+
         | 
| 102 | 
            +
                else:stmtElse?
         | 
| 103 | 
            +
                kwEND tSpace kwCASE tSpace? ';' <Case>
         | 
| 104 | 
            +
              end
         | 
| 105 | 
            +
              
         | 
| 106 | 
            +
              rule stmtIf
         | 
| 107 | 
            +
                kwIF
         | 
| 108 | 
            +
                  condSpace:tSpace?
         | 
| 109 | 
            +
                  condStub:stubNode
         | 
| 110 | 
            +
                  cond:expressionUntilThen
         | 
| 111 | 
            +
                kwTHEN
         | 
| 112 | 
            +
                  bodySpace:tSpace
         | 
| 113 | 
            +
                  bodyStub:stubNode
         | 
| 114 | 
            +
                  body:statement*
         | 
| 115 | 
            +
                  else:stmtElse?
         | 
| 116 | 
            +
                kwEND tSpace kwIF tSpace? ';' <If>
         | 
| 117 | 
            +
              end
         | 
| 118 | 
            +
              
         | 
| 119 | 
            +
              rule stmtElse
         | 
| 120 | 
            +
                kwELSIF
         | 
| 121 | 
            +
                  condSpace:tSpace?
         | 
| 122 | 
            +
                  condStub:stubNode
         | 
| 123 | 
            +
                  cond:expressionUntilThen
         | 
| 124 | 
            +
                kwTHEN
         | 
| 125 | 
            +
                  bodySpace:tSpace
         | 
| 126 | 
            +
                  bodyStub:stubNode
         | 
| 127 | 
            +
                  body:statement*
         | 
| 128 | 
            +
                  else:stmtElse? <If>
         | 
| 129 | 
            +
                /
         | 
| 130 | 
            +
                kwELSE
         | 
| 131 | 
            +
                  bodySpace:tSpace
         | 
| 132 | 
            +
                  bodyStub:stubNode
         | 
| 133 | 
            +
                  body:statement* <Else>
         | 
| 134 | 
            +
              end
         | 
| 135 | 
            +
              
         | 
| 136 | 
            +
              rule stmtLoop
         | 
| 137 | 
            +
                label_open:tLabel tSpace
         | 
| 138 | 
            +
                cond:kwLOOP
         | 
| 139 | 
            +
                  bodySpace:tSpace
         | 
| 140 | 
            +
                  bodyStub:stubNode
         | 
| 141 | 
            +
                  body:statement*
         | 
| 142 | 
            +
                kwEND tSpace kwLOOP
         | 
| 143 | 
            +
                ( tSpace label_close:tIdentifier )?
         | 
| 144 | 
            +
                tSpace? ';' exitStub:stubNode <Loop>
         | 
| 145 | 
            +
                /
         | 
| 146 | 
            +
                cond:kwLOOP
         | 
| 147 | 
            +
                  bodySpace:tSpace
         | 
| 148 | 
            +
                  bodyStub:stubNode
         | 
| 149 | 
            +
                  body:statement*
         | 
| 150 | 
            +
                kwEND tSpace kwLOOP
         | 
| 151 | 
            +
                tSpace? ';' exitStub:stubNode <Loop>
         | 
| 152 | 
            +
              end
         | 
| 153 | 
            +
              
         | 
| 154 | 
            +
              rule stmtWhileLoop
         | 
| 155 | 
            +
                label_open:tLabel tSpace
         | 
| 156 | 
            +
                kwWHILE
         | 
| 157 | 
            +
                  condSpace:tSpace?
         | 
| 158 | 
            +
                  condStub:stubNode
         | 
| 159 | 
            +
                  cond:expressionUntilLoop
         | 
| 160 | 
            +
                kwLOOP
         | 
| 161 | 
            +
                  bodySpace:tSpace
         | 
| 162 | 
            +
                  bodyStub:stubNode
         | 
| 163 | 
            +
                  body:statement*
         | 
| 164 | 
            +
                kwEND tSpace kwLOOP
         | 
| 165 | 
            +
                ( tSpace label_close:tIdentifier )?
         | 
| 166 | 
            +
                tSpace? ';' <WhileLoop>
         | 
| 167 | 
            +
                /
         | 
| 168 | 
            +
                kwWHILE
         | 
| 169 | 
            +
                  condSpace:tSpace?
         | 
| 170 | 
            +
                  condStub:stubNode
         | 
| 171 | 
            +
                  cond:expressionUntilLoop
         | 
| 172 | 
            +
                kwLOOP
         | 
| 173 | 
            +
                  bodySpace:tSpace
         | 
| 174 | 
            +
                  bodyStub:stubNode
         | 
| 175 | 
            +
                  body:statement*
         | 
| 176 | 
            +
                kwEND tSpace kwLOOP
         | 
| 177 | 
            +
                tSpace? ';' <WhileLoop>
         | 
| 178 | 
            +
              end
         | 
| 179 | 
            +
              
         | 
| 180 | 
            +
              # loop coverage calculated by using exitStub
         | 
| 181 | 
            +
              rule stmtForLoop
         | 
| 182 | 
            +
                label_open:tLabel tSpace
         | 
| 183 | 
            +
                kwFOR tSpace identifierList tSpace
         | 
| 184 | 
            +
                kwIN
         | 
| 185 | 
            +
                  condSpace:tSpace
         | 
| 186 | 
            +
                  cond:( stmtForSql / expressionUntilLoop )
         | 
| 187 | 
            +
                kwLOOP
         | 
| 188 | 
            +
                  bodySpace:tSpace
         | 
| 189 | 
            +
                  bodyStub:stubNode
         | 
| 190 | 
            +
                  body:statement*
         | 
| 191 | 
            +
                  doneStub:stubNode
         | 
| 192 | 
            +
                kwEND tSpace kwLOOP
         | 
| 193 | 
            +
                ( tSpace label_close:tIdentifier )?
         | 
| 194 | 
            +
                tSpace? ';'
         | 
| 195 | 
            +
                exitStub:stubNode <ForLoop>
         | 
| 196 | 
            +
                /
         | 
| 197 | 
            +
                kwFOR tSpace identifierList tSpace
         | 
| 198 | 
            +
                kwIN
         | 
| 199 | 
            +
                  condSpace:tSpace
         | 
| 200 | 
            +
                  cond:( stmtForSql / expressionUntilLoop )
         | 
| 201 | 
            +
                kwLOOP
         | 
| 202 | 
            +
                  bodySpace:tSpace
         | 
| 203 | 
            +
                  bodyStub:stubNode
         | 
| 204 | 
            +
                  body:statement*
         | 
| 205 | 
            +
                  doneStub:stubNode
         | 
| 206 | 
            +
                kwEND tSpace kwLOOP tSpace? ';'
         | 
| 207 | 
            +
                exitStub:stubNode <ForLoop>
         | 
| 208 | 
            +
              end
         | 
| 209 | 
            +
              
         | 
| 210 | 
            +
              rule stmtForSql
         | 
| 211 | 
            +
                sqlKeyword tSpace expressionUntilLoop <Sql>
         | 
| 212 | 
            +
              end
         | 
| 213 | 
            +
              
         | 
| 214 | 
            +
              rule stmtExit
         | 
| 215 | 
            +
                bodyStub:stubNode
         | 
| 216 | 
            +
                body:( kwEXIT (tSpace label:tIdentifier)? ) tSpace? ';' <Exit>
         | 
| 217 | 
            +
                /
         | 
| 218 | 
            +
                body:( kwEXIT (tSpace label:tIdentifier)? ) tSpace
         | 
| 219 | 
            +
                kwWHEN
         | 
| 220 | 
            +
                  condSpace:tSpace
         | 
| 221 | 
            +
                  condStub:stubNode
         | 
| 222 | 
            +
                  cond:expressionUntilSemiColon ';' <ExitWhen>
         | 
| 223 | 
            +
              end
         | 
| 224 | 
            +
             | 
| 225 | 
            +
              rule stmtContinue
         | 
| 226 | 
            +
                bodyStub:stubNode
         | 
| 227 | 
            +
                body:( kwCONTINUE (tSpace label:tIdentifier)? ) tSpace? ';' <Continue>
         | 
| 228 | 
            +
                /
         | 
| 229 | 
            +
                body:( kwCONTINUE (tSpace label:tIdentifier)? ) tSpace
         | 
| 230 | 
            +
                kwWHEN
         | 
| 231 | 
            +
                  condSpace:tSpace
         | 
| 232 | 
            +
                  condStub:stubNode
         | 
| 233 | 
            +
                  cond:expressionUntilSemiColon ';' <ContinueWhen>
         | 
| 234 | 
            +
              end
         | 
| 235 | 
            +
              
         | 
| 236 | 
            +
              rule stmtReturn
         | 
| 237 | 
            +
                bodyStub:stubNode
         | 
| 238 | 
            +
                body:(kwRETURN ( tSpace? &';'
         | 
| 239 | 
            +
                               / tSpace kwNEXT tSpace expressionUntilSemiColon tSpace?
         | 
| 240 | 
            +
                               / tSpace kwQUERY tSpace expressionUntilSemiColon
         | 
| 241 | 
            +
                               / expressionUntilSemiColon )) ';'
         | 
| 242 | 
            +
              end
         | 
| 243 | 
            +
              
         | 
| 244 | 
            +
              rule stmtRaise
         | 
| 245 | 
            +
                bodyStub:stubNode
         | 
| 246 | 
            +
                body:(kwRAISE tSpace level:kwEXCEPTION tSpace expr:expressionUntilSemiColon) ';' <Throw>
         | 
| 247 | 
            +
                /
         | 
| 248 | 
            +
                kwRAISE tSpace
         | 
| 249 | 
            +
                level:( kwWARNING
         | 
| 250 | 
            +
                      / kwNOTICE
         | 
| 251 | 
            +
                      / kwINFO
         | 
| 252 | 
            +
                      / kwLOG
         | 
| 253 | 
            +
                      / kwDEBUG )
         | 
| 254 | 
            +
                tSpace
         | 
| 255 | 
            +
                expr:expressionUntilSemiColon ';' <Raise>
         | 
| 256 | 
            +
              end
         | 
| 257 | 
            +
              
         | 
| 258 | 
            +
              rule stmtExecSql
         | 
| 259 | 
            +
                sqlKeyword tSpace expressionUntilSemiColon ';' <Sql>
         | 
| 260 | 
            +
              end
         | 
| 261 | 
            +
              
         | 
| 262 | 
            +
              rule stmtDynamicExecute
         | 
| 263 | 
            +
                kwEXECUTE tSpace expressionUntilSemiColon ';'
         | 
| 264 | 
            +
              end
         | 
| 265 | 
            +
              
         | 
| 266 | 
            +
              rule stmtPerform
         | 
| 267 | 
            +
                kwPERFORM tSpace expressionUntilSemiColon ';'
         | 
| 268 | 
            +
              end
         | 
| 269 | 
            +
              
         | 
| 270 | 
            +
              rule stmtOpen
         | 
| 271 | 
            +
                kwOPEN notImplemented
         | 
| 272 | 
            +
              end
         | 
| 273 | 
            +
              
         | 
| 274 | 
            +
              rule stmtFetch
         | 
| 275 | 
            +
                kwFETCH notImplemented
         | 
| 276 | 
            +
              end
         | 
| 277 | 
            +
              
         | 
| 278 | 
            +
              rule stmtMove
         | 
| 279 | 
            +
                kwMOVE notImplemented
         | 
| 280 | 
            +
              end
         | 
| 281 | 
            +
              
         | 
| 282 | 
            +
              rule stmtClose
         | 
| 283 | 
            +
                kwCLOSE notImplemented
         | 
| 284 | 
            +
              end
         | 
| 285 | 
            +
              
         | 
| 286 | 
            +
              rule stmtGetDiag
         | 
| 287 | 
            +
                kwGET tSpace
         | 
| 288 | 
            +
                kwPERFORM tSpace
         | 
| 289 | 
            +
                notImplemented
         | 
| 290 | 
            +
              end
         | 
| 291 | 
            +
              
         | 
| 292 | 
            +
              rule stmtNull
         | 
| 293 | 
            +
                kwNULL tSpace? ';'
         | 
| 294 | 
            +
              end
         | 
| 295 | 
            +
              
         | 
| 296 | 
            +
              ##
         | 
| 297 | 
            +
              #############################################################################
         | 
| 298 | 
            +
              
         | 
| 299 | 
            +
              rule stmtDeclare
         | 
| 300 | 
            +
                kwDECLARE tSpace varDeclaration*
         | 
| 301 | 
            +
              end
         | 
| 302 | 
            +
             | 
| 303 | 
            +
              rule varDeclaration
         | 
| 304 | 
            +
                name:tIdentifier tSpace ( kwCONSTANT tSpace )?
         | 
| 305 | 
            +
                type:tType ( tSpace kwNOT tSpace kwNULL )?
         | 
| 306 | 
            +
                           ( tSpace kwASSIGN tSpace? rval:expressionUntilSemiColon )?
         | 
| 307 | 
            +
                tSpace?
         | 
| 308 | 
            +
                ';' tSpace?
         | 
| 309 | 
            +
              end
         | 
| 310 | 
            +
             | 
| 311 | 
            +
              rule identifierList
         | 
| 312 | 
            +
                tIdentifier ( tSpace? ',' tSpace? tIdentifier )*
         | 
| 313 | 
            +
              end
         | 
| 314 | 
            +
             | 
| 315 | 
            +
              rule blockExceptions
         | 
| 316 | 
            +
                kwEXCEPTION tSpace cases:exceptionCase*
         | 
| 317 | 
            +
              end
         | 
| 318 | 
            +
              
         | 
| 319 | 
            +
              rule exceptionCase
         | 
| 320 | 
            +
                # cannot provide branch-coverage on cond
         | 
| 321 | 
            +
                kwWHEN
         | 
| 322 | 
            +
                  condSpace:tSpace
         | 
| 323 | 
            +
                  cond:expressionUntilThen
         | 
| 324 | 
            +
                kwTHEN
         | 
| 325 | 
            +
                  bodySpace:tSpace
         | 
| 326 | 
            +
                  bodyStub:stubNode
         | 
| 327 | 
            +
                  body:statement* <Catch>
         | 
| 328 | 
            +
              end
         | 
| 329 | 
            +
             | 
| 330 | 
            +
              rule caseWhen
         | 
| 331 | 
            +
                # cannot provide branch-coverage on cond
         | 
| 332 | 
            +
                kwWHEN
         | 
| 333 | 
            +
                  condSpace:tSpace
         | 
| 334 | 
            +
                  cond:expressionUntilThen
         | 
| 335 | 
            +
                kwTHEN
         | 
| 336 | 
            +
                  bodySpace:tSpace
         | 
| 337 | 
            +
                  bodyStub:stubNode
         | 
| 338 | 
            +
                  body:statement* <Case>
         | 
| 339 | 
            +
              end
         | 
| 340 | 
            +
             | 
| 341 | 
            +
              rule condWhen
         | 
| 342 | 
            +
                kwWHEN
         | 
| 343 | 
            +
                  condSpace:tSpace
         | 
| 344 | 
            +
                  condStub:stubNode
         | 
| 345 | 
            +
                  cond:expressionUntilThen
         | 
| 346 | 
            +
                kwTHEN
         | 
| 347 | 
            +
                  bodySpace:tSpace
         | 
| 348 | 
            +
                  bodyStub:stubNode
         | 
| 349 | 
            +
                  body:statement* <Cond>
         | 
| 350 | 
            +
              end
         | 
| 351 | 
            +
              
         | 
| 352 | 
            +
              ## EXPRESSIONS
         | 
| 353 | 
            +
              #############################################################################
         | 
| 354 | 
            +
              
         | 
| 355 | 
            +
              # it would be nice to match parens and brackets here, but we again assume there
         | 
| 356 | 
            +
              # are no syntax errors in the proc and let the database worry about them
         | 
| 357 | 
            +
              
         | 
| 358 | 
            +
              rule expressionUntilSemiColon
         | 
| 359 | 
            +
                head:tSpace? expr:( tString / skipWords / tSpace !';' / !tSpace [^;] )* tail:tSpace? &';' <Expression>
         | 
| 360 | 
            +
              end
         | 
| 361 | 
            +
              
         | 
| 362 | 
            +
              rule expressionUntilClosingBracket
         | 
| 363 | 
            +
                head:tSpace? expr:( tString / skipWords / tSpace !']' / !tSpace [^\]] )+ tail:tSpace? &']' <Expression>
         | 
| 364 | 
            +
              end
         | 
| 365 | 
            +
              
         | 
| 366 | 
            +
              rule expressionUntilThen
         | 
| 367 | 
            +
                head:tSpace? expr:( tString / skipWords / tSpace !kwTHEN / !tSpace !kwTHEN . )+ tail:tSpace &kwTHEN <Expression>
         | 
| 368 | 
            +
              end
         | 
| 369 | 
            +
              
         | 
| 370 | 
            +
              rule expressionUntilWhen
         | 
| 371 | 
            +
                head:tSpace? expr:( tString / skipWords / tSpace !kwWHEN / !tSpace !kwWHEN . )+ tail:tSpace &kwWHEN <Expression>
         | 
| 372 | 
            +
              end
         | 
| 373 | 
            +
              
         | 
| 374 | 
            +
              rule expressionUntilLoop
         | 
| 375 | 
            +
                head:tSpace? expr:( tString / skipWords / tSpace !kwLOOP / !tSpace !kwLOOP . )+ tail:tSpace &kwLOOP <Expression>
         | 
| 376 | 
            +
              end
         | 
| 377 | 
            +
             | 
| 378 | 
            +
              rule skipWords
         | 
| 379 | 
            +
                [a-z0-9_]+ <TextNode>
         | 
| 380 | 
            +
              end
         | 
| 381 | 
            +
             | 
| 382 | 
            +
              ##
         | 
| 383 | 
            +
              #############################################################################
         | 
| 384 | 
            +
             | 
| 385 | 
            +
              rule ws
         | 
| 386 | 
            +
                [ \t\n\v\f\r]+ <TextNode>
         | 
| 387 | 
            +
              end
         | 
| 388 | 
            +
              
         | 
| 389 | 
            +
              rule dollarQuoteMarker
         | 
| 390 | 
            +
                '$' tag:( [a-z\200-\377_] [a-z\200-\377_0-9]* )? '$' <TDollarQuoteMarker>
         | 
| 391 | 
            +
              end
         | 
| 392 | 
            +
              
         | 
| 393 | 
            +
              rule stubNode
         | 
| 394 | 
            +
                '' <StubNode>
         | 
| 395 | 
            +
              end
         | 
| 396 | 
            +
             | 
| 397 | 
            +
              rule notImplemented
         | 
| 398 | 
            +
                '' <NotImplemented>
         | 
| 399 | 
            +
              end
         | 
| 400 | 
            +
              
         | 
| 401 | 
            +
              rule lValue
         | 
| 402 | 
            +
                  tIdentifier sub:('[' expressionUntilClosingBracket ']')+ next:('.' lValue)+ <Assignable>
         | 
| 403 | 
            +
                / tIdentifier sub:('[' expressionUntilClosingBracket ']')+ <Assignable>
         | 
| 404 | 
            +
                / tIdentifier next:('.' lValue)+ <Assignable>
         | 
| 405 | 
            +
                / tIdentifier x:'' <Assignable>
         | 
| 406 | 
            +
              end
         | 
| 407 | 
            +
              
         | 
| 408 | 
            +
              ## BASIC TOKENS
         | 
| 409 | 
            +
              #############################################################################
         | 
| 410 | 
            +
             | 
| 411 | 
            +
              rule tEOF
         | 
| 412 | 
            +
                !.
         | 
| 413 | 
            +
              end
         | 
| 414 | 
            +
              
         | 
| 415 | 
            +
              rule tLabel
         | 
| 416 | 
            +
                '<<' tSpace? name:tIdentifier tSpace? '>>' <TLabel>
         | 
| 417 | 
            +
              end
         | 
| 418 | 
            +
              
         | 
| 419 | 
            +
              rule tIdentifier
         | 
| 420 | 
            +
                ( '"' [^"]+ '"' )+ <TIdentifier>
         | 
| 421 | 
            +
                / !keyword ( [a-z\200-\377_] [a-z\200-\377_0-9$]* ) <TIdentifier>
         | 
| 422 | 
            +
              end
         | 
| 423 | 
            +
             | 
| 424 | 
            +
              # not context sensitive so opening and closing tag might not match
         | 
| 425 | 
            +
              rule tString
         | 
| 426 | 
            +
                openTag:dollarQuoteMarker content:(!dollarQuoteMarker .)* closeTag:dollarQuoteMarker <TString> /
         | 
| 427 | 
            +
                "E'" content:("''" / [^'])* "'" <TString> /
         | 
| 428 | 
            +
                "'"  content:("''" / [^'])* "'" <TString>
         | 
| 429 | 
            +
              end
         | 
| 430 | 
            +
              
         | 
| 431 | 
            +
              # beware this is quite broad and might match things it shouldn't
         | 
| 432 | 
            +
              rule tType
         | 
| 433 | 
            +
                [a-z\200-\377_]
         | 
| 434 | 
            +
                ( '(' rType ')' /
         | 
| 435 | 
            +
                  '[' rType ']' /
         | 
| 436 | 
            +
                  [a-z\200-\377_0-9$%]+ /
         | 
| 437 | 
            +
                  ws !( kwAS / kwNOT / kwASSIGN / kwDEFAULT ) )* <TDatatype>
         | 
| 438 | 
            +
              end
         | 
| 439 | 
            +
              
         | 
| 440 | 
            +
              rule rType
         | 
| 441 | 
            +
                ( '(' rType ')' /
         | 
| 442 | 
            +
                  '[' rType ']' /
         | 
| 443 | 
            +
                  [^\(\)\[\]]+ )*
         | 
| 444 | 
            +
              end
         | 
| 445 | 
            +
             | 
| 446 | 
            +
              rule tSpace
         | 
| 447 | 
            +
                ws !tComment <TextNode>
         | 
| 448 | 
            +
                /
         | 
| 449 | 
            +
                ( ws / tComment )+
         | 
| 450 | 
            +
              end
         | 
| 451 | 
            +
              
         | 
| 452 | 
            +
              rule tComment
         | 
| 453 | 
            +
                '/*' content:(!'*/' .)* '*/' <TComment> /
         | 
| 454 | 
            +
                '--' content:[^\n]* ("\n" / tEOF) <TComment>
         | 
| 455 | 
            +
              end
         | 
| 456 | 
            +
             | 
| 457 | 
            +
              ##
         | 
| 458 | 
            +
              #############################################################################
         | 
| 459 | 
            +
             | 
| 460 | 
            +
              rule tBinary
         | 
| 461 | 
            +
                "b'" [01]+ "'"
         | 
| 462 | 
            +
              end
         | 
| 463 | 
            +
             | 
| 464 | 
            +
              rule tHex
         | 
| 465 | 
            +
                "x'" [0123456789abcdef]+ "'"
         | 
| 466 | 
            +
              end
         | 
| 467 | 
            +
             | 
| 468 | 
            +
              rule tNumber
         | 
| 469 | 
            +
                tBinary / tHex /
         | 
| 470 | 
            +
                sign:[+-]?        '.' [0-9]+ exponent:('e' [+-]? [0-9]+)? /
         | 
| 471 | 
            +
                sign:[+-]? [0-9]+ '.' [0-9]* exponent:('e' [+-]? [0-9]+)? /
         | 
| 472 | 
            +
                sign:[+-]? [0-9]+ '.'?       exponent:('e' [+-]? [0-9]+)?
         | 
| 473 | 
            +
              end
         | 
| 474 | 
            +
             | 
| 475 | 
            +
              rule tLiteral
         | 
| 476 | 
            +
                tString (tSpace? '::' tSpace? tType) /
         | 
| 477 | 
            +
                tString /
         | 
| 478 | 
            +
                tNumber (tSpace? '::' tSpace? tType) /
         | 
| 479 | 
            +
                tNumber /
         | 
| 480 | 
            +
                'cast' tSpace? '(' tSpace? tString tSpace kwAS tSpace tType tSpace? ')' /
         | 
| 481 | 
            +
                'cast' tSpace? '(' tSpace? tNumber tSpace kwAS tSpace tType tSpace? ')'
         | 
| 482 | 
            +
              end
         | 
| 483 | 
            +
              
         | 
| 484 | 
            +
              ## KEYWORDS
         | 
| 485 | 
            +
              #############################################################################
         | 
| 486 | 
            +
              
         | 
| 487 | 
            +
              rule sqlKeyword
         | 
| 488 | 
            +
                ( 'insert'
         | 
| 489 | 
            +
                / 'select'
         | 
| 490 | 
            +
                / 'update'
         | 
| 491 | 
            +
                / 'delete'
         | 
| 492 | 
            +
                / 'drop'
         | 
| 493 | 
            +
                / 'alter'
         | 
| 494 | 
            +
                / 'commit'
         | 
| 495 | 
            +
                / 'copy'
         | 
| 496 | 
            +
                / 'create'
         | 
| 497 | 
            +
                / 'begin'
         | 
| 498 | 
            +
                / 'rollback'
         | 
| 499 | 
            +
                / 'set'
         | 
| 500 | 
            +
                / 'start'
         | 
| 501 | 
            +
                / 'vacuum' ) ![a-z0-9] <TextNode>
         | 
| 502 | 
            +
              end
         | 
| 503 | 
            +
              
         | 
| 504 | 
            +
              rule keyword
         | 
| 505 | 
            +
                # WHEN is checked first as a minor optimization to distinguish
         | 
| 506 | 
            +
                #   CONTINUE tIdentifier WHEN cond;
         | 
| 507 | 
            +
                #   EXIT tIdentifier WHEN cond;
         | 
| 508 | 
            +
                #
         | 
| 509 | 
            +
                #   CONTINUE WHEN cond;
         | 
| 510 | 
            +
                #   EXIT WHEN cond;
         | 
| 511 | 
            +
             | 
| 512 | 
            +
                kwWHEN / kwAS / kwASSIGN / kwALIAS / kwBEGIN / kwBY / kwCASE / kwCLOSE
         | 
| 513 | 
            +
                / kwCONSTANT / kwCONTINUE / kwCURSOR / kwDEBUG / kwDECLARE / kwDEFAULT
         | 
| 514 | 
            +
                / kwDIAGNOSTICS / kwELSE / kwELSIF / kwEND / kwEXCEPTION / kwEXECUTE / kwEXIT
         | 
| 515 | 
            +
                / kwFETCH / kwFOR / kwFROM / kwGET / kwIF / kwIN / kwINFO / kwINSERT / kwINTO
         | 
| 516 | 
            +
                / kwIS / kwLOG / kwLOOP / kwMOVE / kwNOT / kwNOTICE / kwNULL / kwOPEN
         | 
| 517 | 
            +
                / kwOR / kwPERFORM / kwRAISE / kwRENAME / kwRESULTOID / kwRETURN
         | 
| 518 | 
            +
                / kwREVERSE / kwROWCOUNT / kwSCROLL / kwSTRICT / kwTHEN / kwTO / kwTYPE
         | 
| 519 | 
            +
                / kwWARNING / kwWHILE
         | 
| 520 | 
            +
              end
         | 
| 521 | 
            +
              
         | 
| 522 | 
            +
              # this terminates keywords
         | 
| 523 | 
            +
              rule x
         | 
| 524 | 
            +
                [^a-z0-9_]
         | 
| 525 | 
            +
              end
         | 
| 526 | 
            +
              
         | 
| 527 | 
            +
              rule kwAS
         | 
| 528 | 
            +
                'as' ![a-z0-9_] <TKeyword>
         | 
| 529 | 
            +
              end
         | 
| 530 | 
            +
              
         | 
| 531 | 
            +
              rule kwASSIGN
         | 
| 532 | 
            +
                ':=' <TKeyword> / '=' <TKeyword>
         | 
| 533 | 
            +
              end
         | 
| 534 | 
            +
              
         | 
| 535 | 
            +
              rule kwALIAS
         | 
| 536 | 
            +
                'alias' ![a-z0-9_] <TKeyword>
         | 
| 537 | 
            +
              end
         | 
| 538 | 
            +
              
         | 
| 539 | 
            +
              rule kwBEGIN
         | 
| 540 | 
            +
                'begin' ![a-z0-9_] <TKeyword>
         | 
| 541 | 
            +
              end
         | 
| 542 | 
            +
              
         | 
| 543 | 
            +
              rule kwBY
         | 
| 544 | 
            +
                'by' ![a-z0-9_] <TKeyword>
         | 
| 545 | 
            +
              end
         | 
| 546 | 
            +
             | 
| 547 | 
            +
              rule kwCASE
         | 
| 548 | 
            +
                'case' ![a-z0-9_] <TKeyword>
         | 
| 549 | 
            +
              end
         | 
| 550 | 
            +
              
         | 
| 551 | 
            +
              rule kwCLOSE
         | 
| 552 | 
            +
                'close' ![a-z0-9_] <TKeyword>
         | 
| 553 | 
            +
              end
         | 
| 554 | 
            +
              
         | 
| 555 | 
            +
              rule kwCONSTANT
         | 
| 556 | 
            +
                'constant' ![a-z0-9_] <TKeyword>
         | 
| 557 | 
            +
              end
         | 
| 558 | 
            +
              
         | 
| 559 | 
            +
              rule kwCONTINUE
         | 
| 560 | 
            +
                'continue' ![a-z0-9_] <TKeyword>
         | 
| 561 | 
            +
              end
         | 
| 562 | 
            +
              
         | 
| 563 | 
            +
              rule kwCURSOR
         | 
| 564 | 
            +
                'cursor' ![a-z0-9_] <TKeyword>
         | 
| 565 | 
            +
              end
         | 
| 566 | 
            +
              
         | 
| 567 | 
            +
              rule kwDEBUG
         | 
| 568 | 
            +
                'debug' ![a-z0-9_] <TKeyword>
         | 
| 569 | 
            +
              end
         | 
| 570 | 
            +
              
         | 
| 571 | 
            +
              rule kwDECLARE
         | 
| 572 | 
            +
                'declare' ![a-z0-9_] <TKeyword>
         | 
| 573 | 
            +
              end
         | 
| 574 | 
            +
              
         | 
| 575 | 
            +
              rule kwDEFAULT
         | 
| 576 | 
            +
                'default' ![a-z0-9_] <TKeyword>
         | 
| 577 | 
            +
              end
         | 
| 578 | 
            +
              
         | 
| 579 | 
            +
              rule kwDIAGNOSTICS
         | 
| 580 | 
            +
                'diagnostics' ![a-z0-9_] <TKeyword>
         | 
| 581 | 
            +
              end
         | 
| 582 | 
            +
              
         | 
| 583 | 
            +
              rule kwELSE
         | 
| 584 | 
            +
                'else' ![a-z0-9_] <TKeyword>
         | 
| 585 | 
            +
              end
         | 
| 586 | 
            +
              
         | 
| 587 | 
            +
              rule kwELSIF
         | 
| 588 | 
            +
                ('elsif'/'elseif') ![a-z0-9_] <TKeyword>
         | 
| 589 | 
            +
              end
         | 
| 590 | 
            +
              
         | 
| 591 | 
            +
              rule kwEND
         | 
| 592 | 
            +
                'end' ![a-z0-9_] <TKeyword>
         | 
| 593 | 
            +
              end
         | 
| 594 | 
            +
              
         | 
| 595 | 
            +
              rule kwEXCEPTION
         | 
| 596 | 
            +
                'exception' ![a-z0-9_] <TKeyword>
         | 
| 597 | 
            +
              end
         | 
| 598 | 
            +
              
         | 
| 599 | 
            +
              rule kwEXECUTE
         | 
| 600 | 
            +
                'execute' ![a-z0-9_] <TKeyword>
         | 
| 601 | 
            +
              end
         | 
| 602 | 
            +
              
         | 
| 603 | 
            +
              rule kwEXIT
         | 
| 604 | 
            +
                'exit' ![a-z0-9_] <TKeyword>
         | 
| 605 | 
            +
              end
         | 
| 606 | 
            +
              
         | 
| 607 | 
            +
              rule kwFETCH
         | 
| 608 | 
            +
                'fetch' ![a-z0-9_] <TKeyword>
         | 
| 609 | 
            +
              end
         | 
| 610 | 
            +
              
         | 
| 611 | 
            +
              rule kwFOR
         | 
| 612 | 
            +
                'for' ![a-z0-9_] <TKeyword>
         | 
| 613 | 
            +
              end
         | 
| 614 | 
            +
              
         | 
| 615 | 
            +
              rule kwFROM
         | 
| 616 | 
            +
                'from' ![a-z0-9_] <TKeyword>
         | 
| 617 | 
            +
              end
         | 
| 618 | 
            +
              
         | 
| 619 | 
            +
              rule kwGET
         | 
| 620 | 
            +
                'get' ![a-z0-9_] <TKeyword>
         | 
| 621 | 
            +
              end
         | 
| 622 | 
            +
              
         | 
| 623 | 
            +
              rule kwIF
         | 
| 624 | 
            +
                'if' ![a-z0-9_] <TKeyword>
         | 
| 625 | 
            +
              end
         | 
| 626 | 
            +
              
         | 
| 627 | 
            +
              rule kwIN
         | 
| 628 | 
            +
                'in' ![a-z0-9_] <TKeyword>
         | 
| 629 | 
            +
              end
         | 
| 630 | 
            +
              
         | 
| 631 | 
            +
              rule kwINFO
         | 
| 632 | 
            +
                'info' ![a-z0-9_] <TKeyword>
         | 
| 633 | 
            +
              end
         | 
| 634 | 
            +
              
         | 
| 635 | 
            +
              rule kwINSERT
         | 
| 636 | 
            +
                'insert' ![a-z0-9_] <TKeyword>
         | 
| 637 | 
            +
              end
         | 
| 638 | 
            +
              
         | 
| 639 | 
            +
              rule kwINTO
         | 
| 640 | 
            +
                'into' ![a-z0-9_] <TKeyword>
         | 
| 641 | 
            +
              end
         | 
| 642 | 
            +
              
         | 
| 643 | 
            +
              rule kwIS
         | 
| 644 | 
            +
                'is' ![a-z0-9_] <TKeyword>
         | 
| 645 | 
            +
              end
         | 
| 646 | 
            +
              
         | 
| 647 | 
            +
              rule kwLOG
         | 
| 648 | 
            +
                'log' ![a-z0-9_] <TKeyword>
         | 
| 649 | 
            +
              end
         | 
| 650 | 
            +
              
         | 
| 651 | 
            +
              rule kwLOOP
         | 
| 652 | 
            +
                'loop' ![a-z0-9_] <TKeyword>
         | 
| 653 | 
            +
              end
         | 
| 654 | 
            +
              
         | 
| 655 | 
            +
              rule kwMOVE
         | 
| 656 | 
            +
                'move' ![a-z0-9_] <TKeyword>
         | 
| 657 | 
            +
              end
         | 
| 658 | 
            +
              
         | 
| 659 | 
            +
              rule kwNEXT
         | 
| 660 | 
            +
                'next' ![a-z0-9_] <TKeyword>
         | 
| 661 | 
            +
              end
         | 
| 662 | 
            +
              
         | 
| 663 | 
            +
              rule kwNOT
         | 
| 664 | 
            +
                'not' ![a-z0-9_] <TKeyword>
         | 
| 665 | 
            +
              end
         | 
| 666 | 
            +
              
         | 
| 667 | 
            +
              rule kwNOTICE
         | 
| 668 | 
            +
                'notice' ![a-z0-9_] <TKeyword>
         | 
| 669 | 
            +
              end
         | 
| 670 | 
            +
              
         | 
| 671 | 
            +
              rule kwNULL
         | 
| 672 | 
            +
                'null' ![a-z0-9_] <TKeyword>
         | 
| 673 | 
            +
              end
         | 
| 674 | 
            +
              
         | 
| 675 | 
            +
              rule kwOPEN
         | 
| 676 | 
            +
                'open' ![a-z0-9_] <TKeyword>
         | 
| 677 | 
            +
              end
         | 
| 678 | 
            +
              
         | 
| 679 | 
            +
              rule kwOR
         | 
| 680 | 
            +
                'or' ![a-z0-9_] <TKeyword>
         | 
| 681 | 
            +
              end
         | 
| 682 | 
            +
              
         | 
| 683 | 
            +
              rule kwPERFORM
         | 
| 684 | 
            +
                'perform' ![a-z0-9_] <TKeyword>
         | 
| 685 | 
            +
              end
         | 
| 686 | 
            +
             | 
| 687 | 
            +
              rule kwQUERY
         | 
| 688 | 
            +
                'query' ![a-z0-9_] <TKeyword>
         | 
| 689 | 
            +
              end
         | 
| 690 | 
            +
              
         | 
| 691 | 
            +
              rule kwRAISE
         | 
| 692 | 
            +
                'raise' ![a-z0-9_] <TKeyword>
         | 
| 693 | 
            +
              end
         | 
| 694 | 
            +
              
         | 
| 695 | 
            +
              rule kwRENAME
         | 
| 696 | 
            +
                'rename' ![a-z0-9_] <TKeyword>
         | 
| 697 | 
            +
              end
         | 
| 698 | 
            +
              
         | 
| 699 | 
            +
              rule kwRESULTOID
         | 
| 700 | 
            +
                'result_oid' ![a-z0-9_] <TKeyword>
         | 
| 701 | 
            +
              end
         | 
| 702 | 
            +
              
         | 
| 703 | 
            +
              rule kwRETURN
         | 
| 704 | 
            +
                'return' ![a-z0-9_] <TKeyword>
         | 
| 705 | 
            +
              end
         | 
| 706 | 
            +
              
         | 
| 707 | 
            +
              rule kwREVERSE
         | 
| 708 | 
            +
                'reverse' ![a-z0-9_] <TKeyword>
         | 
| 709 | 
            +
              end
         | 
| 710 | 
            +
              
         | 
| 711 | 
            +
              rule kwROWCOUNT
         | 
| 712 | 
            +
                'row_count' ![a-z0-9_] <TKeyword>
         | 
| 713 | 
            +
              end
         | 
| 714 | 
            +
              
         | 
| 715 | 
            +
              rule kwSCROLL
         | 
| 716 | 
            +
                'scroll' ![a-z0-9_] <TKeyword>
         | 
| 717 | 
            +
              end
         | 
| 718 | 
            +
              
         | 
| 719 | 
            +
              rule kwSTRICT
         | 
| 720 | 
            +
                'strict' ![a-z0-9_] <TKeyword>
         | 
| 721 | 
            +
              end
         | 
| 722 | 
            +
              
         | 
| 723 | 
            +
              rule kwTHEN
         | 
| 724 | 
            +
                'then' ![a-z0-9_] <TKeyword>
         | 
| 725 | 
            +
              end
         | 
| 726 | 
            +
              
         | 
| 727 | 
            +
              rule kwTO
         | 
| 728 | 
            +
                'to' ![a-z0-9_] <TKeyword>
         | 
| 729 | 
            +
              end
         | 
| 730 | 
            +
              
         | 
| 731 | 
            +
              rule kwTYPE
         | 
| 732 | 
            +
                'type' ![a-z0-9_] <TKeyword>
         | 
| 733 | 
            +
              end
         | 
| 734 | 
            +
              
         | 
| 735 | 
            +
              rule kwWARNING
         | 
| 736 | 
            +
                'warning' ![a-z0-9_] <TKeyword>
         | 
| 737 | 
            +
              end
         | 
| 738 | 
            +
              
         | 
| 739 | 
            +
              rule kwWHEN
         | 
| 740 | 
            +
                'when' ![a-z0-9_] <TKeyword>
         | 
| 741 | 
            +
              end
         | 
| 742 | 
            +
             | 
| 743 | 
            +
              rule kwWHILE
         | 
| 744 | 
            +
                'while' ![a-z0-9_] <TKeyword>
         | 
| 745 | 
            +
              end
         | 
| 746 | 
            +
              
         | 
| 747 | 
            +
            end
         |