Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,46 @@ jobs:
fi
echo "[postfix-index] x[i]++ and x[i]-- change that element"

- name: "@PRE conditions on rule elements (#438) (Non-20.04)"
if: matrix.id != 'docker-ubuntu-20.04'
shell: bash
run: |
set -eo pipefail
# A @PRE condition can be written on the rule element itself (#438):
# _xWILD [plus varz="num"] is <n,n> varz("num"); in @PRE.
# Each case runs in both forms; their matches must agree.
FIX=.github/workflows/tests/element-pre
rm -rf "$FIX/logs" "$FIX/input/text.txt_log"
mkdir -p "$FIX/logs"
./bin/nlp -ANA "$FIX" -WORK ./ "$FIX/input/text.txt"
OUT="$FIX/input/text.txt_log/output.txt"
if [ ! -f "$OUT" ]; then
echo "FAIL(element-pre): no output.txt -- the analyzer did not build"; exit 1
fi
got=$(tr -d '\r' < "$OUT")
want=$(printf '%s\n' \
'vareq @PRE: two' \
'vareq elt : two' \
'varz @PRE: two Three ABC 3' \
'varz elt : two Three ABC 3' \
'two @PRE: one' \
'two elt : one' \
'flag @PRE: ABC' \
'flag elt : ABC' \
'cap @PRE: Three' \
'cap @PRE: ABC' \
'cap elt : Three' \
'cap elt : ABC' \
'range @PRE: 9' \
'range elt : 9' \
'regexp @PRE: two' \
'regexp elt : two' \
'mixed: one two')
if [ "$got" != "$want" ]; then
echo "FAIL(element-pre): output.txt was:"; echo "$got"; echo "wanted:"; echo "$want"; exit 1
fi
echo "[element-pre] element-key conditions match like @PRE"

- name: factorial() up to 20! (Non-20.04)
if: matrix.id != 'docker-ubuntu-20.04'
shell: bash
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,45 @@ jobs:
fi
echo "[postfix-index] x[i]++ and x[i]-- change that element"

- name: "@PRE conditions on rule elements (#438)"
shell: bash
run: |
set -eo pipefail
# A @PRE condition can be written on the rule element itself (#438):
# _xWILD [plus varz="num"] is <n,n> varz("num"); in @PRE.
# Each case runs in both forms; their matches must agree.
FIX=.github/workflows/tests/element-pre
rm -rf "$FIX/logs" "$FIX/input/text.txt_log"
mkdir -p "$FIX/logs"
./bin/Release/nlp.exe -ANA "$FIX" -WORK ./ "$FIX/input/text.txt"
OUT="$FIX/input/text.txt_log/output.txt"
if [ ! -f "$OUT" ]; then
echo "FAIL(element-pre): no output.txt -- the analyzer did not build"; exit 1
fi
got=$(tr -d '\r' < "$OUT")
want=$(printf '%s\n' \
'vareq @PRE: two' \
'vareq elt : two' \
'varz @PRE: two Three ABC 3' \
'varz elt : two Three ABC 3' \
'two @PRE: one' \
'two elt : one' \
'flag @PRE: ABC' \
'flag elt : ABC' \
'cap @PRE: Three' \
'cap @PRE: ABC' \
'cap elt : Three' \
'cap elt : ABC' \
'range @PRE: 9' \
'range elt : 9' \
'regexp @PRE: two' \
'regexp elt : two' \
'mixed: one two')
if [ "$got" != "$want" ]; then
echo "FAIL(element-pre): output.txt was:"; echo "$got"; echo "wanted:"; echo "$want"; exit 1
fi
echo "[element-pre] element-key conditions match like @PRE"

- name: factorial() up to 20!
shell: bash
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests/element-pre/input/text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
one two Three ABC 3 9
17 changes: 17 additions & 0 deletions .github/workflows/tests/element-pre/spec/analyzer.seq
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
tokenize nil #
nlp mark #
nlp vareq_pre #
nlp vareq_elt #
nlp varz_pre #
nlp varz_elt #
nlp two_pre #
nlp two_elt #
nlp flag_pre #
nlp flag_elt #
nlp cap_pre #
nlp cap_elt #
nlp range_pre #
nlp range_elt #
nlp regexp_pre #
nlp regexp_elt #
nlp mixed #
14 changes: 14 additions & 0 deletions .github/workflows/tests/element-pre/spec/cap_elt.nlp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
###############################################
# FILE: cap_elt.nlp
# SUBJ: cap on an alphabetic element. (element-key form)
# NOTE: Part of the element-pre regression (#438); expected output
# is in the CI step.
###############################################

