From aa18956bb7f31f2a658e49a0afbafda40ebf4bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Zuza=C5=88=C3=A1k?= Date: Fri, 10 Nov 2023 14:51:47 +0100 Subject: [PATCH] added envs parser --- build/rules/envs.rules | 38 ++++++++++++++++++++++++++++++++++++++ build/rules/envs.src | 18 ++++++++++++++++++ build/run.sh | 4 ++++ 3 files changed, 60 insertions(+) create mode 100644 build/rules/envs.rules create mode 100644 build/rules/envs.src diff --git a/build/rules/envs.rules b/build/rules/envs.rules new file mode 100644 index 0000000..0405742 --- /dev/null +++ b/build/rules/envs.rules @@ -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: + + + + + + +rules: + + -> ->> {} + + $ !!! FIXME comment these two rules before production + -> _END_ ->> {} + -> _END_ ->> {} + + -> ->> {} + + -> ->> {} + -> ->> {} + + -> var ->> {print("var: '"..rule_body(0).."'");} + -> var_def ->> {print("var_def: '"..rule_body(0).."'");} + -> escape ->> {print("escape: '"..rule_body(0).."'");} + -> data ->> {print("data: '"..rule_body(0).."'");} + diff --git a/build/rules/envs.src b/build/rules/envs.src new file mode 100644 index 0000000..7f293bf --- /dev/null +++ b/build/rules/envs.src @@ -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}", + ] +} diff --git a/build/run.sh b/build/run.sh index b9b930c..bb2892c 100755 --- a/build/run.sh +++ b/build/run.sh @@ -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