Skip to content

Commit

Permalink
Issue #45: Extend the grammer to explicitly support CURSOR variables …
Browse files Browse the repository at this point in the history
…in a declaration section.

Also allow "COLLATE" and "DEFAULT" in regular variable declarations.
  • Loading branch information
hawicz committed Jun 17, 2020
1 parent 113f6bb commit 9fbf2f1
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions lib/piggly/parser/grammar.tt
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,21 @@ grammar Piggly
end

rule varDeclaration
varDeclarationMisc / varDeclarationCursor
end

rule varDeclarationMisc
name:tIdentifier tSpace ( kwCONSTANT tSpace )?
type:tType ( tSpace kwNOT tSpace kwNULL )?
( tSpace? kwASSIGN tSpace? rval:expressionUntilSemiColon )?
type:tType ( tSpace kwCOLLATE name:tIdentifier )?
( tSpace kwNOT tSpace kwNULL )?
( tSpace? ( kwASSIGN / kwDEFAULT ) tSpace? rval:expressionUntilSemiColon )?
tSpace?
';' tSpace?
end

rule varDeclarationCursor
name:tIdentifier tSpace ( kwNO tSpace kwSCROLL tSpace )? kwCURSOR tSpace
rval:expressionUntilSemiColon
tSpace?
';' tSpace?
end
Expand Down Expand Up @@ -494,7 +506,7 @@ grammar Piggly
# EXIT WHEN cond;

kwWHEN / kwAS / kwASSIGN / kwALIAS / kwBEGIN / kwBY / kwCASE / kwARRAY
/ kwCONSTANT / kwCONTINUE / kwCURSOR / kwDEBUG / kwDECLARE / kwDEFAULT
/ kwCOLLATE / kwCONSTANT / kwCONTINUE / kwCURSOR / kwDEBUG / kwDECLARE / kwDEFAULT
/ kwDIAGNOSTICS / kwELSE / kwELSIF / kwEND / kwEXCEPTION / kwEXECUTE / kwEXIT
/ kwFOR / kwFROM / kwGET / kwIF / kwIN / kwINFO / kwINSERT / kwINTO
/ kwIS / kwLOG / kwLOOP / kwNOT / kwNOTICE / kwNULL / kwFOREACH
Expand Down Expand Up @@ -536,6 +548,10 @@ grammar Piggly
'case' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
end

rule kwCOLLATE
'collate' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
end

rule kwCONSTANT
'constant' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
end
Expand Down Expand Up @@ -640,6 +656,10 @@ grammar Piggly
'next' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
end

rule kwNO
'no' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
end

rule kwNOT
'not' ![a-z0-9_] <Piggly::Parser::Nodes::TKeyword>
end
Expand Down

0 comments on commit 9fbf2f1

Please sign in to comment.