From beea28fdd19e752fce7441b82434abf61da64495 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Wed, 28 Aug 2024 19:27:03 -0400 Subject: [PATCH] nitcc: add AST transformation tests Signed-off-by: Jean Privat --- contrib/nitcc/tests/sav/trans2.input.res | 20 +++++++++++++++++++ contrib/nitcc/tests/sav/trans_token.input.res | 4 ++++ contrib/nitcc/tests/trans2.input | 1 + contrib/nitcc/tests/trans2.sablecc | 8 ++++++++ contrib/nitcc/tests/trans_token.input | 1 + contrib/nitcc/tests/trans_token.sablecc | 6 ++++++ 6 files changed, 40 insertions(+) create mode 100644 contrib/nitcc/tests/sav/trans2.input.res create mode 100644 contrib/nitcc/tests/sav/trans_token.input.res create mode 100644 contrib/nitcc/tests/trans2.input create mode 100644 contrib/nitcc/tests/trans2.sablecc create mode 100644 contrib/nitcc/tests/trans_token.input create mode 100644 contrib/nitcc/tests/trans_token.sablecc diff --git a/contrib/nitcc/tests/sav/trans2.input.res b/contrib/nitcc/tests/sav/trans2.input.res new file mode 100644 index 0000000000..241d41608c --- /dev/null +++ b/contrib/nitcc/tests/sav/trans2.input.res @@ -0,0 +1,20 @@ +Start + s_0 + s_0 + s_0 + s_0 + s_0 + s_1 + b_0 + 'x'@(1:1-1:2) + b_0 + 'x'@(1:2-1:3) + c_0 + 'y'@(1:3-1:4) + c_0 + 'y'@(1:4-1:5) + b_0 + 'x'@(1:5-1:6) + c_0 + 'y'@(1:6-1:7) + Eof@(1:7-1:7)='' diff --git a/contrib/nitcc/tests/sav/trans_token.input.res b/contrib/nitcc/tests/sav/trans_token.input.res new file mode 100644 index 0000000000..1fb1aac316 --- /dev/null +++ b/contrib/nitcc/tests/sav/trans_token.input.res @@ -0,0 +1,4 @@ +Start + p + a@(1:1-1:2)='a' + Eof@(1:2-1:2)='' diff --git a/contrib/nitcc/tests/trans2.input b/contrib/nitcc/tests/trans2.input new file mode 100644 index 0000000000..eaad3280de --- /dev/null +++ b/contrib/nitcc/tests/trans2.input @@ -0,0 +1 @@ +xxyyxy \ No newline at end of file diff --git a/contrib/nitcc/tests/trans2.sablecc b/contrib/nitcc/tests/trans2.sablecc new file mode 100644 index 0000000000..8c1ee10458 --- /dev/null +++ b/contrib/nitcc/tests/trans2.sablecc @@ -0,0 +1,8 @@ +Grammar trans; + +Parser + +s = s b | b; +a = ; +b {-> a} = 'x' | c {->}; +c {-> a} = 'y'; diff --git a/contrib/nitcc/tests/trans_token.input b/contrib/nitcc/tests/trans_token.input new file mode 100644 index 0000000000..2e65efe2a1 --- /dev/null +++ b/contrib/nitcc/tests/trans_token.input @@ -0,0 +1 @@ +a \ No newline at end of file diff --git a/contrib/nitcc/tests/trans_token.sablecc b/contrib/nitcc/tests/trans_token.sablecc new file mode 100644 index 0000000000..dda16d9182 --- /dev/null +++ b/contrib/nitcc/tests/trans_token.sablecc @@ -0,0 +1,6 @@ +Lexer +a = 'a'; + +Parser +p = q; +q {-> a} = a {->};