Skip to content

Commit

Permalink
beliebige Reihenfolge der Abstands-Optionen: WIP.
Browse files Browse the repository at this point in the history
Change-Id: Icd84e7d65a15f35283995e93e3bd61eda19d657d
  • Loading branch information
Bodmo committed Nov 29, 2023
1 parent 760fe93 commit f6e477c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
48 changes: 35 additions & 13 deletions src/main/antlr/cosmas/c2ps_opPROX.g
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ tokens { PROX_OPTS;
DISTVALUE
: ('0' .. '9')+ ;

DISTOPTS
: ('s'|'p'|'w'|'t'|'+'|'-')+;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//
// PROX-Parser
Expand All @@ -52,46 +55,65 @@ proxDist: proxDirection (v1=proxDistValue m1=proxMeasure | m2=proxMeasure v2=pro
-> ^(DIST {$proxDirection.tree} {$v2.tree} {$m2.tree});
*/

// +++ new version 29.11.23 by including all possible option ordering +++ //
/*
proxDist:
proxDirection v1=proxDistValue m1=proxMeasure
-> ^(DIST {$proxDirection.tree} {$v1.tree} {$m1.tree})
| proxDirection m1=proxMeasure v1=proxDistValue
-> ^(DIST {$proxDirection.tree} {$v1.tree} {$m1.tree})
| m1=proxMeasure d1=proxDirection v1=proxDistValue
-> ^(DIST {$d1.tree} {$v1.tree} {$m1.tree})
| m1=proxMeasure v1=proxDistValue d1=proxDirection
-> ^(DIST {$d1.tree} {$v1.tree} {$m1.tree})
| v1=proxDistValue m1=proxMeasure d1=proxDirection
-> ^(DIST {$d1.tree} {$v1.tree} {$m1.tree})
| v1=proxDistValue d1=proxDirection m1=proxMeasure
-> ^(DIST {$d1.tree} {$v1.tree} {$m1.tree});
*/

// new version: accepts any order (28.11.23/FB):

/*
proxDist: ('s'|'w'|'p'|'t'|'+'|'-'|DISTVALUE)+
proxDist: (DISTOPTS|DISTVALUE)+

-> {c2ps_opPROX.encode($proxDist.text, DIST)};
*/

// new version: just use the grammar another way (28.11.23/FB):

proxDist: (d=proxDirection|v=proxDistValue|m=proxMeasure)+
//-> {$v.tree != null && $m.tree != null} ? ^(DIST DIST); //{c2ps_opPROX.encodeDIST(DIR, $d.tree, $m.tree, $v.tree)} );
-> {c2ps_opPROX.encodeDIST(DIST, $d.tree, $m.tree, $v.tree)};

//+++++++++ new version: accepts options in any order (28.11.23/FB): +++++++ //
// -> {$v.tree != null && $m.tree != null} ? ^(DIST DIST); //{c2ps_opPROX.encodeDIST(DIR, $d.tree, $m.tree, $v.tree)} );
/*
proxDist: (m=proxMeasure|d=proxDirection|v=proxDistValue)+

-> {c2ps_opPROX.encodeDIST(DIST, $m.tree, $m.tree, $m.tree)};
*/
/* old rule for optional direction with default setting:
proxDirection:
(p='+'|m='-')? -> {$p != null}? ^(DIR PLUS)
-> {$m != null}? ^(DIR MINUS)
-> ^(DIR BOTH) ;
*/

// new rule with default setting. Default tree for direction set in c2ps_opPROX.encode():
// new rule accepts + and -. Default tree for direction is set in c2ps_opPROX.encode():
// 28.11.23/FB

/*
proxDirection
: '+' -> ^(DIR PLUS)
| '-' -> ^(DIR MINUS);

*/
/*
proxDistValue // proxDistMin ( ':' proxDistMax)? ;
: (m1=proxDistMin -> ^(DIST_RANGE VAL0 $m1)) (':' m2=proxDistMax -> ^(DIST_RANGE $m1 $m2))? ;
*/

// proxDistMin ( ':' proxDistMax)? ;
/*
proxDistValue
: (m1=proxDistMin ) (':' m2=proxDistMax)?

-> {$m2.text != null}? ^(RANGE $m1 $m2)
-> ^(RANGE VAL0 $m1);

*/
/*
proxMeasure
: (m='w'|m='s'|m='p'|m='t') -> ^(MEAS $m);

Expand All @@ -100,7 +122,7 @@ proxDistMin

proxDistMax
: DISTVALUE;

*/
proxGroup
: 'min' -> ^(GRP MIN)
| 'max' -> ^(GRP MAX);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ public static Tree encodeDefautDir(String input, int type)
} // encode

/* encodeDefaultDir():
* - return a tree containing the default Prox Direction when there is no
* direction indication in the input query.
* - returns a CommonTree built of out Direction/Measure/Distance value.
* - accepts options in any order.
* - creates CommonTree in that order: Direction .. Distance value .. Measure.
* - sets default direction to BOTH if not set yet.
* 28.11.23/FB
*/

Expand Down

0 comments on commit f6e477c

Please sign in to comment.