@NODES _ROOT

@POST
"output.txt" << "cap elt : " << phrasetext() << "\n";
noop();
@RULES
_xNIL <- _xALPHA [cap] @@
16 changes: 16 additions & 0 deletions .github/workflows/tests/element-pre/spec/cap_pre.nlp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
###############################################
# FILE: cap_pre.nlp
# SUBJ: cap on an alphabetic element. (@PRE form)
# NOTE: Part of the element-pre regression (#438); expected output
# is in the CI step.
###############################################

@NODES _ROOT

@PRE
<1,1> cap();
@POST
"output.txt" << "cap @PRE: " << phrasetext() << "\n";
noop();
@RULES
_xNIL <- _xALPHA @@
14 changes: 14 additions & 0 deletions .github/workflows/tests/element-pre/spec/flag_elt.nlp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
###############################################
# FILE: flag_elt.nlp
# SUBJ: A bare action name with no arguments. (element-key form)
# NOTE: Part of the element-pre regression (#438); expected output
# is in the CI step.
###############################################

@NODES _ROOT

@POST
"output.txt" << "flag elt : " << phrasetext() << "\n";
noop();
@RULES
_xNIL <- _xALPHA [uppercase] @@
16 changes: 16 additions & 0 deletions .github/workflows/tests/element-pre/spec/flag_pre.nlp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
###############################################
# FILE: flag_pre.nlp
# SUBJ: A bare action name with no arguments. (@PRE form)
# NOTE: Part of the element-pre regression (#438); expected output
# is in the CI step.
###############################################

@NODES _ROOT

@PRE
<1,1> uppercase();
@POST
"output.txt" << "flag @PRE: " << phrasetext() << "\n";
noop();
@RULES
_xNIL <- _xALPHA @@
20 changes: 20 additions & 0 deletions .github/workflows/tests/element-pre/spec/mark.nlp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
###############################################
# FILE: mark.nlp
# SUBJ: Gives "two" pos=noun and "one" num=1.
# NOTE: Part of the element-pre regression (#438); expected output
# is in the CI step.
###############################################

@NODES _ROOT

@POST
N("pos",1) = "noun";
noop();
@RULES
_xNIL <- two @@

@POST
N("num",1) = 1;
noop();
@RULES
_xNIL <- one @@
16 changes: 16 additions & 0 deletions .github/workflows/tests/element-pre/spec/mixed.nlp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
###############################################
# FILE: mixed.nlp
# SUBJ: Element keys and a @PRE region in one rule.
# NOTE: Part of the element-pre regression (#438); expected output
# is in the CI step.
###############################################

@NODES _ROOT

@PRE
<3,3> var("pos");
@POST
"output.txt" << "mixed: " << phrasetext() << "\n";
noop();
@RULES
_xNIL <- _xALPHA [var="num"] _xWHITE [s] _xALPHA @@
14 changes: 14 additions & 0 deletions .github/workflows/tests/element-pre/spec/range_elt.nlp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
###############################################
# FILE: range_elt.nlp
# SUBJ: numrange on a number. (element-key form)
# NOTE: Part of the element-pre regression (#438); expected output
# is in the CI step.
###############################################

@NODES _ROOT

@POST
"output.txt" << "range elt : " << phrasetext() << "\n";
noop();
@RULES
_xNIL <- _xNUM [numrange=(5 10)] @@
16 changes: 16 additions & 0 deletions .github/workflows/tests/element-pre/spec/range_pre.nlp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
###############################################
# FILE: range_pre.nlp
# SUBJ: numrange on a number. (@PRE form)
# NOTE: Part of the element-pre regression (#438); expected output
# is in the CI step.
###############################################

@NODES _ROOT

@PRE
<1,1> numrange(5, 10);
@POST
"output.txt" << "range @PRE: " << phrasetext() << "\n";
noop();
@RULES
_xNIL <- _xNUM @@
14 changes: 14 additions & 0 deletions .github/workflows/tests/element-pre/spec/regexp_elt.nlp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
###############################################
# FILE: regexp_elt.nlp
# SUBJ: regexp (a glob match) on an alphabetic element. (element-key form)
# NOTE: Part of the element-pre regression (#438); expected output
# is in the CI step.
###############################################

