Skip to content

Commit

Permalink
added envs parser
Browse files Browse the repository at this point in the history
  • Loading branch information
izuzanak committed Nov 10, 2023
1 parent afd601e commit aa18956
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
38 changes: 38 additions & 0 deletions build/rules/envs.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#vim: set syntax=rules:

init_code: {}

terminals:
var {"${".(|:\}| + (':'.(|-\}| + e)))*.'\}'}
var_def {"${".|:\}|*.":-".|\}|*.'\}'}
escape {"$$"}
data {(|$| + ('$'.|${|)).|$|*}

$ !!! FIXME comment this terminal before production
_END_ {'\0'}

nonterminals:
<start>
<end_check>
<program>
<term_list>
<term>

rules:

<start> -> <end_check> ->> {}

$ !!! FIXME comment these two rules before production
<end_check> -> <program> _END_ ->> {}
<end_check> -> _END_ ->> {}

<program> -> <term_list> ->> {}

<term_list> -> <term_list> <term> ->> {}
<term_list> -> <term> ->> {}

<term> -> var ->> {print("var: '"..rule_body(0).."'");}
<term> -> var_def ->> {print("var_def: '"..rule_body(0).."'");}
<term> -> escape ->> {print("escape: '"..rule_body(0).."'");}
<term> -> data ->> {print("data: '"..rule_body(0).."'");}

18 changes: 18 additions & 0 deletions build/rules/envs.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"devices": [
"${DEVICE}",
"$${DEVICE}",
"$$${DEVICE}",
"$x{DEVICE}",
"$xx{DEVICE}",
"${DEVICEdefault}",
"${DEVICE:}",
"${DEVICE:default}",
"${DEVICE:-}",
"${DEVICE:-default}",
"${DEVICE:x-}",
"${DEVICE:x-default}",
"${DEVICE:}-}",
"${DEVICE:}-default}",
]
}
4 changes: 4 additions & 0 deletions build/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@
#echo "xpath1.rules" 1>&2
#./yapgen --parser_descr rules/camsys/xpath1.rules --source rules/camsys/xpath1.src

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

# - smtp -
#echo "smtp.rules" 1>&2
#./yapgen --parser_descr rules/smtp.rules --source rules/smtp.src
Expand Down

0 comments on commit aa18956

Please sign in to comment.