Skip to content

Commit

Permalink
adjusted psql condition parser
Browse files Browse the repository at this point in the history
  • Loading branch information
izuzanak committed Jan 6, 2025
1 parent 10ae132 commit bd38f74
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions build/rules/psql_condition.rules
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ terminals:

id {('_'+l).('_'+l+d)*}

equal {"="}
exclamation_equal {"!="}
equal {"="+"=="}
exclamation_equal {"!="+"<>"}
rs_br {'>'}
ls_br {'<'}
rs_br_equal {">="}
ls_br_equal {"<="}
contains {"has"+"contains"+"like"+"HAS"+"CONTAINS"+"LIKE"}

and {"&&"+"and"+"AND"}
or {"||"+"or"+"OR"}
Expand Down Expand Up @@ -48,6 +49,7 @@ rules:
<cond> -> <id> ls_br <const> ->> {print("operator <")}
<cond> -> <id> rs_br_equal <const> ->> {print("operator >=")}
<cond> -> <id> ls_br_equal <const> ->> {print("operator <=")}
<cond> -> <id> contains <const> ->> {print("operator contains")}

<cond> -> lr_br <cond_list> rr_br ->> {}

Expand Down
6 changes: 5 additions & 1 deletion build/rules/psql_condition.src
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
-- system = '03' or system = '02' and carrier = 10
-- carrier = 10 and (system = '03' or system = '02')
-- carrier = 10 AND (system = '03' OR system = '02')
carrier = 10 && (system = '03' || system = '02')
-- carrier = 10 && (system = '03' || system = '02')
-- carrier == 10
-- carrier <> 10 OR carrier != 9
-- system has '1' OR system contains '1' OR system like '%1%'
system HAS '1' OR system CONTAINS '1' OR system LIKE '%1%'

2 changes: 1 addition & 1 deletion build/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# - psql_condition -
#echo "psql_condition.rules" 1>&2
./yapgen --parser_descr rules/psql_condition.rules --source rules/psql_condition.src
#./yapgen --parser_descr rules/psql_condition.rules --source rules/psql_condition.src

# - momas_log parser-
#echo "momas_log.rules" 1>&2
Expand Down

0 comments on commit bd38f74

Please sign in to comment.