Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panc: Adjust grammar to allow a single trailing comma in choice types #272

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion panc/src/main/jjtree/PanParser.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ org.quattor.pan.ttemplate.SourceRange typeSpec() #TypeSpec :
org.quattor.pan.ttemplate.SourceRange baseTypeSpec() #BaseTypeSpec :
{ Token t = null, b=null, e=null; org.quattor.pan.utils.Range r = null; }
{
t=<CHOICE> <LPAREN> stringLiteral() (<COMMA> stringLiteral())* e=<RPAREN>
t=<CHOICE> <LPAREN> stringLiteral() (LOOKAHEAD(2) <COMMA> stringLiteral())* [ <COMMA> ] e=<RPAREN>
{
jjtThis.setIdentifier(t.image);
jjtThis.setSourceRange(PanParserUtils.sourceRangeFromTokens(t,(e!=null)?e:t));
Expand Down
7 changes: 6 additions & 1 deletion panc/src/test/pan/Functionality/choice/choice18.pan
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

object template choice18;

type mychoice = choice("aa", "bb", "aaa", "bbb");
type mychoice = choice(
"aa",
"bb",
"aaa",
"bbb",
);
bind '/x' = mychoice with length(SELF) == 3;
'/x' = "aaa";
7 changes: 6 additions & 1 deletion panc/src/test/pan/Functionality/choice/choice19.pan
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

object template choice19;

type mychoice = choice("aa", "bb", "aaa", "bbb");
type mychoice = choice(
"aa",
"bb",
"aaa",
"bbb",
);
bind '/x' = mychoice with length(SELF) == 3;
'/x' = "aa";
7 changes: 6 additions & 1 deletion panc/src/test/pan/Functionality/choice/choice20.pan
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

object template choice20;

type mychoice = choice("aa", "bb", "aaa", "bbb");
type mychoice = choice(
"aa",
"bb",
"aaa",
"bbb",
);
bind '/x' = mychoice with length(SELF) == 3;
'/x' = "ddd";
9 changes: 7 additions & 2 deletions panc/src/test/pan/Functionality/choice/choice21.pan
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

object template choice21;

type mychoice = choice("aa", "bb", "aaa", "bbb");
type mychoice = choice(
"aa",
"bb",
"aaa",
"bbb",
);
bind '/x' = mychoice(3);
'/x' = "aaa";
'/x' = "aaa";
9 changes: 7 additions & 2 deletions panc/src/test/pan/Functionality/choice/choice22.pan
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@

object template choice22;

type mychoice = choice("aa", "bb", "aaa", "bbb");
type mychoice = choice(
"aa",
"bb",
"aaa",
"bbb",
);
bind '/x' = mychoice(3);
'/x' = "aa";
'/x' = "aa";
Loading