Skip to content

Commit

Permalink
rework antlr
Browse files Browse the repository at this point in the history
  • Loading branch information
jchambers-ln committed Mar 26, 2024
1 parent cd167cb commit b8bf3c8
Show file tree
Hide file tree
Showing 11 changed files with 841 additions and 721 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ opts:
opt:
maxlength
| maxcount
| setdefaultvalall
| setdefaultval
| defaultval
| xpath
Expand Down Expand Up @@ -106,7 +107,10 @@ xmldefaultval:
;

setdefaultval:
('DEFAULT' OPAREN OSQUARE STRING CSQUARE CPAREN | 'DEFAULT' OPAREN SETSTRING CPAREN)
'DEFAULT' OPAREN SETSTRING CPAREN
;
setdefaultvalall:
'DEFAULT' OPAREN 'ALL' CPAREN
;

annotation_name : ATOKEN;
Expand Down Expand Up @@ -137,10 +141,11 @@ DATASET_SYM : 'DATASET';
WS : [ \t\r\n] -> skip;
INT : [0-9]+ ;
fragment ESCAPED_QUOTE : '\\\'';
SETSTRING : '[\'' ( ESCAPED_QUOTE | ~('\'') )* '\']';
SETSTRING : '[\'' ( ESCAPED_QUOTE | SETTOKEN | ('\'') | ~(']'))* '\']';
STRING : '\'' ( ESCAPED_QUOTE | ~('\'') )* '\'';
ATOKEN: [@][a-zA-Z0-9_-]+[a-zA-Z0-9_];
TOKEN : ~[_\r\n\t; (),:={}-]~[\r\n \t;(),:={}-]* ;
UTOKEN: [_]+[a-zA-Z0-9_-]+[a-zA-Z0-9_];
ECL_NUMBERED_TYPE: TOKEN INT?;
SETTOKEN: [a-zA-Z0-9,_-];

Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,23 @@ else if (currentrec != null)
}
}


@Override
public void enterSetdefaultvalall(EclRecordParser.SetdefaultvalallContext ctx) {
String val = ctx.getChild(2).getText();
val = val.replace("'", "");

if (currentfield != null)
{
currentfield.setColumnValue(val);
}
else if (currentrec != null)
{
currentrec.setColumnValue(val);
}
}


/**
* {@inheritDoc}
*
Expand All @@ -407,9 +424,28 @@ else if (currentrec != null)
public void enterSetdefaultval(EclRecordParser.SetdefaultvalContext ctx)
{
String val = ctx.getChild(2).getText();
val = val.replace("['", "");
if(val.length() >= 2){
if(val.substring(0, 2).equals("['")) {
val = val.substring(2, val.length());
}
}
if(val.length() >= 2){
if(val.substring(val.length()-2, val.length()).equals("']")) {
val = val.substring(0, val.length() - 2);
}
}
//val = val.replaceFirst("(\[')", "");
//val = val.replace("['", "");
val = val.replace("']", "");

if(val.contains("','")){
if(!val.startsWith("'")) {
val = "'" + val;
}
if(!val.endsWith("'")){
val = val + "'";
}
}
if (currentfield != null)
{
currentfield.setColumnValue(val);
Expand All @@ -418,6 +454,8 @@ else if (currentrec != null)
{
currentrec.setColumnValue(val);
}


}

/**
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ T__11=12
T__12=13
T__13=14
T__14=15
QUOTE=16
T__15=16
OSQUARE=17
CSQUARE=18
OPAREN=19
Expand All @@ -35,6 +35,7 @@ ATOKEN=34
TOKEN=35
UTOKEN=36
ECL_NUMBERED_TYPE=37
SETTOKEN=38
'SET OF'=1
'set of'=2
'MAXLENGTH'=3
Expand All @@ -47,10 +48,10 @@ ECL_NUMBERED_TYPE=37
'DEFAULT'=10
'XPATH'=11
'XMLDEFAULT'=12
'//'=13
'/*'=14
'*/'=15
'\''=16
'ALL'=13
'//'=14
'/*'=15
'*/'=16
'['=17
']'=18
'('=19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,18 @@ public class EclRecordBaseListener implements EclRecordListener {
* <p>The default implementation does nothing.</p>
*/
@Override public void exitSetdefaultval(EclRecordParser.SetdefaultvalContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterSetdefaultvalall(EclRecordParser.SetdefaultvalallContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitSetdefaultvalall(EclRecordParser.SetdefaultvalallContext ctx) { }
/**
* {@inheritDoc}
*
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ T__11=12
T__12=13
T__13=14
T__14=15
QUOTE=16
T__15=16
OSQUARE=17
CSQUARE=18
OPAREN=19
Expand All @@ -35,6 +35,7 @@ ATOKEN=34
TOKEN=35
UTOKEN=36
ECL_NUMBERED_TYPE=37
SETTOKEN=38
'SET OF'=1
'set of'=2
'MAXLENGTH'=3
Expand All @@ -47,10 +48,10 @@ ECL_NUMBERED_TYPE=37
'DEFAULT'=10
'XPATH'=11
'XMLDEFAULT'=12
'//'=13
'/*'=14
'*/'=15
'\''=16
'ALL'=13
'//'=14
'/*'=15
'*/'=16
'['=17
']'=18
'('=19
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,16 @@ public interface EclRecordListener extends ParseTreeListener {
* @param ctx the parse tree
*/
void exitSetdefaultval(EclRecordParser.SetdefaultvalContext ctx);
/**
* Enter a parse tree produced by {@link EclRecordParser#setdefaultvalall}.
* @param ctx the parse tree
*/
void enterSetdefaultvalall(EclRecordParser.SetdefaultvalallContext ctx);
/**
* Exit a parse tree produced by {@link EclRecordParser#setdefaultvalall}.
* @param ctx the parse tree
*/
void exitSetdefaultvalall(EclRecordParser.SetdefaultvalallContext ctx);
/**
* Enter a parse tree produced by {@link EclRecordParser#annotation_name}.
* @param ctx the parse tree
Expand Down
Loading

0 comments on commit b8bf3c8

Please sign in to comment.