@NODES _ROOT

@POST
"output.txt" << "regexp elt : " << phrasetext() << "\n";
noop();
@RULES
_xNIL <- _xALPHA [regexp="t*"] @@
16 changes: 16 additions & 0 deletions .github/workflows/tests/element-pre/spec/regexp_pre.nlp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
###############################################
# FILE: regexp_pre.nlp
# SUBJ: regexp (a glob match) on an alphabetic element. (@PRE form)
# NOTE: Part of the element-pre regression (#438); expected output
# is in the CI step.
###############################################

@NODES _ROOT

@PRE
<1,1> regexp("t*");
@POST
"output.txt" << "regexp @PRE: " << phrasetext() << "\n";
noop();
@RULES
_xNIL <- _xALPHA @@
14 changes: 14 additions & 0 deletions .github/workflows/tests/element-pre/spec/two_elt.nlp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
###############################################
# FILE: two_elt.nlp
# SUBJ: Two conditions on one element. (element-key form)
# NOTE: Part of the element-pre regression (#438); expected output
# is in the CI step.
###############################################

@NODES _ROOT

@POST
"output.txt" << "two elt : " << phrasetext() << "\n";
noop();
@RULES
_xNIL <- _xALPHA [var="num" varne=("pos" "noun")] @@
17 changes: 17 additions & 0 deletions .github/workflows/tests/element-pre/spec/two_pre.nlp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
###############################################
# FILE: two_pre.nlp
# SUBJ: Two conditions on one element. (@PRE form)
# NOTE: Part of the element-pre regression (#438); expected output
# is in the CI step.
###############################################

@NODES _ROOT

@PRE
<1,1> var("num");
<1,1> varne("pos", "noun");
@POST
"output.txt" << "two @PRE: " << phrasetext() << "\n";
noop();
@RULES
_xNIL <- _xALPHA @@
14 changes: 14 additions & 0 deletions .github/workflows/tests/element-pre/spec/vareq_elt.nlp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
###############################################
# FILE: vareq_elt.nlp
# SUBJ: vareq on an alphabetic element. (element-key form)
# NOTE: Part of the element-pre regression (#438); expected output
# is in the CI step.
###############################################

@NODES _ROOT

@POST
"output.txt" << "vareq elt : " << phrasetext() << "\n";
noop();
@RULES
_xNIL <- _xALPHA [vareq=("pos" "noun")] @@
16 changes: 16 additions & 0 deletions .github/workflows/tests/element-pre/spec/vareq_pre.nlp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
###############################################
# FILE: vareq_pre.nlp
# SUBJ: vareq on an alphabetic element. (@PRE form)
# NOTE: Part of the element-pre regression (#438); expected output
# is in the CI step.
###############################################

@NODES _ROOT

@PRE
<1,1> vareq("pos", "noun");
@POST
"output.txt" << "vareq @PRE: " << phrasetext() << "\n";
noop();
@RULES
_xNIL <- _xALPHA @@
14 changes: 14 additions & 0 deletions .github/workflows/tests/element-pre/spec/varz_elt.nlp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
###############################################
# FILE: varz_elt.nlp
# SUBJ: varz on a wildcard between two words (#449 behaviour). (element-key form)
# NOTE: Part of the element-pre regression (#438); expected output
# is in the CI step.
###############################################

@NODES _ROOT

@POST
"output.txt" << "varz elt : " << phrasetext() << "\n";
noop();
@RULES
_xNIL <- two _xWILD [plus varz="num"] 3 @@
16 changes: 16 additions & 0 deletions .github/workflows/tests/element-pre/spec/varz_pre.nlp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
###############################################
# FILE: varz_pre.nlp
# SUBJ: varz on a wildcard between two words (#449 behaviour). (@PRE form)
# NOTE: Part of the element-pre regression (#438); expected output
# is in the CI step.
###############################################

@NODES _ROOT

@PRE
<2,2> varz("num");
@POST
"output.txt" << "varz @PRE: " << phrasetext() << "\n";
noop();
@RULES
_xNIL <- two _xWILD [plus] 3 @@
Loading
Loading