summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2020-03-08 23:29:57 +0200
committerAdrian Thurston <thurston@colm.net>2020-03-08 23:53:25 +0200
commit78e7949ca590b273c2c152a0abe0d51e590a52fd (patch)
treec253c852aec77af8a04c24d921d8657ff29c4101 /test
parent5718c319424a21b64e1b50dbb6aae644715b9e85 (diff)
downloadcolm-78e7949ca590b273c2c152a0abe0d51e590a52fd.tar.gz
remove the ragel tests, export runtests for use by ragel
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am4
-rw-r--r--test/ragel.d/.gitignore34
-rw-r--r--test/ragel.d/Makefile.am87
-rw-r--r--test/ragel.d/README11
-rw-r--r--test/ragel.d/any1.rl17
-rw-r--r--test/ragel.d/args1.rl94
-rw-r--r--test/ragel.d/args2.rl94
-rw-r--r--test/ragel.d/argsinc.rl11
-rw-r--r--test/ragel.d/atoi1.rl67
-rw-r--r--test/ragel.d/atoi2.rl81
-rw-r--r--test/ragel.d/atoi3.rl74
-rw-r--r--test/ragel.d/atoi4.rl73
-rw-r--r--test/ragel.d/atoi5.rl266
-rw-r--r--test/ragel.d/awkemu.rl154
-rw-r--r--test/ragel.d/buffer.h57
-rw-r--r--test/ragel.d/builtin.rl1208
-rw-r--r--test/ragel.d/call1.rl101
-rw-r--r--test/ragel.d/call2.rl116
-rw-r--r--test/ragel.d/call3.rl122
-rw-r--r--test/ragel.d/call4.rl39
-rw-r--r--test/ragel.d/caseindep.rl54
-rw-r--r--test/ragel.d/clang1.rl282
-rw-r--r--test/ragel.d/clang2.rl323
-rw-r--r--test/ragel.d/clang3.rl319
-rw-r--r--test/ragel.d/clang4.rl187
-rw-r--r--test/ragel.d/clang5.rl151
-rw-r--r--test/ragel.d/cond1.rl84
-rw-r--r--test/ragel.d/cond10.rl79
-rw-r--r--test/ragel.d/cond11.rl40
-rw-r--r--test/ragel.d/cond2.rl90
-rw-r--r--test/ragel.d/cond3.rl58
-rw-r--r--test/ragel.d/cond4.rl53
-rw-r--r--test/ragel.d/cond5.rl58
-rw-r--r--test/ragel.d/cond6.rl60
-rw-r--r--test/ragel.d/cond7.rl80
-rw-r--r--test/ragel.d/cond8.rl55
-rw-r--r--test/ragel.d/cond9.rl292
-rw-r--r--test/ragel.d/conderr1.rl61
-rw-r--r--test/ragel.d/conderr2.rl36
-rw-r--r--test/ragel.d/condrep1.rl117
-rw-r--r--test/ragel.d/condrep2.rl117
-rw-r--r--test/ragel.d/condrep3.rl115
-rw-r--r--test/ragel.d/condrep4.rl115
-rw-r--r--test/ragel.d/condrep5.rl68
-rw-r--r--test/ragel.d/cppscan1.h112
-rw-r--r--test/ragel.d/cppscan1.rl311
-rw-r--r--test/ragel.d/cppscan2.rl403
-rw-r--r--test/ragel.d/cppscan3.rl284
-rw-r--r--test/ragel.d/cppscan4.rl301
-rw-r--r--test/ragel.d/cppscan5.rl273
-rw-r--r--test/ragel.d/cppscan6.rl360
-rw-r--r--test/ragel.d/crack1.rl39
-rw-r--r--test/ragel.d/curs1.rl34
-rw-r--r--test/ragel.d/element1.rl107
-rw-r--r--test/ragel.d/element2.rl82
-rw-r--r--test/ragel.d/element3.rl143
-rw-r--r--test/ragel.d/empty1.rl15
-rw-r--r--test/ragel.d/eofact.h9
-rw-r--r--test/ragel.d/eofact.rl51
-rw-r--r--test/ragel.d/eofcall1.rl106
-rw-r--r--test/ragel.d/eofcall2.rl106
-rw-r--r--test/ragel.d/eofgoto1.rl104
-rw-r--r--test/ragel.d/eofgoto2.rl103
-rw-r--r--test/ragel.d/eofret1.rl107
-rw-r--r--test/ragel.d/erract1.rl144
-rw-r--r--test/ragel.d/erract2.rl90
-rw-r--r--test/ragel.d/erract3.rl103
-rw-r--r--test/ragel.d/erract4.rl134
-rw-r--r--test/ragel.d/erract5.rl144
-rw-r--r--test/ragel.d/erract6.rl81
-rw-r--r--test/ragel.d/erract7.rl41
-rw-r--r--test/ragel.d/erract8.rl43
-rw-r--r--test/ragel.d/erract9.rl43
-rw-r--r--test/ragel.d/export1.rl58
-rw-r--r--test/ragel.d/export2.rl56
-rw-r--r--test/ragel.d/export3.rl52
-rw-r--r--test/ragel.d/export4.rl58
-rw-r--r--test/ragel.d/fbreak1.rl56
-rw-r--r--test/ragel.d/fnext1.rl81
-rw-r--r--test/ragel.d/fnext2.rl81
-rw-r--r--test/ragel.d/fnext3.rl81
-rw-r--r--test/ragel.d/forder1.rl97
-rw-r--r--test/ragel.d/forder2.rl132
-rw-r--r--test/ragel.d/forder3.rl106
-rw-r--r--test/ragel.d/genrep1.rl112
-rw-r--r--test/ragel.d/genrep2.rl124
-rw-r--r--test/ragel.d/genrep3.rl623
-rw-r--r--test/ragel.d/genrep4.rl188
-rw-r--r--test/ragel.d/genrep5.rl123
-rw-r--r--test/ragel.d/genrep6.rl178
-rw-r--r--test/ragel.d/genrep7.rl121
-rw-r--r--test/ragel.d/genrep8.rl121
-rw-r--r--test/ragel.d/gentests.sh506
-rw-r--r--test/ragel.d/goto1.rl37
-rw-r--r--test/ragel.d/gotocallret1.rl117
-rw-r--r--test/ragel.d/gotocallret2.rl78
-rw-r--r--test/ragel.d/gotocallret3.rl122
-rw-r--r--test/ragel.d/high1.rl179
-rw-r--r--test/ragel.d/high2.rl102
-rw-r--r--test/ragel.d/high3.rl111
-rw-r--r--test/ragel.d/import1.rl73
-rw-r--r--test/ragel.d/import2.h13
-rw-r--r--test/ragel.d/import2.rl24
-rw-r--r--test/ragel.d/include1.rl28
-rw-r--r--test/ragel.d/include2.rl51
-rw-r--r--test/ragel.d/include3.rl6
-rw-r--r--test/ragel.d/include3/smtp_addr_parser.rl17
-rw-r--r--test/ragel.d/include3/smtp_address.rl8
-rw-r--r--test/ragel.d/include3/smtp_ip.rl4
-rw-r--r--test/ragel.d/include3/smtp_whitespace.rl4
-rw-r--r--test/ragel.d/java1.rl47
-rw-r--r--test/ragel.d/java2.rl50
-rw-r--r--test/ragel.d/julia1.rl34
-rw-r--r--test/ragel.d/keller1.rl1074
-rw-r--r--test/ragel.d/lmgoto.rl197
-rw-r--r--test/ragel.d/lmnfa1.rl28
-rw-r--r--test/ragel.d/mailbox1.h33
-rw-r--r--test/ragel.d/mailbox1.rl265
-rw-r--r--test/ragel.d/mailbox2.rl171
-rw-r--r--test/ragel.d/mailbox3.rl245
-rw-r--r--test/ragel.d/main.c16
-rw-r--r--test/ragel.d/minimize1.rl80
-rw-r--r--test/ragel.d/ncall1.rl38
-rw-r--r--test/ragel.d/next1.rl36
-rw-r--r--test/ragel.d/next2.rl64
-rw-r--r--test/ragel.d/nfa1.rl145
-rw-r--r--test/ragel.d/nfa2.rl296
-rw-r--r--test/ragel.d/nfa3.rl110
-rw-r--r--test/ragel.d/noignore.rl68
-rw-r--r--test/ragel.d/patact.rl100
-rw-r--r--test/ragel.d/perftest38
-rw-r--r--test/ragel.d/range.rl73
-rw-r--r--test/ragel.d/rangei.rl28
-rw-r--r--test/ragel.d/recdescent1.rl129
-rw-r--r--test/ragel.d/recdescent2.rl117
-rw-r--r--test/ragel.d/recdescent4.rl129
-rw-r--r--test/ragel.d/recdescent5.rl116
-rw-r--r--test/ragel.d/repetition.rl292
-rw-r--r--test/ragel.d/rlscan.rl353
-rw-r--r--test/ragel.d/rpn1.rl110
-rw-r--r--test/ragel.d/ruby1.rl55
-rw-r--r--test/ragel.d/rust1.rl39
-rw-r--r--test/ragel.d/scan1.rl71
-rw-r--r--test/ragel.d/scan2.rl34
-rw-r--r--test/ragel.d/scan3.rl33
-rw-r--r--test/ragel.d/scan4.rl34
-rw-r--r--test/ragel.d/scan5.rl88
-rw-r--r--test/ragel.d/scan6.rl62
-rw-r--r--test/ragel.d/scan7.rl155
-rw-r--r--test/ragel.d/stateact1.rl47
-rw-r--r--test/ragel.d/statechart1.rl99
-rw-r--r--test/ragel.d/strings1.rl201
-rw-r--r--test/ragel.d/strings2.h9
-rw-r--r--test/ragel.d/strings2.rl1369
-rw-r--r--test/ragel.d/strings3.rl1434
-rw-r--r--test/ragel.d/targs1.rl35
-rw-r--r--test/ragel.d/tofrom1.rl351
-rw-r--r--test/ragel.d/tofrom2.rl178
-rw-r--r--test/ragel.d/tokstart1.rl243
-rw-r--r--test/ragel.d/trans-asm.lm647
-rw-r--r--test/ragel.d/trans-c.lm353
-rw-r--r--test/ragel.d/trans-crack.lm349
-rw-r--r--test/ragel.d/trans-csharp.lm354
-rw-r--r--test/ragel.d/trans-d.lm345
-rw-r--r--test/ragel.d/trans-go.lm345
-rw-r--r--test/ragel.d/trans-java.lm353
-rw-r--r--test/ragel.d/trans-julia.lm342
-rw-r--r--test/ragel.d/trans-ocaml.lm371
-rw-r--r--test/ragel.d/trans-ruby.lm343
-rw-r--r--test/ragel.d/trans-rust.lm352
-rw-r--r--test/ragel.d/trans.lm493
-rw-r--r--test/ragel.d/union.rl196
-rw-r--r--test/ragel.d/url1.rl540
-rw-r--r--test/ragel.d/xml.rl104
-rw-r--r--test/ragel.d/xmlcommon.rl205
-rw-r--r--test/ragel.d/zlen1.rl15
176 files changed, 3 insertions, 28128 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 1846642f..5220fe30 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,7 +1,9 @@
-SUBDIRS = . aapl.d colm.d ragel.d rlhc.d rlparse.d trans.d
+SUBDIRS = . aapl.d colm.d rlhc.d rlparse.d trans.d
noinst_SCRIPTS = subject.mk subject.sh
+data_DATA = runtests
+
EXTRA_DIST = subject.mk.in subject.sh.in runtests
subject.mk: subject.mk.in Makefile
diff --git a/test/ragel.d/.gitignore b/test/ragel.d/.gitignore
deleted file mode 100644
index ee2d6d6e..00000000
--- a/test/ragel.d/.gitignore
+++ /dev/null
@@ -1,34 +0,0 @@
-/Makefile.in
-/Makefile
-
-/aclocal.m4
-/autom4te.cache/
-/config.log
-/config.status
-/configure
-/stamp-h1
-
-/compile
-/depcomp
-/install-sh
-/missing
-/test-driver
-
-/working
-
-/gentests
-
-/.deps
-/trans
-/trans.c
-/*.o
-
-/config.h
-/config.h.in
-/config.h.in~
-/stamp-h1
-
-/subject.mk
-/subject.sh
-
-/.libs
diff --git a/test/ragel.d/Makefile.am b/test/ragel.d/Makefile.am
deleted file mode 100644
index 84e6a159..00000000
--- a/test/ragel.d/Makefile.am
+++ /dev/null
@@ -1,87 +0,0 @@
-#
-# Copyright 2002-2014 Adrian Thurston <thurston@complang.org>
-#
-
-# This file is part of Ragel.
-#
-# Ragel is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Ragel is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ragel; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-COLM_BIN = ../../colm/colm
-RAGEL_LM = ../../ragel
-
-COLM_xCPPFLAGS = -I../../colm/include
-COLM_xLDFLAGS = -L../../colm
-
-TESTS = gentests
-
-noinst_SCRIPTS = gentests
-noinst_PROGRAMS = trans
-
-EXTRA_DIST = \
- gentests.sh trans.lm \
- trans-asm.lm trans-d.lm trans-ocaml.lm \
- trans-c.lm trans-go.lm trans-ruby.lm \
- trans-crack.lm trans-java.lm trans-rust.lm \
- trans-csharp.lm trans-julia.lm \
- any1.rl args1.rl args2.rl argsinc.rl atoi1.rl atoi2.rl atoi3.rl \
- atoi4.rl atoi5.rl awkemu.rl buffer.h builtin.rl call1.rl call2.rl \
- call3.rl call4.rl caseindep.rl clang1.rl clang2.rl clang3.rl \
- clang4.rl clang5.rl cond10.rl cond11.rl cond1.rl cond2.rl cond3.rl \
- cond4.rl cond5.rl cond6.rl cond7.rl cond8.rl cond9.rl conderr1.rl \
- conderr2.rl condrep1.rl condrep2.rl condrep3.rl condrep4.rl condrep5.rl \
- cppscan1.h cppscan1.rl cppscan2.rl cppscan3.rl cppscan4.rl cppscan5.rl \
- cppscan6.rl crack1.rl curs1.rl element1.rl element2.rl element3.rl \
- empty1.rl eofact.h eofact.rl eofcall1.rl eofcall2.rl eofgoto1.rl \
- eofgoto2.rl eofret1.rl erract1.rl erract2.rl erract3.rl erract4.rl \
- erract5.rl erract6.rl erract7.rl erract8.rl erract9.rl export1.rl \
- export2.rl export3.rl export4.rl fnext1.rl fnext2.rl fnext3.rl forder1.rl \
- forder2.rl forder3.rl genrep1.rl genrep2.rl genrep3.rl genrep4.rl \
- genrep5.rl genrep6.rl genrep7.rl genrep8.rl goto1.rl gotocallret1.rl \
- gotocallret2.rl gotocallret3.rl high1.rl high2.rl high3.rl import1.rl \
- import2.h import2.rl include1.rl include2.rl include3.rl \
- include3/smtp_address.rl include3/smtp_addr_parser.rl \
- include3/smtp_ip.rl include3/smtp_whitespace.rl \
- java1.rl java2.rl julia1.rl keller1.rl lmgoto.rl lmnfa1.rl mailbox1.h \
- mailbox1.rl mailbox2.rl mailbox3.rl minimize1.rl ncall1.rl next1.rl \
- next2.rl nfa1.rl nfa2.rl nfa3.rl noignore.rl patact.rl rangei.rl \
- range.rl recdescent1.rl recdescent2.rl recdescent4.rl recdescent5.rl \
- repetition.rl rlscan.rl rpn1.rl ruby1.rl rust1.rl scan1.rl scan2.rl \
- scan3.rl scan4.rl scan5.rl scan6.rl scan7.rl stateact1.rl \
- statechart1.rl strings1.rl strings2.h strings2.rl strings3.rl targs1.rl \
- tofrom1.rl tofrom2.rl tokstart1.rl union.rl url1.rl xmlcommon.rl xml.rl \
- zlen1.rl
-
-CLEANFILES = working
-
-TRANS_DEPS = \
- $(RAGEL_LM)/ragel.lm \
- trans-c.lm trans-asm.lm \
- trans-crack.lm trans-csharp.lm \
- trans-d.lm trans-go.lm \
- trans-java.lm trans-julia.lm \
- trans-ocaml.lm trans-ruby.lm \
- trans-rust.lm
-
-trans_CPPFLAGS = $(COLM_xCPPFLAGS)
-trans_SOURCES = trans.c main.c
-trans_LDADD = -lcolm
-trans_LDFLAGS = $(COLM_xLDFLAGS)
-
-trans.c: trans.lm $(TRANS_DEPS) $(COLM_BIN)
- $(COLM_BIN) -c -b trans_object -I$(RAGEL_LM) -I../../ragel/host-go -o $@ $<
-
-gentests: gentests.sh Makefile
- @$(top_srcdir)/sedsubst $< $@ -w,+x $(SED_SUBST)
-
diff --git a/test/ragel.d/README b/test/ragel.d/README
deleted file mode 100644
index afebb52f..00000000
--- a/test/ragel.d/README
+++ /dev/null
@@ -1,11 +0,0 @@
-README
-======
-
-The test suite depends on Colm. Tests are now being written in a fictional
-mini-language designed for the purpose of testing ragel. The host language
-test-cases are then generated using a Colm Program. This allows one test case
-to be run against all host languages in addition to all code generation styles.
-
-It is possible to soft-link to external test directories. The external
-directory should have a 'runtests' program.
-
diff --git a/test/ragel.d/any1.rl b/test/ragel.d/any1.rl
deleted file mode 100644
index 81ec713c..00000000
--- a/test/ragel.d/any1.rl
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * @LANG: indep
- */
-
-%%{
- machine any1;
- main := any;
-}%%
-
-##### INPUT #####
-""
-"x"
-"xx"
-##### OUTPUT #####
-FAIL
-ACCEPT
-FAIL
diff --git a/test/ragel.d/args1.rl b/test/ragel.d/args1.rl
deleted file mode 100644
index e4f8332d..00000000
--- a/test/ragel.d/args1.rl
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * @LANG: c++
- *
- * This is a conds test modified to exercise actions arguments.
- */
-
-#include <iostream>
-#include <string.h>
-using std::cout;
-using std::endl;
-
-%%{
- machine foo;
-
- action c(v) { $v }
-
- action c1 {i}
- action c2 {j}
-
- action one {"one"}
- action pr(str) { cout << " " $str << endl;}
-
- main := (
- [a-z] |
- ('\n' when c(c1) @pr( one ) )
- )*
- ('\n' when c({j}) @pr( {"two"} ) );
-}%%
-
-%% write data noerror;
-
-void test( int i, int j, const char *str )
-{
- int cs = foo_start;
- const char *p = str;
- const char *pe = str + strlen( str );
-
- cout << "run:" << endl;
- %% write exec;
- if ( cs >= foo_first_final )
- cout << " success" << endl;
- else
- cout << " failure" << endl;
- cout << endl;
-}
-
-int main()
-{
- test( 0, 0, "hi\n\n" );
- test( 1, 0, "hi\n\n" );
- test( 0, 1, "hi\n" );
- test( 0, 1, "hi\n\n" );
- test( 1, 1, "hi\n" );
- test( 1, 1, "hi\n\n" );
- test( 1, 1, "hi\n\nx" );
- return 0;
-}
-
-##### OUTPUT #####
-run:
- failure
-
-run:
- one
- one
- failure
-
-run:
- two
- success
-
-run:
- two
- failure
-
-run:
- one
- two
- success
-
-run:
- one
- two
- one
- two
- success
-
-run:
- one
- two
- one
- two
- failure
-
diff --git a/test/ragel.d/args2.rl b/test/ragel.d/args2.rl
deleted file mode 100644
index 5d55349e..00000000
--- a/test/ragel.d/args2.rl
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * @LANG: c++
- *
- * This is a conds test modified to exercise actions arguments.
- */
-
-#include <iostream>
-#include <string.h>
-using std::cout;
-using std::endl;
-
-%%{
- machine foo;
-
- include "argsinc.rl";
-
- action c1 {i}
- action c2 {j}
-
- action one {"one"}
- action pr(str) { cout << " " $str << endl;}
-
- main := (
- [a-z] |
- ('\n' when c(c1) @pr( one ) )
- )*
- ('\n' when c({j}) @pr( {"two"} ) );
-}%%
-
-%% write data noerror;
-
-void test( int i, int j, const char *str )
-{
- int cs = foo_start;
- const char *p = str;
- const char *pe = str + strlen( str );
-
- cout << "run:" << endl;
- %% write exec;
- if ( cs >= foo_first_final )
- cout << " success" << endl;
- else
- cout << " failure" << endl;
- cout << endl;
-}
-
-int main()
-{
- test( 0, 0, "hi\n\n" );
- test( 1, 0, "hi\n\n" );
- test( 0, 1, "hi\n" );
- test( 0, 1, "hi\n\n" );
- test( 1, 1, "hi\n" );
- test( 1, 1, "hi\n\n" );
- test( 1, 1, "hi\n\nx" );
- return 0;
-}
-
-##### OUTPUT #####
-run:
- failure
-
-run:
- one
- one
- failure
-
-run:
- two
- success
-
-run:
- two
- failure
-
-run:
- one
- two
- success
-
-run:
- one
- two
- one
- two
- success
-
-run:
- one
- two
- one
- two
- failure
-
diff --git a/test/ragel.d/argsinc.rl b/test/ragel.d/argsinc.rl
deleted file mode 100644
index 2617fdde..00000000
--- a/test/ragel.d/argsinc.rl
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * @ENABLED: false
- *
- * This is a conds test modified to exercise actions arguments.
- */
-
-%%{
- machine foo;
- action c(v) { $v }
-}%%
-
diff --git a/test/ragel.d/atoi1.rl b/test/ragel.d/atoi1.rl
deleted file mode 100644
index 40217d91..00000000
--- a/test/ragel.d/atoi1.rl
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * @LANG: indep
- */
-bool neg;
-int value;
-
-value = 0;
-neg = false;
-%%{
- machine atoi;
-
- action begin {
- neg = false;
- value = 0;
- }
-
- action see_neg {
- neg = true;
- }
-
- action add_digit {
- value = value * 10 + <int>(fc - 48);
- }
-
- action finish {
- if ( neg ) {
- value = -1 * value;
- }
- }
- action print {
- print_int value;
- print_str "\n";
- }
-
- atoi = (
- ('-'@see_neg | '+')? (digit @add_digit)+
- ) >begin %finish;
-
- main := atoi '\n' @print;
-}%%
-
-##### INPUT #####
-"1\n"
-"12\n"
-"222222\n"
-"+2123\n"
-"213 3213\n"
-"-12321\n"
-"--123\n"
-"-99\n"
-" -3000\n"
-##### OUTPUT #####
-1
-ACCEPT
-12
-ACCEPT
-222222
-ACCEPT
-2123
-ACCEPT
-FAIL
--12321
-ACCEPT
-FAIL
--99
-ACCEPT
-FAIL
diff --git a/test/ragel.d/atoi2.rl b/test/ragel.d/atoi2.rl
deleted file mode 100644
index d793d3d8..00000000
--- a/test/ragel.d/atoi2.rl
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * @LANG: indep
- * This implementes an atoi machine using the statechart paradigm.
- */
-bool neg;
-int value;
-
-value = 0;
-neg = false;
-
-%%{
- machine state_chart;
-
- action begin {
- neg = false;
- value = 0;
- }
-
- action see_neg {
- neg = true;
- }
-
- action add_digit {
- value = value * 10 + <int>(fc - 48);
- }
-
- action finish {
- if ( neg ) {
- value = -1 * value;
- }
- }
-
- atoi = (
- start: (
- '-' @see_neg ->om_num |
- '+' ->om_num |
- [0-9] @add_digit ->more_nums
- ),
-
- # One or more nums.
- om_num: (
- [0-9] @add_digit ->more_nums
- ),
-
- # Zero ore more nums.
- more_nums: (
- [0-9] @add_digit ->more_nums |
- '' -> final
- )
- ) >begin %finish;
-
- action oneof { print_int value; print_str "\n"; }
- main := ( atoi '\n' @oneof )*;
-}%%
-
-##### INPUT #####
-"1\n"
-"12\n"
-"222222\n"
-"+2123\n"
-"213 3213\n"
-"-12321\n"
-"--123\n"
-"-99\n"
-" -3000\n"
-##### OUTPUT #####
-1
-ACCEPT
-12
-ACCEPT
-222222
-ACCEPT
-2123
-ACCEPT
-FAIL
--12321
-ACCEPT
-FAIL
--99
-ACCEPT
-FAIL
diff --git a/test/ragel.d/atoi3.rl b/test/ragel.d/atoi3.rl
deleted file mode 100644
index cb919287..00000000
--- a/test/ragel.d/atoi3.rl
+++ /dev/null
@@ -1,74 +0,0 @@
-#
-# @LANG: ruby
-#
-
-%%{
- machine atoi3;
- action begin {
- neg = false;
- val = 0;
- }
- action see_neg {
- neg = true;
- }
- action add_digit {
- val = val * 10 + (fc - "0"[0].ord);
- }
- action finish {
- val = -1 * val if neg
- }
- action print {
- print val, "\n"
- }
- atoi = (('-' @ see_neg | '+') ? (digit @ add_digit) +) > begin % finish;
- main := atoi '\n' @ print;
-}%%
-
-%% write data;
-
-def run_machine( data )
- p = 0;
- pe = data.length
- cs = 0
- val = 0;
- neg = false;
-
- %% write init;
- %% write exec;
- if cs >= atoi3_first_final
- puts "ACCEPT"
- else
- puts "FAIL"
- end
-end
-
-inp = [
- "1\n",
- "12\n",
- "222222\n",
- "+2123\n",
- "213 3213\n",
- "-12321\n",
- "--123\n",
- "-99\n",
- " -3000\n",
-]
-
-inp.each { |str| run_machine(str) }
-
-##### OUTPUT #####
-1
-ACCEPT
-12
-ACCEPT
-222222
-ACCEPT
-2123
-ACCEPT
-FAIL
--12321
-ACCEPT
-FAIL
--99
-ACCEPT
-FAIL
diff --git a/test/ragel.d/atoi4.rl b/test/ragel.d/atoi4.rl
deleted file mode 100644
index 04b678f9..00000000
--- a/test/ragel.d/atoi4.rl
+++ /dev/null
@@ -1,73 +0,0 @@
-(*
- * @LANG: ocaml
- *)
-
-let id x = x
-let fail fmt = Printf.ksprintf failwith fmt
-let pr fmt = Printf.ksprintf print_endline fmt
-
-let failed fmt = Printf.ksprintf (fun s -> prerr_endline s; exit 1) fmt
-let test' show f x y = if f x <> y then failed "FAILED: test %S" (show x)
-let case = ref 0
-let test f x y = incr case; if f x <> y then failed "FAILED: case %d" !case
-let error f x = match try Some (f x) with _ -> None with Some _ -> failed "FAILED: fail %S" x | None -> ()
-
-%%{
- machine atoi;
- write data;
-}%%
-
-let fail fmt = Printf.ksprintf failwith fmt
-
-let atoi data =
- let cs = ref 0 in
- let p = ref 0 in
- let pe = ref (String.length data) in
- let neg = ref false in
- let res = ref 0 in
-
- %%{
- action see_neg { neg := true; }
- action add_digit { res := !res * 10 + (fc - Char.code '0'); }
-
- main :=
- ( '-'@see_neg | '+' )? ( digit @add_digit )+
- '\n'?
- ;
-
- write init;
- write exec;
- }%%
-
- if !neg then
- res := (-1) * !res ;
-
- print_int res.contents;
- print_string "\n";
-
- if !cs < atoi_first_final then
- fail "atoi: cs %d < %d" !cs atoi_first_final;
-
- !res
-;;
-
-let () =
- let t = test atoi in
- t "7" 7;
- t "666" 666;
- t "-666" (-666);
- t "+666" 666;
- t "123456789" 123456789;
- t "+123456789\n" 123456789;
- error atoi "+ 1234567890";
- ()
-;;
-
-##### OUTPUT #####
-7
-666
--666
-666
-123456789
-123456789
-0
diff --git a/test/ragel.d/atoi5.rl b/test/ragel.d/atoi5.rl
deleted file mode 100644
index c2928967..00000000
--- a/test/ragel.d/atoi5.rl
+++ /dev/null
@@ -1,266 +0,0 @@
-#
-# @LANG: asm
-#
-
-%%{
- machine AtoI;
-
- action begin {
- # neg = 0;
- # val = 0;
- movl $0, neg(%rip)
- movl $0, val(%rip)
- }
-
- action see_neg {
- # neg = 1;
- movl $1, neg(%rip)
- }
-
- action add_digit {
- # val = val * 10 + (fc - 48);
- movl val(%rip), %eax
- imul $10, %eax
- movsbl (%r12), %ecx
- subl $48, %ecx
- add %ecx, %eax
- movl %eax, val(%rip)
- }
-
- action finish {
- #if (neg)
- #{
- # val = - 1 * val;
- #}
-
- movl neg(%rip), %eax
- cmpl $0, %eax
- je .finish_L
- movl val(%rip), %eax
- negl %eax
- movl %eax, val(%rip)
- .finish_L:
- }
-
- action print {
- #printf ("%i", val);
- #fputs ("\n", stdout);
- movl $.L_fmt_i_nl, %edi
- movl val(%rip), %esi
- movl $0, %eax
- call printf
- }
-
- atoi =
- (('-' @ see_neg | '+') ?
- (digit @ add_digit) +) > begin %finish;
-
- main := atoi '\n' @ print;
-
-}%%
- .file "tmp.c"
- .comm neg,4,4
- .comm val,4,4
- .comm cs,4,4
- .section .rodata
-
-%% write data;
-
-.L_fmt_i_nl:
- .string "%i\n"
-.L_marker:
- .string "marker\n"
-
- .text
- .globl init
- .type init, @function
-init:
-.LFB0:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- movl $0, val(%rip)
- movl $0, neg(%rip)
-
-%% write init;
-
- movq %r11, cs(%rip)
-
- popq %rbp
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE0:
- .size init, .-init
- .section .rodata
-.LC0:
- .string "%i"
- .text
- .globl exec
- .type exec, @function
-exec:
-.LFB1:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- subq $96, %rsp
-
- pushq %r12
- pushq %r13
-
- movq cs(%rip), %r11
- movq %rdi, %r12
- movq %rsi, %r13
-
-%% write exec;
-
- movq %r11, cs(%rip)
-
- popq %r13
- popq %r12
-
-.LRET:
- leave
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE1:
- .size exec, .-exec
- .section .rodata
-.LC1:
- .string "-> ACCEPT"
-.LC2:
- .string "-> FAIL"
- .text
- .globl finish
- .type finish, @function
-finish:
-.LFB2:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- movq cs@GOTPCREL (%rip), %rdx
- movl (%rdx), %edx
- movl $4, %eax
- cmpl %eax, %edx
- jl .L36
- movl $.LC1, %edi
-# call puts
- jmp .L35
-.L36:
- movl $.LC2, %edi
- call puts
-.L35:
- popq %rbp
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE2:
- .size finish, .-finish
- .globl inp
-
- .section .rodata
-.LC3:
- .string "1\n"
-.LC4:
- .string "12\n"
-.LC5:
- .string "222222\n"
-.LC6:
- .string "+2123\n"
-.LC7:
- .string "-99\n"
-.LC8:
- .string "-12321\n"
-.LC9:
- .string "213 3213\n"
-.LC10:
- .string "--123\n"
-.LC11:
- .string " -3000\n"
- .data
- .align 32
- .type inp, @object
- .size inp, 72
-inp:
- .quad .LC3
- .quad .LC4
- .quad .LC5
- .quad .LC6
- .quad .LC7
- .quad .LC8
- .quad .LC9
- .quad .LC10
- .quad .LC11
- .globl inplen
- .align 4
- .type inplen, @object
- .size inplen, 4
-inplen:
- .long 9
- .text
- .globl main
- .type main, @function
-main:
-.LFB3:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- subq $16, %rsp
- movl $0, -4(%rbp)
- jmp .L39
-.L40:
- movl $0, %eax
- call init
- movl -4(%rbp), %eax
- cltq
- movq inp(,%rax,8), %rax
- movq %rax, %rdi
- call strlen
- movl %eax, %edx
- movl -4(%rbp), %eax
- cltq
- movq inp(,%rax,8), %rax
- movslq %edx, %rsi
- addq %rax, %rsi
- movq %rax, %rdi
- call exec
- movl $0, %eax
- call finish
- addl $1, -4(%rbp)
-.L39:
- movl inplen(%rip), %eax
- cmpl %eax, -4(%rbp)
- jl .L40
- movl $0, %eax
- leave
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE3:
- .size main, .-main
- .ident "GCC: (Ubuntu 4.8.2-19ubuntu1) 4.8.2"
- .section .note.GNU-stack,"",@progbits
-
-##### OUTPUT #####
-1
-12
-222222
-2123
--99
--12321
--> FAIL
--> FAIL
--> FAIL
diff --git a/test/ragel.d/awkemu.rl b/test/ragel.d/awkemu.rl
deleted file mode 100644
index 201559d6..00000000
--- a/test/ragel.d/awkemu.rl
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * @LANG: c
- */
-
-/*
- * Emulate the basic parser of the awk program. Breaks lines up into
- * words and prints the words.
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#define LINEBUF 2048
-static char lineBuf[LINEBUF];
-static char blineBuf[LINEBUF];
-static int lineLen;
-static int blineLen;
-static int words;
-
-void finishLine();
-
-struct awkemu
-{
- int cs;
-};
-
-%%{
- machine awkemu;
-
- variable cs fsm->cs;
-
- # Starts a line. Will initialize all the data necessary for capturing the line.
- action startline {
- lineLen = 0;
- blineLen = 0;
- words = 0;
- }
-
- # Will be executed on every character seen in a word. Captures the word
- # to the broken up line buffer.
- action wordchar {
- blineBuf[blineLen++] = fc;
- }
-
- # Terminate a word. Adds the null after the word and increments the word count
- # for the line.
- action termword {
- blineBuf[blineLen++] = 0;
- words += 1;
- }
-
- # Will be executed on every character seen in a line (not including
- # the newline itself.
- action linechar {
- lineBuf[lineLen++] = fc;
- }
-
- # This section of the machine deals with breaking up lines into fields.
- # Lines are separed by the whitespace and put in an array of words.
-
- # Words in a line.
- word = (extend - [ \t\n])+;
-
- # The whitespace separating words in a line.
- whitespace = [ \t];
-
- # The components in a line to break up. Either a word or a single char of
- # whitespace. On the word capture characters.
- blineElements = word $wordchar %termword | whitespace;
-
- # Star the break line elements. Just be careful to decrement the leaving
- # priority as we don't want multiple character identifiers to be treated as
- # multiple single char identifiers.
- breakLine = ( blineElements $1 %0 )* . '\n';
-
- # This machine lets us capture entire lines. We do it separate from the words
- # in a line.
- bufLine = (extend - '\n')* $linechar %{ finishLine(); } . '\n';
-
- # A line can then consist of the machine that will break up the line into
- # words and a machine that will buffer the entire line.
- line = ( breakLine | bufLine ) > startline;
-
- # Any number of lines.
- main := line*;
-}%%
-
-void finishLine()
-{
- int i;
- char *pword = blineBuf;
- lineBuf[lineLen] = 0;
- printf("endline(%i): %s\n", words, lineBuf );
- for ( i = 0; i < words; i++ ) {
- printf(" word: %s\n", pword );
- pword += strlen(pword) + 1;
- }
-}
-
-%% write data;
-
-void awkemu_init( struct awkemu *fsm )
-{
- %% write init;
-}
-
-void awkemu_execute( struct awkemu *fsm, const char *_data, int _len )
-{
- const char *p = _data;
- const char *pe = _data+_len;
- %% write exec;
-}
-
-int awkemu_finish( struct awkemu *fsm )
-{
- if ( fsm->cs == awkemu_error )
- return -1;
- if ( fsm->cs >= awkemu_first_final )
- return 1;
- return 0;
-}
-
-#include <stdio.h>
-#define BUFSIZE 2048
-
-struct awkemu fsm;
-char buf[BUFSIZE];
-
-void test( char *buf )
-{
- int len = strlen( buf );
- awkemu_init( &fsm );
- awkemu_execute( &fsm, buf, len );
- if ( awkemu_finish( &fsm ) > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
-}
-
-int main()
-{
- test( "" );
- test( "one line with no newline" );
- test( "one line\n" );
- return 0;
-}
-
-##### OUTPUT #####
-ACCEPT
-FAIL
-endline(2): one line
- word: one
- word: line
-ACCEPT
diff --git a/test/ragel.d/buffer.h b/test/ragel.d/buffer.h
deleted file mode 100644
index 60ef1242..00000000
--- a/test/ragel.d/buffer.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2003 Adrian Thurston <thurston@complang.org>
- */
-
-/* This file is part of Colm.
- *
- * Colm is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Colm is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Colm; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _BUFFER_H
-#define _BUFFER_H
-
-#include <stdlib.h>
-
-#define BUFFER_INITIAL_SIZE 4096
-
-/* An automatically grown buffer for collecting tokens. Always reuses space;
- * never down resizes. */
-struct Buffer
-{
- Buffer()
- {
- data = (char*) malloc( BUFFER_INITIAL_SIZE );
- allocated = BUFFER_INITIAL_SIZE;
- length = 0;
- }
- ~Buffer() { free(data); }
-
- void append( char p )
- {
- if ( length == allocated ) {
- allocated *= 2;
- data = (char*) realloc( data, allocated );
- }
- data[length++] = p;
- }
-
- void clear() { length = 0; }
-
- char *data;
- int allocated;
- int length;
-};
-
-#endif /* _BUFFER_H */
diff --git a/test/ragel.d/builtin.rl b/test/ragel.d/builtin.rl
deleted file mode 100644
index eb8f27c3..00000000
--- a/test/ragel.d/builtin.rl
+++ /dev/null
@@ -1,1208 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stdio.h>
-
-void alph(const char *type)
-{
- printf("%s\n", type);
-}
-
-struct builtin
-{
- int cs;
-};
-
-%%{
- machine builtin;
- alphtype unsigned int;
- variable cs fsm->cs;
-
- main := (
- any @{alph("any");} |
- ascii @{alph("ascii");} |
- extend @{alph("extend");} |
- alpha @{alph("alpha");} |
- digit @{alph("digit");} |
- alnum @{alph("alnum");} |
- lower @{alph("lower");} |
- upper @{alph("upper");} |
- cntrl @{alph("cntrl");} |
- graph @{alph("graph");} |
- print @{alph("print");} |
- punct @{alph("punct");} |
- space @{alph("space");} |
- xdigit @{alph("xdigit");}
- )*;
-}%%
-
-%% write data;
-
-void builtin_init( struct builtin *fsm )
-{
- %% write init;
-}
-
-void builtin_execute( struct builtin *fsm, const unsigned int *data, int len )
-{
- const unsigned int *p = data;
- const unsigned int *pe = data+len;
- %% write exec;
-}
-
-int builtin_finish( struct builtin *fsm )
-{
- if ( fsm->cs == builtin_error )
- return -1;
- else if ( fsm->cs >= builtin_first_final )
- return 1;
- return 0;
-}
-
-#include <stdio.h>
-#define BUFSIZE 2048
-
-struct builtin fsm;
-char buf[BUFSIZE];
-unsigned int i;
-
-int test( const unsigned int *data, int len )
-{
- builtin_init( &fsm );
- builtin_execute( &fsm, data, len );
- if ( builtin_finish( &fsm ) > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
- return 0;
-}
-
-#define DLEN 258
-unsigned int data[DLEN] = {
- -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
- 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,
- 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
- 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
- 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
- 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126,
- 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141,
- 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156,
- 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
- 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186,
- 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201,
- 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216,
- 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231,
- 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246,
- 247, 248, 249, 250, 251, 252, 253, 254, 255, 256
-};
-
-int main()
-{
- test( data, DLEN );
- return 0;
-}
-
-##### OUTPUT #####
-any
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-space
-any
-ascii
-extend
-cntrl
-space
-any
-ascii
-extend
-cntrl
-space
-any
-ascii
-extend
-cntrl
-space
-any
-ascii
-extend
-cntrl
-space
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-cntrl
-any
-ascii
-extend
-print
-space
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-digit
-alnum
-graph
-print
-xdigit
-any
-ascii
-extend
-digit
-alnum
-graph
-print
-xdigit
-any
-ascii
-extend
-digit
-alnum
-graph
-print
-xdigit
-any
-ascii
-extend
-digit
-alnum
-graph
-print
-xdigit
-any
-ascii
-extend
-digit
-alnum
-graph
-print
-xdigit
-any
-ascii
-extend
-digit
-alnum
-graph
-print
-xdigit
-any
-ascii
-extend
-digit
-alnum
-graph
-print
-xdigit
-any
-ascii
-extend
-digit
-alnum
-graph
-print
-xdigit
-any
-ascii
-extend
-digit
-alnum
-graph
-print
-xdigit
-any
-ascii
-extend
-digit
-alnum
-graph
-print
-xdigit
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-xdigit
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-xdigit
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-xdigit
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-xdigit
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-xdigit
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-xdigit
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-upper
-graph
-print
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-xdigit
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-xdigit
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-xdigit
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-xdigit
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-xdigit
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-xdigit
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-alpha
-alnum
-lower
-graph
-print
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-graph
-print
-punct
-any
-ascii
-extend
-cntrl
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-extend
-any
-ACCEPT
diff --git a/test/ragel.d/call1.rl b/test/ragel.d/call1.rl
deleted file mode 100644
index 3b54a713..00000000
--- a/test/ragel.d/call1.rl
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * @LANG: c
- * @PROHIBIT_FLAGS: --var-backend
- */
-
-#include <stdio.h>
-#include <string.h>
-
-int num = 0;
-
-struct test
-{
- int cs, top, stack[32];
-};
-
-%%{
- machine test;
- access fsm->;
-
- action check_num {
- if ( num & 1 )
- fcall *fentry(odd);
- else
- fcall even;
- }
-
- # Test call and return functionality.
- even := 'even' any @{fhold; fret;};
- odd := 'odd' any @{fhold; fret;};
- num = [0-9]+ ${ num = num * 10 + (fc - '0'); };
- even_odd = num ' ' @check_num "\n";
-
- # Test calls in out actions.
- fail := !(any*);
- out_acts = 'OA ok\n' |
- 'OA error1\n' |
- 'OA error2\n';
-
- main := even_odd | out_acts;
-}%%
-
-%% write data;
-
-void test_init( struct test *fsm )
-{
- num = 0;
- %% write init;
-}
-
-void test_execute( struct test *fsm, const char *data, int len )
-{
- const char *p = data;
- const char *pe = data+len;
-
- %% write exec;
-}
-
-int test_finish( struct test *fsm )
-{
- if ( fsm->cs == test_error )
- return -1;
- if ( fsm->cs >= test_first_final )
- return 1;
- return 0;
-}
-
-#define BUFSIZE 1024
-
-void test( char *buf )
-{
- struct test test;
- test_init( &test );
- test_execute( &test, buf, strlen(buf) );
- if ( test_finish( &test ) > 0 )
- printf( "ACCEPT\n" );
- else
- printf( "FAIL\n" );
-}
-
-int main()
-{
- test( "78 even\n" );
- test( "89 odd\n" );
- test( "1 even\n" );
- test( "0 odd\n" );
- test( "OA ok\n" );
- test( "OA error1\n" );
- test( "OA error2\n" );
-
- return 0;
-}
-
-
-##### OUTPUT #####
-ACCEPT
-ACCEPT
-FAIL
-FAIL
-ACCEPT
-ACCEPT
-ACCEPT
diff --git a/test/ragel.d/call2.rl b/test/ragel.d/call2.rl
deleted file mode 100644
index fdf40e6f..00000000
--- a/test/ragel.d/call2.rl
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * @LANG: c++
- * @PROHIBIT_FLAGS: --var-backend
- */
-
-#include <stdio.h>
-#include <string.h>
-
-int num = 0;
-
-struct CallTest
-{
- int cs, top, stack[32];
-
- // Initialize the machine. Invokes any init statement blocks. Returns 0
- // if the machine begins in a non-accepting state and 1 if the machine
- // begins in an accepting state.
- void init( );
-
- // Execute the machine on a block of data. Returns -1 if after processing
- // the data, the machine is in the error state and can never accept, 0 if
- // the machine is in a non-accepting state and 1 if the machine is in an
- // accepting state.
- void execute( const char *data, int len );
-
- // Indicate that there is no more data. Returns -1 if the machine finishes
- // in the error state and does not accept, 0 if the machine finishes
- // in any other non-accepting state and 1 if the machine finishes in an
- // accepting state.
- int finish( );
-};
-
-%%{
- machine CallTest;
-
- action check_num {
- if ( num & 1 )
- fcall *fentry(odd);
- else
- fcall even;
- }
-
- # Test call and return functionality.
- even := 'even' any @{fhold; fret;};
- odd := 'odd' any @{fhold; fret;};
- num = [0-9]+ ${ num = num * 10 + (fc - '0'); };
- even_odd = num ' ' @check_num "\n";
-
- # Test calls in out actions.
- fail := !(any*);
- out_acts = 'OA ok\n' |
- 'OA error1\n' |
- 'OA error2\n';
-
- main := even_odd | out_acts;
-}%%
-
-%% write data;
-
-void CallTest::init( )
-{
- num = 0;
- %% write init;
-}
-
-void CallTest::execute( const char *data, int len )
-{
- const char *p = data;
- const char *pe = data+len;
-
- %% write exec;
-}
-
-int CallTest::finish( )
-{
- if ( this->cs == CallTest_error )
- return -1;
- if ( this->cs >= CallTest_first_final )
- return 1;
- return 0;
-}
-
-#define BUFSIZE 1024
-
-void test( const char *buf )
-{
- CallTest test;
-
- test.init();
- test.execute( buf, strlen(buf) );
- if ( test.finish() > 0 )
- printf( "ACCEPT\n" );
- else
- printf( "FAIL\n" );
-}
-
-int main()
-{
- test( "78 even\n" );
- test( "89 odd\n" );
- test( "1 even\n" );
- test( "0 odd\n" );
- test( "OA ok\n" );
- test( "OA error1\n" );
- test( "OA error2\n" );
- return 0;
-}
-
-##### OUTPUT #####
-ACCEPT
-ACCEPT
-FAIL
-FAIL
-ACCEPT
-ACCEPT
-ACCEPT
diff --git a/test/ragel.d/call3.rl b/test/ragel.d/call3.rl
deleted file mode 100644
index 416790d8..00000000
--- a/test/ragel.d/call3.rl
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * @LANG: obj-c
- * @PROHIBIT_FLAGS: --var-backend
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#import <Foundation/Foundation.h>
-
-int num = 0;
-
-@interface CallTest : NSObject
-{
-@public
- /* State machine operation data. */
- int cs, top, stack[32];
-};
-
-// Initialize the machine. Invokes any init statement blocks. Returns 0
-// if the machine begins in a non-accepting state and 1 if the machine
-// begins in an accepting state.
-- (void) initFsm;
-
-// Execute the machine on a block of data. Returns -1 if after processing
-// the data, the machine is in the error state and can never accept, 0 if
-// the machine is in a non-accepting state and 1 if the machine is in an
-// accepting state.
-- (void) executeWithData:(const char *)data len:(int)len;
-
-// Indicate that there is no more data. Returns -1 if the machine finishes
-// in the error state and does not accept, 0 if the machine finishes
-// in any other non-accepting state and 1 if the machine finishes in an
-// accepting state.
-- (int) finish;
-
-@end
-
-@implementation CallTest
-
-%%{
- machine CallTest;
-
- action check_num {
- if ( num & 1 )
- fcall odd;
- else
- fcall even;
- }
-
- # Test call and return functionality.
- even := 'even' any @{fhold; fret;};
- odd := 'odd' any @{fhold; fret;};
- num = [0-9]+ ${ num = num * 10 + (fc - '0'); };
- even_odd = num ' ' @check_num "\n";
-
- # Test calls in out actions.
- fail := !(any*);
- out_acts = 'OA ok\n' |
- 'OA error1\n' |
- 'OA error2\n';
-
- main := even_odd | out_acts;
-}%%
-
-%% write data;
-
-- (void) initFsm;
-{
- num = 0;
- %% write init;
-}
-
-- (void) executeWithData:(const char *)data len:(int)len;
-{
- const char *p = data;
- const char *pe = data + len;
- %% write exec;
-}
-
-- (int) finish;
-{
- if ( cs == CallTest_error )
- return -1;
- return ( cs >= CallTest_first_final ) ? 1 : 0;
-}
-
-@end
-
-#define BUFSIZE 1024
-
-void test( char *buf )
-{
- CallTest *test = [[CallTest alloc] init];
- [test initFsm];
- [test executeWithData:buf len:strlen(buf)];
- if ( [test finish] > 0 )
- printf( "ACCEPT\n" );
- else
- printf( "FAIL\n" );
-}
-
-int main()
-{
- test( "78 even\n" );
- test( "89 odd\n" );
- test( "1 even\n" );
- test( "0 odd\n" );
- test( "OA ok\n" );
- test( "OA error1\n" );
- test( "OA error2\n" );
- return 0;
-}
-
-##### OUTPUT #####
-ACCEPT
-ACCEPT
-FAIL
-FAIL
-ACCEPT
-ACCEPT
-ACCEPT
diff --git a/test/ragel.d/call4.rl b/test/ragel.d/call4.rl
deleted file mode 100644
index a999d490..00000000
--- a/test/ragel.d/call4.rl
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * @LANG: indep
- * @PROHIBIT_LANGUAGES: cv ruby ocaml rust crack
- * @PROHIBIT_FLAGS: --var-backend
- */
-
-int target;
-int top;
-int stack[32];
-
-%%{
- machine call4;
-
- unused := 'unused';
-
- one := 'one' @{
- print_str "one\n";
- fret;
- };
-
- two := 'two' @{
- print_str "two\n";
- fret;
- };
-
- main := (
- '1' @{ target = fentry(one); fcall *target; }
- | '2' @{ target = fentry(two); fcall *target; }
- | '\n'
- )*;
-}%%
-
-##### INPUT #####
-"1one2two1one\n"
-##### OUTPUT #####
-one
-two
-one
-ACCEPT
diff --git a/test/ragel.d/caseindep.rl b/test/ragel.d/caseindep.rl
deleted file mode 100644
index d3bd188c..00000000
--- a/test/ragel.d/caseindep.rl
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * @LANG: indep
- */
-%%{
- machine indep;
-
- main := (
- ( '1' 'hello' ) |
- ( '2' "hello" ) |
- ( '3' /hello/ ) |
- ( '4' 'hello'i ) |
- ( '5' "hello"i ) |
- ( '6' /hello/i )
- ) '\n';
-}%%
-
-##### INPUT #####
-"1hello\n"
-"1HELLO\n"
-"1HeLLo\n"
-"2hello\n"
-"2HELLO\n"
-"2HeLLo\n"
-"3hello\n"
-"3HELLO\n"
-"3HeLLo\n"
-"4hello\n"
-"4HELLO\n"
-"4HeLLo\n"
-"5hello\n"
-"5HELLO\n"
-"5HeLLo\n"
-"6hello\n"
-"6HELLO\n"
-"6HeLLo\n"
-##### OUTPUT #####
-ACCEPT
-FAIL
-FAIL
-ACCEPT
-FAIL
-FAIL
-ACCEPT
-FAIL
-FAIL
-ACCEPT
-ACCEPT
-ACCEPT
-ACCEPT
-ACCEPT
-ACCEPT
-ACCEPT
-ACCEPT
-ACCEPT
diff --git a/test/ragel.d/clang1.rl b/test/ragel.d/clang1.rl
deleted file mode 100644
index b5610331..00000000
--- a/test/ragel.d/clang1.rl
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * @LANG: c
- * A mini C-like language scanner.
- */
-
-#include <stdio.h>
-#include <string.h>
-#define IDENT_BUFLEN 256
-
-%%{
- machine clang;
-
- # Function to buffer a character.
- action bufChar {
- if ( identLen < IDENT_BUFLEN ) {
- identBuf[identLen] = fc;
- identLen += 1;
- }
- }
-
- # Function to clear the buffer.
- action clearBuf {
- identLen = 0;
- }
-
- # Functions to dump tokens as they are matched.
- action ident {
- identBuf[identLen] = 0;
- printf("ident(%i): %s\n", curLine, identBuf);
- }
- action literal {
- identBuf[identLen] = 0;
- printf("literal(%i): %s\n", curLine, identBuf);
- }
- action float {
- identBuf[identLen] = 0;
- printf("float(%i): %s\n", curLine, identBuf);
- }
- action int {
- identBuf[identLen] = 0;
- printf("int(%i): %s\n", curLine, identBuf);
- }
- action hex {
- identBuf[identLen] = 0;
- printf("hex(%i): 0x%s\n", curLine, identBuf);
- }
- action symbol {
- identBuf[identLen] = 0;
- printf("symbol(%i): %s\n", curLine, identBuf);
- }
-
- # Alpha numberic characters or underscore.
- alnumu = alnum | '_';
-
- # Alpha charactres or underscore.
- alphau = alpha | '_';
-
- # Symbols. Upon entering clear the buffer. On all transitions
- # buffer a character. Upon leaving dump the symbol.
- symbol = ( punct - [_'"] ) >clearBuf $bufChar %symbol;
-
- # Identifier. Upon entering clear the buffer. On all transitions
- # buffer a character. Upon leaving, dump the identifier.
- ident = (alphau . alnumu*) >clearBuf $bufChar %ident;
-
- # Match single characters inside literal strings. Or match
- # an escape sequence. Buffers the charater matched.
- sliteralChar =
- ( extend - ['\\] ) @bufChar |
- ( '\\' . extend @bufChar );
- dliteralChar =
- ( extend - ["\\] ) @bufChar |
- ( '\\' . extend @bufChar );
-
- # Single quote and double quota literals. At the start clear
- # the buffer. Upon leaving dump the literal.
- sliteral = ('\'' @clearBuf . sliteralChar* . '\'' ) %literal;
- dliteral = ('"' @clearBuf . dliteralChar* . '"' ) %literal;
- literal = sliteral | dliteral;
-
- # Whitespace is standard ws, newlines and control codes.
- whitespace = any - 0x21..0x7e;
-
- # Describe both c style comments and c++ style comments. The
- # priority bump on tne terminator of the comments brings us
- # out of the extend* which matches everything.
- ccComment = '//' . extend* $0 . '\n' @1;
- cComment = '/*' . extend* $0 . '*/' @1;
-
- # Match an integer. We don't bother clearing the buf or filling it.
- # The float machine overlaps with int and it will do it.
- int = digit+ %int;
-
- # Match a float. Upon entering the machine clear the buf, buffer
- # characters on every trans and dump the float upon leaving.
- float = ( digit+ . '.' . digit+ ) >clearBuf $bufChar %float;
-
- # Match a hex. Upon entering the hex part, clear the buf, buffer characters
- # on every trans and dump the hex on leaving transitions.
- hex = '0x' . xdigit+ >clearBuf $bufChar %hex;
-
- # Or together all the lanuage elements.
- fin = ( ccComment |
- cComment |
- symbol |
- ident |
- literal |
- whitespace |
- int |
- float |
- hex );
-
- # Star the language elements. It is critical in this type of application
- # that we decrease the priority of out transitions before doing so. This
- # is so that when we see 'aa' we stay in the fin machine to match an ident
- # of length two and not wrap around to the front to match two idents of
- # length one.
- clang_main = ( fin $1 %0 )*;
-
- # This machine matches everything, taking note of newlines.
- newline = ( any | '\n' @{ curLine += 1; } )*;
-
- # The final fsm is the lexer intersected with the newline machine which
- # will count lines for us. Since the newline machine accepts everything,
- # the strings accepted is goverened by the clang_main machine, onto which
- # the newline machine overlays line counting.
- main := clang_main & newline;
-}%%
-
-#include <stdio.h>
-
-%% write data noerror;
-
-
-char data[] =
- "/*\n"
- " * Copyright\n"
- " */\n"
- "\n"
- "/* Aapl.\n"
- " */\n"
- " \n"
- "#define _AAPL_RESIZE_H\n"
- "\n"
- "#include <assert.h>\n"
- "\n"
- "#ifdef AAPL_NAMESPACE\n"
- "namespace Aapl {\n"
- "#endif\n"
- "#define LIN_DEFAULT_STEP 256\n"
- "#define EXPN_UP( existing, needed ) \\\n"
- " need > eng ? (ned<<1) : eing\n"
- " \n"
- "\n"
- "/*@}*/\n"
- "#undef EXPN_UP\n"
- "#ifdef AAPL_NAMESPACE\n"
- "#endif /* _AAPL_RESIZE_H */\n";
-
-void test( char *buf )
-{
- int len = strlen( buf );
- char *p = buf, *pe = buf + len;
- char *eof = pe;
- char identBuf[IDENT_BUFLEN+1];
- int identLen;
- int curLine;
- int cs;
-
- identLen = 0;
- curLine = 1;
-
- %% write init;
- %% write exec;
-
- if ( cs >= clang_first_final )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
-}
-
-int main()
-{
- test(
- "999 0xaAFF99 99.99 /*\n"
- "*/ 'lksdj' //\n"
- "\"\n"
- "\n"
- "literal\n"
- "\n"
- "\n"
- "\"0x00aba foobardd.ddsf 0x0.9\n" );
- test(
- "wordwithnum00asdf\n"
- "000wordfollowsnum,makes new symbol\n"
- "\n"
- "finishing early /* unfinished ...\n" );
- test( data );
- return 0;
-}
-
-##### OUTPUT #####
-int(1): 999
-hex(1): 0xaAFF99
-float(1): 99.99
-literal(2): lksdj
-literal(8):
-
-literal
-
-
-
-hex(8): 0x00aba
-ident(8): foobardd
-symbol(8): .
-ident(8): ddsf
-hex(8): 0x0
-symbol(8): .
-int(8): 9
-ACCEPT
-ident(1): wordwithnum00asdf
-int(2): 000
-ident(2): wordfollowsnum
-symbol(2): ,
-ident(2): makes
-ident(2): new
-ident(2): symbol
-ident(4): finishing
-ident(4): early
-FAIL
-symbol(8): #
-ident(8): define
-ident(8): _AAPL_RESIZE_H
-symbol(10): #
-ident(10): include
-symbol(10): <
-ident(10): assert
-symbol(10): .
-ident(10): h
-symbol(10): >
-symbol(12): #
-ident(12): ifdef
-ident(12): AAPL_NAMESPACE
-ident(13): namespace
-ident(13): Aapl
-symbol(13): {
-symbol(14): #
-ident(14): endif
-symbol(15): #
-ident(15): define
-ident(15): LIN_DEFAULT_STEP
-int(15): 256
-symbol(16): #
-ident(16): define
-ident(16): EXPN_UP
-symbol(16): (
-ident(16): existing
-symbol(16): ,
-ident(16): needed
-symbol(16): )
-symbol(16): \
-ident(17): need
-symbol(17): >
-ident(17): eng
-symbol(17): ?
-symbol(17): (
-ident(17): ned
-symbol(17): <
-symbol(17): <
-int(17): 1
-symbol(17): )
-symbol(17): :
-ident(17): eing
-symbol(21): #
-ident(21): undef
-ident(21): EXPN_UP
-symbol(22): #
-ident(22): ifdef
-ident(22): AAPL_NAMESPACE
-symbol(23): #
-ident(23): endif
-ACCEPT
diff --git a/test/ragel.d/clang2.rl b/test/ragel.d/clang2.rl
deleted file mode 100644
index fead806e..00000000
--- a/test/ragel.d/clang2.rl
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * @LANG: obj-c
- * A mini C-like language scanner.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <Foundation/Foundation.h>
-
-#define IDENT_BUFLEN 256
-
-@interface Clang : NSObject
-{
-@public
- /* State machine operation data. */
- int cs;
-
- /* Parsing data. */
- char identBuf[IDENT_BUFLEN+1];
- int identLen;
- int curLine;
-};
-
-- (void) initFsm;
-- (void) executeWithData:(const char *)data len:(int)len;
-- (int) finish;
-
-@end
-
-%%{
- machine Clang;
-
- # Function to buffer a character.
- action bufChar {
- if ( identLen < IDENT_BUFLEN ) {
- identBuf[identLen] = fc;
- identLen += 1;
- }
- }
-
- # Function to clear the buffer.
- action clearBuf {
- identLen = 0;
- }
-
- # Functions to dump tokens as they are matched.
- action ident {
- identBuf[identLen] = 0;
- printf("ident(%i): %s\n", curLine, identBuf);
- }
- action literal {
- identBuf[identLen] = 0;
- printf("literal(%i): %s\n", curLine, identBuf);
- }
- action float {
- identBuf[identLen] = 0;
- printf("float(%i): %s\n", curLine, identBuf);
- }
- action int {
- identBuf[identLen] = 0;
- printf("int(%i): %s\n", curLine, identBuf);
- }
- action hex {
- identBuf[identLen] = 0;
- printf("hex(%i): 0x%s\n", curLine, identBuf);
- }
- action symbol {
- identBuf[identLen] = 0;
- printf("symbol(%i): %s\n", curLine, identBuf);
- }
-
- # Alpha numberic characters or underscore.
- alnumu = alnum | '_';
-
- # Alpha charactres or underscore.
- alphau = alpha | '_';
-
- # Symbols. Upon entering clear the buffer. On all transitions
- # buffer a character. Upon leaving dump the symbol.
- symbol = ( punct - [_'"] ) >clearBuf $bufChar %symbol;
-
- # Identifier. Upon entering clear the buffer. On all transitions
- # buffer a character. Upon leaving, dump the identifier.
- ident = (alphau . alnumu*) >clearBuf $bufChar %ident;
-
- # Match single characters inside literal strings. Or match
- # an escape sequence. Buffers the charater matched.
- sliteralChar =
- ( extend - ['\\] ) @bufChar |
- ( '\\' . extend @bufChar );
- dliteralChar =
- ( extend - ["\\] ) @bufChar |
- ( '\\' . extend @bufChar );
-
- # Single quote and double quota literals. At the start clear
- # the buffer. Upon leaving dump the literal.
- sliteral = ('\'' @clearBuf . sliteralChar* . '\'' ) %literal;
- dliteral = ('"' @clearBuf . dliteralChar* . '"' ) %literal;
- literal = sliteral | dliteral;
-
- # Whitespace is standard ws, newlines and control codes.
- whitespace = any - 0x21..0x7e;
-
- # Describe both c style comments and c++ style comments. The
- # priority bump on tne terminator of the comments brings us
- # out of the extend* which matches everything.
- ccComment = '//' . extend* $0 . '\n' @1;
- cComment = '/*' . extend* $0 . '*/' @1;
-
- # Match an integer. We don't bother clearing the buf or filling it.
- # The float machine overlaps with int and it will do it.
- int = digit+ %int;
-
- # Match a float. Upon entering the machine clear the buf, buffer
- # characters on every trans and dump the float upon leaving.
- float = ( digit+ . '.' . digit+ ) >clearBuf $bufChar %float;
-
- # Match a hex. Upon entering the hex part, clear the buf, buffer characters
- # on every trans and dump the hex on leaving transitions.
- hex = '0x' . xdigit+ >clearBuf $bufChar %hex;
-
- # Or together all the lanuage elements.
- fin = ( ccComment |
- cComment |
- symbol |
- ident |
- literal |
- whitespace |
- int |
- float |
- hex );
-
- # Star the language elements. It is critical in this type of application
- # that we decrease the priority of out transitions before doing so. This
- # is so that when we see 'aa' we stay in the fin machine to match an ident
- # of length two and not wrap around to the front to match two idents of
- # length one.
- clang_main = ( fin $1 %0 )*;
-
- # This machine matches everything, taking note of newlines.
- newline = ( any | '\n' @{ curLine += 1; } )*;
-
- # The final fsm is the lexer intersected with the newline machine which
- # will count lines for us. Since the newline machine accepts everything,
- # the strings accepted is goverened by the clang_main machine, onto which
- # the newline machine overlays line counting.
- main := clang_main & newline;
-}%%
-
-@implementation Clang
-
-%% write data;
-
-- (void) initFsm;
-{
- identLen = 0;
- curLine = 1;
- %% write init;
-}
-
-- (void) executeWithData:(const char *)data len:(int)len;
-{
- const char *p = data;
- const char *pe = data + len;
- const char *eof = pe;
-
- %% write exec;
-}
-
-- (int) finish;
-{
- if ( cs == Clang_error )
- return -1;
- if ( cs >= Clang_first_final )
- return 1;
- return 0;
-}
-
-@end
-
-#define BUFSIZE 2048
-
-Clang *fsm;
-char buf[BUFSIZE];
-
-void test( char *buf )
-{
- int len = strlen(buf);
- fsm = [[Clang alloc] init];
- [fsm initFsm];
- [fsm executeWithData:buf len:len];
- if ( [fsm finish] > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
-}
-
-int main()
-{
- test(
- "999 0xaAFF99 99.99 /*\n"
- "*/ 'lksdj' //\n"
- "\"\n"
- "\n"
- "literal\n"
- "\n"
- "\n"
- "\"0x00aba foobardd.ddsf 0x0.9\n" );
-
- test(
- "wordwithnum00asdf\n"
- "000wordfollowsnum,makes new symbol\n"
- "\n"
- "finishing early /* unfinished ...\n" );
-
- test(
- "/*\n"
- " * Copyright\n"
- " */\n"
- "\n"
- "/* Aapl.\n"
- " */\n"
- " \n"
- "#define _AAPL_RESIZE_H\n"
- "\n"
- "#include <assert.h>\n"
- "\n"
- "#ifdef AAPL_NAMESPACE\n"
- "namespace Aapl {\n"
- "#endif\n"
- "#define LIN_DEFAULT_STEP 256\n"
- "#define EXPN_UP( existing, needed ) \\\n"
- " need > eng ? (ned<<1) : eing\n"
- " \n"
- "\n"
- "/*@}*/\n"
- "#undef EXPN_UP\n"
- "#ifdef AAPL_NAMESPACE\n"
- "#endif /* _AAPL_RESIZE_H */\n" );
- return 0;
-}
-
-##### OUTPUT #####
-int(1): 999
-hex(1): 0xaAFF99
-float(1): 99.99
-literal(2): lksdj
-literal(8):
-
-literal
-
-
-
-hex(8): 0x00aba
-ident(8): foobardd
-symbol(8): .
-ident(8): ddsf
-hex(8): 0x0
-symbol(8): .
-int(8): 9
-ACCEPT
-ident(1): wordwithnum00asdf
-int(2): 000
-ident(2): wordfollowsnum
-symbol(2): ,
-ident(2): makes
-ident(2): new
-ident(2): symbol
-ident(4): finishing
-ident(4): early
-FAIL
-symbol(8): #
-ident(8): define
-ident(8): _AAPL_RESIZE_H
-symbol(10): #
-ident(10): include
-symbol(10): <
-ident(10): assert
-symbol(10): .
-ident(10): h
-symbol(10): >
-symbol(12): #
-ident(12): ifdef
-ident(12): AAPL_NAMESPACE
-ident(13): namespace
-ident(13): Aapl
-symbol(13): {
-symbol(14): #
-ident(14): endif
-symbol(15): #
-ident(15): define
-ident(15): LIN_DEFAULT_STEP
-int(15): 256
-symbol(16): #
-ident(16): define
-ident(16): EXPN_UP
-symbol(16): (
-ident(16): existing
-symbol(16): ,
-ident(16): needed
-symbol(16): )
-symbol(16): \
-ident(17): need
-symbol(17): >
-ident(17): eng
-symbol(17): ?
-symbol(17): (
-ident(17): ned
-symbol(17): <
-symbol(17): <
-int(17): 1
-symbol(17): )
-symbol(17): :
-ident(17): eing
-symbol(21): #
-ident(21): undef
-ident(21): EXPN_UP
-symbol(22): #
-ident(22): ifdef
-ident(22): AAPL_NAMESPACE
-symbol(23): #
-ident(23): endif
-ACCEPT
diff --git a/test/ragel.d/clang3.rl b/test/ragel.d/clang3.rl
deleted file mode 100644
index a3c162fa..00000000
--- a/test/ragel.d/clang3.rl
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * @LANG: d
- * A mini C-like language scanner.
- */
-
-module clang;
-
-import std.c.stdio;
-import std.stdio;
-
-char[] string(char c)
-{
- char[] result = new char[2];
- result[0] = c;
- result[1] = 0;
- return result[0 .. 1];
-}
-
-class CLang
-{
- /* Parsing data. */
- char[] identBuf;
- int curLine;
-
- this()
- {
- }
-
- /* State machine operation data. */
- int cs;
-
- %%{
- machine clang;
-
- # Function to buffer a character.
- action bufChar {
- identBuf ~= fc;
- }
-
- # Function to clear the buffer.
- action clearBuf {
-
- identBuf = null;
- }
-
- # Functions to dump tokens as they are matched.
- action ident {
- writef( "ident(%d): %s\n", curLine, identBuf );
- }
- action literal {
- writef( "literal(%d): %s\n", curLine, identBuf );
- }
- action float {
- writef( "float(%d): %s\n", curLine, identBuf );
- }
- action int {
- writef( "int(%d): %s\n", curLine, identBuf );
- }
- action hex {
- writef( "hex(%d): 0x%s\n", curLine, identBuf );
- }
- action symbol {
- writef( "symbol(%d): %s\n", curLine, identBuf );
- }
-
- # Alpha numberic characters or underscore.
- alnumu = alnum | '_';
-
- # Alpha charactres or underscore.
- alphau = alpha | '_';
-
- # Symbols. Upon entering clear the buffer. On all transitions
- # buffer a character. Upon leaving dump the symbol.
- symbol = ( punct - [_'"] ) >clearBuf $bufChar %symbol;
-
- # Identifier. Upon entering clear the buffer. On all transitions
- # buffer a character. Upon leaving, dump the identifier.
- ident = (alphau . alnumu*) >clearBuf $bufChar %ident;
-
- # Match single characters inside literal strings. Or match
- # an escape sequence. Buffers the charater matched.
- sliteralChar =
- ( extend - ['\\] ) @bufChar |
- ( '\\' . extend @bufChar );
- dliteralChar =
- ( extend - ["\\] ) @bufChar |
- ( '\\' . extend @bufChar );
-
- # Single quote and double quota literals. At the start clear
- # the buffer. Upon leaving dump the literal.
- sliteral = ('\'' @clearBuf . sliteralChar* . '\'' ) %literal;
- dliteral = ('"' @clearBuf . dliteralChar* . '"' ) %literal;
- literal = sliteral | dliteral;
-
- # Whitespace is standard ws, newlines and control codes.
- whitespace = any - 0x21..0x7e;
-
- # Describe both c style comments and c++ style comments. The
- # priority bump on tne terminator of the comments brings us
- # out of the extend* which matches everything.
- ccComment = '//' . extend* $0 . '\n' @1;
- cComment = '/*' . extend* $0 . '*/' @1;
-
- # Match an integer. We don't bother clearing the buf or filling it.
- # The float machine overlaps with int and it will do it.
- int = digit+ %int;
-
- # Match a float. Upon entering the machine clear the buf, buffer
- # characters on every trans and dump the float upon leaving.
- float = ( digit+ . '.' . digit+ ) >clearBuf $bufChar %float;
-
- # Match a hex. Upon entering the hex part, clear the buf, buffer characters
- # on every trans and dump the hex on leaving transitions.
- hex = '0x' . xdigit+ >clearBuf $bufChar %hex;
-
- # Or together all the lanuage elements.
- fin = ( ccComment |
- cComment |
- symbol |
- ident |
- literal |
- whitespace |
- int |
- float |
- hex );
-
- # Star the language elements. It is critical in this type of application
- # that we decrease the priority of out transitions before doing so. This
- # is so that when we see 'aa' we stay in the fin machine to match an ident
- # of length two and not wrap around to the front to match two idents of
- # length one.
- clang_main = ( fin $1 %0 )*;
-
- # This machine matches everything, taking note of newlines.
- newline = ( any | '\n' @{ curLine++; } )*;
-
- # The final fsm is the lexer intersected with the newline machine which
- # will count lines for us. Since the newline machine accepts everything,
- # the strings accepted is goverened by the clang_main machine, onto which
- # the newline machine overlays line counting.
- main := clang_main & newline;
- }%%
-
- %% write data noprefix;
-
- // Initialize the machine. Invokes any init statement blocks. Returns 0
- // if the machine begins in a non-accepting state and 1 if the machine
- // begins in an accepting state.
- void init( )
- {
- curLine = 1;
- %% write init;
- }
-
- // Execute the machine on a block of data. Returns -1 if after processing
- // the data, the machine is in the error state and can never accept, 0 if
- // the machine is in a non-accepting state and 1 if the machine is in an
- // accepting state.
- void execute( const(char)* _data, ulong _len )
- {
- const(char)* p = _data;
- const(char)* pe = _data + _len;
- const(char)* eof = pe;
- %% write exec;
- }
-
- // Indicate that there is no more data. Returns -1 if the machine finishes
- // in the error state and does not accept, 0 if the machine finishes
- // in any other non-accepting state and 1 if the machine finishes in an
- // accepting state.
- int finish( )
- {
- if ( cs == error )
- return -1;
- if ( cs >= first_final )
- return 1;
- return 0;
- }
-}
-
-static const int BUFSIZE = 1024;
-
-void test( const char[] buf )
-{
- CLang scanner = new CLang();
- scanner.init();
- scanner.execute( buf.ptr, buf.length );
- if ( scanner.finish() > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
-}
-
-int main()
-{
- test(
- "999 0xaAFF99 99.99 /*\n"
- "*/ 'lksdj' //\n"
- "\"\n"
- "\n"
- "literal\n"
- "\n"
- "\n"
- "\"0x00aba foobardd.ddsf 0x0.9\n" );
-
- test(
- "wordwithnum00asdf\n"
- "000wordfollowsnum,makes new symbol\n"
- "\n"
- "finishing early /* unfinished ...\n" );
-
- test(
- "/*\n"
- " * Copyright\n"
- " */\n"
- "\n"
- "/* Aapl.\n"
- " */\n"
- " \n"
- "#define _AAPL_RESIZE_H\n"
- "\n"
- "#include <assert.h>\n"
- "\n"
- "#ifdef AAPL_NAMESPACE\n"
- "namespace Aapl {\n"
- "#endif\n"
- "#define LIN_DEFAULT_STEP 256\n"
- "#define EXPN_UP( existing, needed ) \\\n"
- " need > eng ? (ned<<1) : eing\n"
- " \n"
- "\n"
- "/*@}*/\n"
- "#undef EXPN_UP\n"
- "#ifdef AAPL_NAMESPACE\n"
- "#endif /* _AAPL_RESIZE_H */\n" );
- return 0;
-}
-
-##### OUTPUT #####
-int(1): 999
-hex(1): 0xaAFF99
-float(1): 99.99
-literal(2): lksdj
-literal(8):
-
-literal
-
-
-
-hex(8): 0x00aba
-ident(8): foobardd
-symbol(8): .
-ident(8): ddsf
-hex(8): 0x0
-symbol(8): .
-int(8): 9
-ACCEPT
-ident(1): wordwithnum00asdf
-int(2): 000
-ident(2): wordfollowsnum
-symbol(2): ,
-ident(2): makes
-ident(2): new
-ident(2): symbol
-ident(4): finishing
-ident(4): early
-FAIL
-symbol(8): #
-ident(8): define
-ident(8): _AAPL_RESIZE_H
-symbol(10): #
-ident(10): include
-symbol(10): <
-ident(10): assert
-symbol(10): .
-ident(10): h
-symbol(10): >
-symbol(12): #
-ident(12): ifdef
-ident(12): AAPL_NAMESPACE
-ident(13): namespace
-ident(13): Aapl
-symbol(13): {
-symbol(14): #
-ident(14): endif
-symbol(15): #
-ident(15): define
-ident(15): LIN_DEFAULT_STEP
-int(15): 256
-symbol(16): #
-ident(16): define
-ident(16): EXPN_UP
-symbol(16): (
-ident(16): existing
-symbol(16): ,
-ident(16): needed
-symbol(16): )
-symbol(16): \
-ident(17): need
-symbol(17): >
-ident(17): eng
-symbol(17): ?
-symbol(17): (
-ident(17): ned
-symbol(17): <
-symbol(17): <
-int(17): 1
-symbol(17): )
-symbol(17): :
-ident(17): eing
-symbol(21): #
-ident(21): undef
-ident(21): EXPN_UP
-symbol(22): #
-ident(22): ifdef
-ident(22): AAPL_NAMESPACE
-symbol(23): #
-ident(23): endif
-ACCEPT
diff --git a/test/ragel.d/clang4.rl b/test/ragel.d/clang4.rl
deleted file mode 100644
index b033a479..00000000
--- a/test/ragel.d/clang4.rl
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * @LANG: indep
- * @NEEDS_EOF: yes
- */
-
-int pos;
-int line;
-
-pos = 0;
-line = 1;
-%%{
- machine clang;
-
- # Function to buffer a character.
- action bufChar { buf_append(); }
-
- # Function to clear the buffer.
- action clearBuf { buf_clear(); }
-
- action incLine { line = line + 1; }
-
- # Functions to dump tokens as they are matched.
- action ident {
- print_str "ident(";
- print_int line;
- print_str ",";
- print_int blen;
- print_str "): ";
- print_str buffer;
- print_str "\n";
- }
- action literal {
- print_str "literal(";
- print_int line;
- print_str ",";
- print_int blen;
- print_str "): ";
- print_str buffer;
- print_str "\n";
- }
- action float {
- print_str "float(";
- print_int line;
- print_str ",";
- print_int blen;
- print_str "): ";
- print_str buffer;
- print_str "\n";
- }
- action integer {
- print_str "int(";
- print_int line;
- print_str ",";
- print_int blen;
- print_str "): ";
- print_str buffer;
- print_str "\n";
- }
- action hex {
- print_str "hex(";
- print_int line;
- print_str ",";
- print_int blen;
- print_str "): ";
- print_str buffer;
- print_str "\n";
- }
- action symbol {
- print_str "symbol(";
- print_int line;
- print_str ",";
- print_int blen;
- print_str "): ";
- print_str buffer;
- print_str "\n";
- }
-
- # Alpha numberic characters or underscore.
- alnumu = alnum | '_';
-
- # Alpha charactres or underscore.
- alphau = alpha | '_';
-
- # Symbols. Upon entering clear the buffer. On all transitions
- # buffer a character. Upon leaving dump the symbol.
- symbol = ( punct - [_'"] ) >clearBuf $bufChar %symbol;
-
- # Identifier. Upon entering clear the buffer. On all transitions
- # buffer a character. Upon leaving, dump the identifier.
- ident = (alphau . alnumu*) >clearBuf $bufChar %ident;
-
- # Match single characters inside literal strings. Or match
- # an escape sequence. Buffers the charater matched.
- sliteralChar =
- ( extend - ['\\] ) @bufChar |
- ( '\\' . extend @bufChar );
- dliteralChar =
- ( extend - ["\\] ) @bufChar |
- ( '\\' . extend @bufChar );
-
- # Single quote and double quota literals. At the start clear
- # the buffer. Upon leaving dump the literal.
- sliteral = ('\'' @clearBuf . sliteralChar* . '\'' ) %literal;
- dliteral = ('"' @clearBuf . dliteralChar* . '"' ) %literal;
- literal = sliteral | dliteral;
-
- # Whitespace is standard ws, newlines and control codes.
- whitespace = any - 33 .. 126;
-
- # Describe both c style comments and c++ style comments. The
- # priority bump on tne terminator of the comments brings us
- # out of the extend* which matches everything.
- ccComment = '//' . extend* $0 . '\n' @1;
- cComment = '/!' . extend* $0 . '!/' @1;
-
- # Match an integer. We don't bother clearing the buf or filling it.
- # The float machine overlaps with int and it will do it.
- integer = digit+ %integer;
-
- # Match a float. Upon entering the machine clear the buf, buffer
- # characters on every trans and dump the float upon leaving.
- float = ( digit+ . '.' . digit+ ) >clearBuf $bufChar %float;
-
- # Match a hex. Upon entering the hex part, clear the buf, buffer characters
- # on every trans and dump the hex on leaving transitions.
- hex = '0x' . xdigit+ >clearBuf $bufChar %hex;
-
- # Or together all the lanuage elements.
- fin = ( ccComment |
- cComment |
- symbol |
- ident |
- literal |
- whitespace |
- integer |
- float |
- hex );
-
- # Star the language elements. It is critical in this type of application
- # that we decrease the priority of out transitions before doing so. This
- # is so that when we see 'aa' we stay in the fin machine to match an ident
- # of length two and not wrap around to the front to match two idents of
- # length one.
- clang_main = ( fin $1 %0 )*;
-
- # This machine matches everything, taking note of newlines.
- newline = ( any | '\n' @incLine )*;
-
- # The final fsm is the lexer intersected with the newline machine which
- # will count lines for us. Since the newline machine accepts everything,
- # the strings accepted is goverened by the clang_main machine, onto which
- # the newline machine overlays line counting.
- main := clang_main & newline;
-}%%
-
-##### INPUT #####
-"999 0xaAFF99 99.99 /!\n!/ 'lksdj' //\n\"\n\nliteral\n\n\n\"0x00aba foobardd.ddsf 0x0.9\n"
-"wordwithnum00asdf\n000wordfollowsnum,makes new symbol\n\nfinishing early /! unfinished ...\n"
-##### OUTPUT #####
-int(1,3): 999
-hex(1,6): aAFF99
-float(1,5): 99.99
-literal(2,5): lksdj
-literal(8,12):
-
-literal
-
-
-
-hex(8,5): 00aba
-ident(8,8): foobardd
-symbol(8,1): .
-ident(8,4): ddsf
-hex(8,1): 0
-symbol(8,1): .
-int(8,1): 9
-ACCEPT
-ident(1,17): wordwithnum00asdf
-int(2,3): 000
-ident(2,14): wordfollowsnum
-symbol(2,1): ,
-ident(2,5): makes
-ident(2,3): new
-ident(2,6): symbol
-ident(4,9): finishing
-ident(4,5): early
-FAIL
diff --git a/test/ragel.d/clang5.rl b/test/ragel.d/clang5.rl
deleted file mode 100644
index c4633c09..00000000
--- a/test/ragel.d/clang5.rl
+++ /dev/null
@@ -1,151 +0,0 @@
-(*
- * @LANG: ocaml
- *)
-
-let id x = x
-let fail fmt = Printf.ksprintf failwith fmt
-let pr fmt = Printf.ksprintf print_endline fmt
-
-let failed fmt = Printf.ksprintf (fun s -> prerr_endline s; exit 1) fmt
-let test' show f x y = if f x <> y then failed "FAILED: test %S" (show x)
-let case = ref 0
-let test f x y = incr case; if f x <> y then failed "FAILED: case %d" !case
-let error f x = match try Some (f x) with _ -> None with Some _ -> failed "FAILED: fail %S" x | None -> ()
-
-
-%%{
- machine clang;
-
- newline = '\n' @{ incr curlin };
- any_count_line = any | newline;
-
- # Consume a C comment.
- c_comment := any_count_line* :>> '*/' @{fgoto main;};
-
- main := |*
-
- # Alpha numberic characters or underscore.
- alnum_u = alnum | '_';
-
- # Alpha charactres or underscore.
- alpha_u = alpha | '_';
-
- # Symbols. Upon entering clear the buffer. On all transitions
- # buffer a character. Upon leaving dump the symbol.
- ( punct - [_'"] ) {
- pr "symbol(%i): %c" !curlin data.[!ts];
- };
-
- # Identifier. Upon entering clear the buffer. On all transitions
- # buffer a character. Upon leaving, dump the identifier.
- alpha_u alnum_u* {
- pr "ident(%i): %s" !curlin (String.sub data !ts (!te - !ts));
- };
-
- # Single Quote.
- sliteralChar = [^'\\] | newline | ( '\\' . any_count_line );
- '\'' . sliteralChar* . '\'' {
- pr "single_lit(%i): %s" !curlin (String.sub data !ts (!te - !ts));
- };
-
- # Double Quote.
- dliteralChar = [^"\\] | newline | ( '\\' any_count_line );
- '"' . dliteralChar* . '"' {
- pr "double_lit(%i): %s" !curlin (String.sub data !ts (!te - !ts));
- };
-
- # Whitespace is standard ws, newlines and control codes.
- any_count_line - 0x21..0x7e;
-
- # Describe both c style comments and c++ style comments. The
- # priority bump on tne terminator of the comments brings us
- # out of the extend* which matches everything.
- '//' [^\n]* newline;
-
- '/*' { fgoto c_comment; };
-
- # Match an integer. We don't bother clearing the buf or filling it.
- # The float machine overlaps with int and it will do it.
- digit+ {
- pr "int(%i): %s" !curlin (String.sub data !ts (!te - !ts));
- };
-
- # Match a float. Upon entering the machine clear the buf, buffer
- # characters on every trans and dump the float upon leaving.
- digit+ '.' digit+ {
- pr "float(%i): %s" !curlin (String.sub data !ts (!te - !ts));
- };
-
- # Match a hex. Upon entering the hex part, clear the buf, buffer characters
- # on every trans and dump the hex on leaving transitions.
- '0x' xdigit+ {
- pr "hex(%i): %s" !curlin (String.sub data !ts (!te - !ts));
- };
-
- *|;
-}%%
-
-%% write data;
-
-let clang data =
- let cs = ref 0 in
- let p = ref 0 in
- let pe = ref (String.length data) in
- let ts = ref 0 in
- let te = ref 0 in
- let eof = pe in
- let curlin = ref 1 in
-
- %%{
- write init;
- write exec;
- }%%
-
- if !cs < clang_first_final then
- fail "atoi: cs %d < %d" !cs clang_first_final;
-;;
-
-let () =
- clang "999 0xaAFF99 99.99 /!\n!/ 'lksdj' //\n\"\n\nliteral\n\n\n\"0x00aba foobardd.ddsf 0x0.9\n";
- clang "wordwithnum00asdf\n000wordfollowsnum,makes new symbol\n\nfinishing early /! unfinished ...\n";
- ()
-;;
-
-
-##### OUTPUT #####
-int(1): 999
-hex(1): 0xaAFF99
-float(1): 99.99
-symbol(1): /
-symbol(1): !
-symbol(2): !
-symbol(2): /
-single_lit(2): 'lksdj'
-double_lit(8): "
-
-literal
-
-
-"
-hex(8): 0x00aba
-ident(8): foobardd
-symbol(8): .
-ident(8): ddsf
-hex(8): 0x0
-symbol(8): .
-int(8): 9
-ident(1): wordwithnum00asdf
-int(2): 000
-ident(2): wordfollowsnum
-symbol(2): ,
-ident(2): makes
-ident(2): new
-ident(2): symbol
-ident(4): finishing
-ident(4): early
-symbol(4): /
-symbol(4): !
-ident(4): unfinished
-symbol(4): .
-symbol(4): .
-symbol(4): .
diff --git a/test/ragel.d/cond1.rl b/test/ragel.d/cond1.rl
deleted file mode 100644
index 58a31dca..00000000
--- a/test/ragel.d/cond1.rl
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * @LANG: indep
- */
-
-bool i;
-bool j;
-bool k;
-
-%%{
- machine foo;
-
- action c1 {i}
- action c2 {j}
- action c3 {k}
- action one { print_str " one\n";}
- action two { print_str " two\n";}
- action three { print_str " three\n";}
-
- action seti {
- if ( fc == 48 ) {
- i = false;
- } else {
- i = true;
- }
- }
- action setj {
- if ( fc == 48 ) {
- j = false;
- } else {
- j = true;
- }
- }
- action setk {
- if ( fc == 48 ) {
- k = false;
- } else {
- k = true;
- }
- }
-
- action break {fnbreak;}
-
- one = 'a' 'b' when c1 'c' @one;
- two = 'a'* 'b' when c2 'c' @two;
- three = 'a'+ 'b' when c3 'c' @three;
-
- main :=
- [01] @seti
- [01] @setj
- [01] @setk
- ( one | two | three ) '\n' @break;
-
-}%%
-
-##### INPUT #####
-"000abc\n"
-"100abc\n"
-"010abc\n"
-"110abc\n"
-"001abc\n"
-"101abc\n"
-"011abc\n"
-"111abc\n"
-##### OUTPUT #####
-FAIL
- one
-ACCEPT
- two
-ACCEPT
- one
- two
-ACCEPT
- three
-ACCEPT
- one
- three
-ACCEPT
- two
- three
-ACCEPT
- one
- two
- three
-ACCEPT
diff --git a/test/ragel.d/cond10.rl b/test/ragel.d/cond10.rl
deleted file mode 100644
index 50b50d28..00000000
--- a/test/ragel.d/cond10.rl
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * @LANG: c++
- *
- * This test case exercises repetition of a machine that accepts zero-length
- * string. It is very ambiguous and not useful as a pattern.
- */
-
-#include <iostream>
-#include <string.h>
-
-using std::cout;
-using std::endl;
-
-%%{
- machine foo;
- alphtype char;
-
- action bs_b { bs_b( src, p ) }
- action bol { p == src }
- action eol { p+1 == eof }
-
- b = '' %when bs_b;
- B = '' %when !bs_b;
- bol = '' %when bol;
- eol = '' %when eol;
-
- # {1,25}
- action ini_4 { q_4 = 0; }
- action inc_4 { q_4++; }
- action min_4 { q_4 >= 1 }
- action max_4 { q_4 < 25 }
-
- # {1,5}
- action ini_5 { q_5 = 0; }
- action inc_5 { q_5++; }
- action min_5 { q_5 >= 1 }
- action max_5 { q_5 < 5 }
-
- # {100}
- action ini_6 { q_6 = 0; }
- action inc_6 { q_6++; }
- action min_6 { q_6 >= 100 }
- action max_6 { q_6 < 100 }
-
- R5306833741170350 =
- ( '<' 47 's' 't' 'y' 'l' 'e' '>' '<'
- (:condstar( ( ( (:condstar( ( [a-zA-Z0-9_] ), ini_4, inc_4, min_4, max_4 ): )
- (:condstar( ( ' ' ), ini_5, inc_5, min_5, max_5 ): ) ) ), ini_6, inc_6, min_6, max_6 ): ) )
- :> any @{ match = 1; };
-
- main := R5306833741170350;
-}%%
-
-%% write data;
-
-void test( const char *str )
-{
- int cs = foo_start;
- const char *p = str;
- const char *pe = str + strlen( str );
- int match = 0;
-
- long q_4 = 0, q_5 = 0, q_6 = 0;
-
- cout << "run:" << endl;
- %% write exec;
- if ( match )
- cout << " success" << endl;
- else
- cout << " failure" << endl;
- cout << endl;
-}
-
-int main()
-{
- return 0;
-}
-
-##### OUTPUT #####
diff --git a/test/ragel.d/cond11.rl b/test/ragel.d/cond11.rl
deleted file mode 100644
index be63e63c..00000000
--- a/test/ragel.d/cond11.rl
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * @LANG: indep
- * @NEEDS_EOF: yes
- */
-
-int q;
-
-%%{
- machine foo;
-
- action match { print_str "match\n"; }
-
- action ini_0 { q = 0; }
- action inc_0 { q = q + 1; }
- action min_0 { q >= 5 }
- action max_0 { q < 5 }
-
- action t { true }
-
- main :=
- ( :condstar( ('a'), ini_0, inc_0, min_0, max_0 ): )
- ( '' %when t | '' %when !t ) %when { 1==1 } %when { 2==2 } %when { 3==3 } %match;
-
-}%%
-
-##### INPUT #####
-""
-"a"
-"aaaa"
-"aaaaa"
-"aaaaaa"
-"aaaaaaa"
-##### OUTPUT #####
-FAIL
-FAIL
-FAIL
-match
-ACCEPT
-FAIL
-FAIL
diff --git a/test/ragel.d/cond2.rl b/test/ragel.d/cond2.rl
deleted file mode 100644
index 507522b5..00000000
--- a/test/ragel.d/cond2.rl
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * @LANG: c++
- */
-
-#include <iostream>
-#include <string.h>
-using std::cout;
-using std::endl;
-
-%%{
- machine foo;
-
- action c1 {i}
- action c2 {j}
-
- action one { cout << " one" << endl;}
- action two { cout << " two" << endl;}
-
- main := (
- [a-z] |
- ('\n' when c1 @one)
- )*
- ('\n' when c2 @two);
-}%%
-
-%% write data noerror;
-
-void test( int i, int j, const char *str )
-{
- int cs = foo_start;
- const char *p = str;
- const char *pe = str + strlen( str );
-
- cout << "run:" << endl;
- %% write exec;
- if ( cs >= foo_first_final )
- cout << " success" << endl;
- else
- cout << " failure" << endl;
- cout << endl;
-}
-
-int main()
-{
- test( 0, 0, "hi\n\n" );
- test( 1, 0, "hi\n\n" );
- test( 0, 1, "hi\n" );
- test( 0, 1, "hi\n\n" );
- test( 1, 1, "hi\n" );
- test( 1, 1, "hi\n\n" );
- test( 1, 1, "hi\n\nx" );
- return 0;
-}
-
-##### OUTPUT #####
-run:
- failure
-
-run:
- one
- one
- failure
-
-run:
- two
- success
-
-run:
- two
- failure
-
-run:
- one
- two
- success
-
-run:
- one
- two
- one
- two
- success
-
-run:
- one
- two
- one
- two
- failure
-
diff --git a/test/ragel.d/cond3.rl b/test/ragel.d/cond3.rl
deleted file mode 100644
index d08b0d75..00000000
--- a/test/ragel.d/cond3.rl
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * @LANG: c++
- */
-
-#include <iostream>
-#include <string.h>
-using std::cout;
-using std::endl;
-
-%%{
- machine foo;
-
- action hit_5 {c == 5}
- action done { cout << " done" << endl; }
- action inc {c++;}
-
- # The any* includes '\n' when hit_5 is true, so use guarded concatenation.
- main := (any @inc)* :> '\n' when hit_5 @done;
-}%%
-
-%% write data noerror;
-
-void test( const char *str )
-{
- int cs = foo_start;
- int c = 0;
- const char *p = str;
- const char *pe = str + strlen( str );
-
- cout << "run:" << endl;
- %% write exec;
- if ( cs >= foo_first_final )
- cout << " success" << endl;
- else
- cout << " failure" << endl;
- cout << endl;
-}
-
-int main()
-{
- test( "12345\n" ); // success
- test( "\n2345\n" ); // success, first newline ignored
- test( "1234\n" ); // failure, didn't get 5 chars before newline.
- return 0;
-}
-
-##### OUTPUT #####
-run:
- done
- success
-
-run:
- done
- success
-
-run:
- failure
-
diff --git a/test/ragel.d/cond4.rl b/test/ragel.d/cond4.rl
deleted file mode 100644
index a110bee8..00000000
--- a/test/ragel.d/cond4.rl
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * @LANG: c++
- */
-
-#include <iostream>
-#include <string.h>
-using std::cout;
-using std::endl;
-
-%%{
- machine foo;
-
- action c1 {(cout << "c1 ", true)}
- action c2 {(cout << "c2 ", true)}
- action c3 {(cout << "c3 ", true)}
- action c4 {(cout << "c4 ", true)}
-
- main := (
- 10 .. 60 when c1 |
- 20 .. 40 when c2 |
- 30 .. 50 when c3 |
- 32 .. 38 when c4 |
- 0 .. 70 )* ${cout << "char: " << (int)*p << endl;};
-}%%
-
-%% write data noerror nofinal;
-
-void test( char *str )
-{
- int len = strlen( str );
- int cs = foo_start;
- char *p = str, *pe = str+len;
- %% write exec;
-}
-
-char data[] = { 5, 15, 25, 31, 35, 39, 45, 55, 65, 0 };
-
-int main()
-{
- test( data );
- return 0;
-}
-
-##### OUTPUT #####
-char: 5
-c1 char: 15
-c1 c2 char: 25
-c1 c2 c3 char: 31
-c1 c2 c3 c4 char: 35
-c1 c2 c3 char: 39
-c1 c3 char: 45
-c1 char: 55
-char: 65
diff --git a/test/ragel.d/cond5.rl b/test/ragel.d/cond5.rl
deleted file mode 100644
index db7afea6..00000000
--- a/test/ragel.d/cond5.rl
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * @LANG: c++
- */
-
-#include <iostream>
-#include <string.h>
-using std::cout;
-using std::endl;
-
-%%{
- machine foo;
- write data noerror;
-}%%
-
-void test( const char *str )
-{
- int cs = foo_start;
- int c = 0;
- const char *p = str;
- const char *pe = str + strlen( str );
- char last = '0';
-
- cout << "run:";
- %%{
- action d1 { cout << " d1"; }
- action see_five { cout << " see_five"; }
-
- see_five = ([0-9] when{c++ < 5} @d1)* '\n' @see_five;
-
- action in_sequence { cout << " in_sequence"; }
- action d2 { last = *p; cout << " d2"; }
- in_sequence = ( [0-9] when { *p == last+1 } @d2 )* '\n' @in_sequence;
-
- main := ( see_five | in_sequence ) ${cout << " |";};
-
- write exec;
- }%%
- if ( cs < foo_first_final )
- cout << " failure";
- cout << endl;
-}
-
-int main()
-{
- test( "123456789012\n" ); // fails both
- test( "123456789\n" ); // fails five
- test( "1234\n" ); // fails five
- test( "13245\n" ); // fails sequence
- test( "12345\n" ); // succeeds in both
- return 0;
-}
-
-##### OUTPUT #####
-run: d1 d2 | d1 d2 | d1 d2 | d1 d2 | d1 d2 | d2 | d2 | d2 | d2 | failure
-run: d1 d2 | d1 d2 | d1 d2 | d1 d2 | d1 d2 | d2 | d2 | d2 | d2 | in_sequence |
-run: d1 d2 | d1 d2 | d1 d2 | d1 d2 | see_five in_sequence |
-run: d1 d2 | d1 | d1 | d1 | d1 | see_five |
-run: d1 d2 | d1 d2 | d1 d2 | d1 d2 | d1 d2 | see_five in_sequence |
diff --git a/test/ragel.d/cond6.rl b/test/ragel.d/cond6.rl
deleted file mode 100644
index 4d66956f..00000000
--- a/test/ragel.d/cond6.rl
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * @LANG: c++
- */
-
-/* Balanced parenthesis with conditions. */
-
-#include <iostream>
-#include <string.h>
-using std::cout;
-using std::endl;
-
-%%{
- machine cond;
- write data noerror;
-}%%
-
-void test( const char *str )
-{
- int cs = cond_start, n = 0;
- const char *p = str;
- const char *pe = str + strlen( str );
-
- %%{
- comment = '(' @{n=0;}
- ( '('@{n++;} | ')'@{n--;} | [^()] )*
- :> ')' when{!n};
-
- main := ' '* comment ' '* '\n' @{cout << "success";};
-
- write exec;
- }%%
- if ( cs < cond_first_final )
- cout << "failure";
- cout << endl;
-}
-
-int main()
-{
- test( "( ( )\n" );
- test( "()()\n" );
- test( "(((\n" );
- test( "((()\n" );
- test( "((())\n" );
- test( "()\n" );
- test( "((()))\n" );
- test( "(()())\n" );
- test( "((())()(((()))))\n" );
- return 0;
-}
-
-##### OUTPUT #####
-failure
-failure
-failure
-failure
-failure
-success
-success
-success
-success
diff --git a/test/ragel.d/cond7.rl b/test/ragel.d/cond7.rl
deleted file mode 100644
index 2fb66b4b..00000000
--- a/test/ragel.d/cond7.rl
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * @LANG: indep
- */
-
-int i;
-int c;
-
-%%{
- machine foo;
-
- action testi {i > 0}
- action inc {
- i = i - 1;
- c = <int>(fc);
- print_str "item: ";
- print_int c;
- print_str "\n";
- }
-
- count = [0-9] @{
- i = <int>(fc - 48);
- print_str "count: ";
- print_int i;
- print_str "\n";
- };
-
- sub =
- count # record the number of digits
- ( digit when testi @inc )* outwhen !testi;
-
- main := sub sub '\n';
-}%%
-
-##### INPUT #####
-"00\n"
-"019\n"
-"190\n"
-"1719\n"
-"1040000\n"
-"104000a\n"
-"104000\n"
-##### OUTPUT #####
-count: 0
-count: 0
-ACCEPT
-count: 0
-count: 1
-item: 57
-ACCEPT
-count: 1
-item: 57
-count: 0
-ACCEPT
-count: 1
-item: 55
-count: 1
-item: 57
-ACCEPT
-count: 1
-item: 48
-count: 4
-item: 48
-item: 48
-item: 48
-item: 48
-ACCEPT
-count: 1
-item: 48
-count: 4
-item: 48
-item: 48
-item: 48
-FAIL
-count: 1
-item: 48
-count: 4
-item: 48
-item: 48
-item: 48
-FAIL
diff --git a/test/ragel.d/cond8.rl b/test/ragel.d/cond8.rl
deleted file mode 100644
index bb7e0939..00000000
--- a/test/ragel.d/cond8.rl
+++ /dev/null
@@ -1,55 +0,0 @@
-(*
- * @LANG: ocaml
- *)
-
-let id x = x
-let fail fmt = Printf.ksprintf failwith fmt
-let pr fmt = Printf.ksprintf print_endline fmt
-
-let failed fmt = Printf.ksprintf (fun s -> prerr_endline s; exit 1) fmt
-let test' show f x y = if f x <> y then failed "FAILED: test %S" (show x)
-let case = ref 0
-let test f x y = incr case; if f x <> y then failed "FAILED: case %d" !case
-let error f x = match try Some (f x) with _ -> None with Some _ -> failed "FAILED: fail %S" x | None -> ()
-
-%% machine cond;
-%% write data;
-
-let fail fmt = Printf.ksprintf failwith fmt
-
-let run data n =
- let cs = ref 0 in
- let p = ref 0 in
- let pe = ref (String.length data) in
- let i = ref 0 in
-
- %%{
- action test_len { i < n }
-
- main := (
- "d"
- [0-9]+
- ":"
- ( [a-z] when test_len )* ${ i := i.contents + 1 }
- )**;
-
- write init;
- write exec;
- }%%
-
- if !cs < cond_first_final then
- print_string "fail\n"
- else
- print_string "ok\n"
-
-let () =
- run "d2:abc" ( ref 1 );
- run "d2:abc" ( ref 2 );
- run "d2:abc" ( ref 3 );
- run "d2:abc" ( ref 4 );
-
-##### OUTPUT #####
-fail
-fail
-ok
-ok
diff --git a/test/ragel.d/cond9.rl b/test/ragel.d/cond9.rl
deleted file mode 100644
index b7fdf055..00000000
--- a/test/ragel.d/cond9.rl
+++ /dev/null
@@ -1,292 +0,0 @@
-#
-# @LANG: asm
-#
-
-%%{
- machine foo;
-
- action c1 {
- /* i != 0 */
- movl i(%rip), %eax
- }
- action c2 {
- /* j != 0 */
- movl j(%rip), %eax
- }
- action c3 {
- /* k != 0 */
- movl k(%rip), %eax
- }
-
- action one {
- /* print_str " one\n"; */
- movl $.L_one, %edi
- call puts
- }
- action two {
- /* print_str " two\n"; */
- movl $.L_two, %edi
- call puts
- }
- action three {
- /* print_str " three\n"; */
- movl $.L_three, %edi
- call puts
- }
-
- action seti {
- //if ( fc == 48 )
- // i = false;
- //else
- // i = true;
- movb (%r12), %al
- cmpb $48, %al
- setne %al
- movsbl %al, %eax
- movl %eax, i(%rip)
- }
- action setj {
- // if ( fc == 48 )
- // j = false;
- // else
- // j = true;
- movb (%r12), %al
- cmpb $48, %al
- setne %al
- movsbl %al, %eax
- movl %eax, j(%rip)
- }
- action setk {
- // if ( fc == 48 )
- // k = false;
- // else
- // k = true;
- movb (%r12), %al
- cmpb $48, %al
- setne %al
- movsbl %al, %eax
- movl %eax, k(%rip)
- }
-
- action break {fnbreak;}
-
- one = 'a' 'b' when c1 'c' @one;
- two = 'a'* 'b' when c2 'c' @two;
- three = 'a'+ 'b' when c3 'c' @three;
-
- main :=
- [01] @seti
- [01] @setj
- [01] @setk
- ( one | two | three ) '\n' @break;
-
-}%%
-
- .file "cond1_c.c"
- .comm i,4,4
- .comm j,4,4
- .comm k,4,4
- .comm cs,4,4
- .section .rodata
-
-%% write data;
-
- .text
- .globl init
- .type init, @function
-init:
-.LFB0:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
-
-%% write init;
-
- movq %r11, cs(%rip)
-
- popq %rbp
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE0:
- .size init, .-init
- .section .rodata
-.L_one:
- .string " one"
-.L_two:
- .string " two"
-.L_three:
- .string " three"
- .text
- .globl exec
- .type exec, @function
-exec:
-.LFB1:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- subq $96, %rsp
-
- push %r12
- push %r13
-
- movq cs(%rip), %r11
- movq %rdi, %r12
- movq %rsi, %r13
-
-%% write exec;
-
- movq %r11, cs(%rip)
-
- pop %r13
- pop %r12
-
- leave
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE1:
- .size exec, .-exec
- .section .rodata
-.LC3:
- .string "ACCEPT"
-.LC4:
- .string "FAIL"
- .text
- .globl finish
- .type finish, @function
-finish:
-.LFB2:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- movl cs(%rip), %edx
- movl $15, %eax
- cmpl %eax, %edx
- jl .L69
- movl $.LC3, %edi
- call puts
- jmp .L68
-.L69:
- movl $.LC4, %edi
- call puts
-.L68:
- popq %rbp
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE2:
- .size finish, .-finish
- .globl inp
- .section .rodata
-.LC5:
- .string "000abc\n"
-.LC6:
- .string "100abc\n"
-.LC7:
- .string "010abc\n"
-.LC8:
- .string "110abc\n"
-.LC9:
- .string "001abc\n"
-.LC10:
- .string "101abc\n"
-.LC11:
- .string "011abc\n"
-.LC12:
- .string "111abc\n"
- .data
- .align 32
- .type inp, @object
- .size inp, 64
-inp:
- .quad .LC5
- .quad .LC6
- .quad .LC7
- .quad .LC8
- .quad .LC9
- .quad .LC10
- .quad .LC11
- .quad .LC12
- .globl inplen
- .align 4
- .type inplen, @object
- .size inplen, 4
-inplen:
- .long 8
- .text
- .globl main
- .type main, @function
-main:
-.LFB3:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- subq $16, %rsp
- movl $0, -4(%rbp)
- jmp .L72
-.L73:
- movl $0, %eax
- call init
- movl -4(%rbp), %eax
- cltq
- movq inp(,%rax,8), %rax
- movq %rax, %rdi
- call strlen
- movl %eax, %edx
- movl -4(%rbp), %eax
- cltq
- movq inp(,%rax,8), %rax
- movslq %edx, %rsi
- addq %rax, %rsi
- movq %rax, %rdi
- call exec
- movl $0, %eax
- call finish
- addl $1, -4(%rbp)
-.L72:
- movl inplen(%rip), %eax
- cmpl %eax, -4(%rbp)
- jl .L73
- movl $0, %eax
- leave
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE3:
- .size main, .-main
- .ident "GCC: (Ubuntu 4.8.2-19ubuntu1) 4.8.2"
- .section .note.GNU-stack,"",@progbits
-##### OUTPUT #####
-FAIL
- one
-ACCEPT
- two
-ACCEPT
- one
- two
-ACCEPT
- three
-ACCEPT
- one
- three
-ACCEPT
- two
- three
-ACCEPT
- one
- two
- three
-ACCEPT
diff --git a/test/ragel.d/conderr1.rl b/test/ragel.d/conderr1.rl
deleted file mode 100644
index 4e1288c0..00000000
--- a/test/ragel.d/conderr1.rl
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * @LANG: c++
- */
-
-#include <iostream>
-#include <string.h>
-using std::cout;
-using std::endl;
-
-%%{
- machine foo;
-
- action c {c}
- main :=
- ( ( 'a' when c )+ ) $err{ cout << " bail" << endl; }
- '\n';
-}%%
-
-%% write data noerror;
-
-void test( int c, const char *str )
-{
- int cs = foo_start;
- const char *p = str;
- const char *pe = str + strlen( str );
- const char *eof = pe;
-
- cout << "run:" << endl;
- %% write exec;
- if ( cs >= foo_first_final )
- cout << " success" << endl;
- else
- cout << " failure" << endl;
- cout << endl;
-}
-
-int main()
-{
- test( 1, "aa\n" );
- test( 1, "ab\n" );
- test( 0, "aa\n" );
- test( 0, "ab\n" );
- return 0;
-}
-
-##### OUTPUT #####
-run:
- success
-
-run:
- bail
- failure
-
-run:
- bail
- failure
-
-run:
- bail
- failure
-
diff --git a/test/ragel.d/conderr2.rl b/test/ragel.d/conderr2.rl
deleted file mode 100644
index f62cb0f7..00000000
--- a/test/ragel.d/conderr2.rl
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stdio.h>
-
-%%{
- machine foo;
-
- sep = ( [ ] | ';' when { 0 } )+;
-
- cmt =
- ^[ ;] >!{ printf("A\n"); } .
- 'x' >!{ printf("B\n"); };
-
- main := sep . cmt;
-}%%
-
-%% write data;
-
-int main()
-{
- char buffer[] = " ;";
-
- char *p = buffer;
- char *pe = buffer + sizeof(buffer);
- char *eof = pe;
- int cs = foo_start;
-
- %% write exec;
-
- return 0;
-}
-
-##### OUTPUT #####
-A
diff --git a/test/ragel.d/condrep1.rl b/test/ragel.d/condrep1.rl
deleted file mode 100644
index 10ae8949..00000000
--- a/test/ragel.d/condrep1.rl
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * @LANG: c++
- */
-
-#include <iostream>
-#include <string.h>
-using std::cout;
-using std::endl;
-
-%%{
- machine foo;
-
- action seen { seen += 1; }
-
- action init { c = 0; }
- action inc { c += 1; }
- action min { ({ c >= min; }) }
- action max { ({ c < max; }) }
-
- main :=
- :condstar( '.' @seen, init, inc, min, max ):
- 0;
-
-}%%
-
-%% write data noerror;
-
-void test( int min, int max, const char *str )
-{
- int cs;
- const char *p = str;
- const char *pe = str + strlen( str ) + 1;
- int c = 0, seen = 0;
-
- cout << "run " << str << " " << min << " " << max << ":";
-
- %% write init;
- %% write exec;
-
- cout << " " << seen;
-
- if ( cs >= foo_first_final )
- cout << " success" << endl;
- else
- cout << " failure" << endl;
-}
-
-int main()
-{
- test( 0, 0, "" );
- test( 0, 1, "" );
- test( 1, 1, "" );
- test( 1, 2, "" );
- test( 2, 2, "" );
- test( 2, 3, "" );
-
- test( 0, 0, "." );
- test( 0, 1, "." );
- test( 1, 1, "." );
- test( 1, 2, "." );
- test( 2, 2, "." );
- test( 2, 3, "." );
-
- test( 0, 0, ".." );
- test( 0, 1, ".." );
- test( 1, 1, ".." );
- test( 1, 2, ".." );
- test( 2, 2, ".." );
- test( 2, 3, ".." );
-
- test( 0, 0, "..." );
- test( 0, 1, "..." );
- test( 1, 1, "..." );
- test( 1, 2, "..." );
- test( 2, 2, "..." );
- test( 2, 3, "..." );
-
- test( 0, 0, "...." );
- test( 0, 1, "...." );
- test( 1, 1, "...." );
- test( 1, 2, "...." );
- test( 2, 2, "...." );
- test( 2, 3, "...." );
- return 0;
-}
-
-##### OUTPUT #####
-run 0 0: 0 success
-run 0 1: 0 success
-run 1 1: 0 failure
-run 1 2: 0 failure
-run 2 2: 0 failure
-run 2 3: 0 failure
-run . 0 0: 0 failure
-run . 0 1: 1 success
-run . 1 1: 1 success
-run . 1 2: 1 success
-run . 2 2: 1 failure
-run . 2 3: 1 failure
-run .. 0 0: 0 failure
-run .. 0 1: 1 failure
-run .. 1 1: 1 failure
-run .. 1 2: 2 success
-run .. 2 2: 2 success
-run .. 2 3: 2 success
-run ... 0 0: 0 failure
-run ... 0 1: 1 failure
-run ... 1 1: 1 failure
-run ... 1 2: 2 failure
-run ... 2 2: 2 failure
-run ... 2 3: 3 success
-run .... 0 0: 0 failure
-run .... 0 1: 1 failure
-run .... 1 1: 1 failure
-run .... 1 2: 2 failure
-run .... 2 2: 2 failure
-run .... 2 3: 3 failure
diff --git a/test/ragel.d/condrep2.rl b/test/ragel.d/condrep2.rl
deleted file mode 100644
index e1b350dd..00000000
--- a/test/ragel.d/condrep2.rl
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * @LANG: c++
- */
-
-#include <iostream>
-#include <string.h>
-using std::cout;
-using std::endl;
-
-%%{
- machine foo;
-
- action seen { seen += 1; }
-
- action init { c = 0; }
- action inc { c += 1; }
- action min { ({ c >= min; }) }
- action max { ({ c < max; }) }
-
- main :=
- :condplus( '.' @seen, init, inc, min, max ):
- 0;
-
-}%%
-
-%% write data noerror;
-
-void test( int min, int max, const char *str )
-{
- int cs;
- const char *p = str;
- const char *pe = str + strlen( str ) + 1;
- int c = 0, seen = 0;
-
- cout << "run " << str << " " << min << " " << max << ":";
-
- %% write init;
- %% write exec;
-
- cout << " " << seen;
-
- if ( cs >= foo_first_final )
- cout << " success" << endl;
- else
- cout << " failure" << endl;
-}
-
-int main()
-{
- test( 0, 0, "" );
- test( 0, 1, "" );
- test( 1, 1, "" );
- test( 1, 2, "" );
- test( 2, 2, "" );
- test( 2, 3, "" );
-
- test( 0, 0, "." );
- test( 0, 1, "." );
- test( 1, 1, "." );
- test( 1, 2, "." );
- test( 2, 2, "." );
- test( 2, 3, "." );
-
- test( 0, 0, ".." );
- test( 0, 1, ".." );
- test( 1, 1, ".." );
- test( 1, 2, ".." );
- test( 2, 2, ".." );
- test( 2, 3, ".." );
-
- test( 0, 0, "..." );
- test( 0, 1, "..." );
- test( 1, 1, "..." );
- test( 1, 2, "..." );
- test( 2, 2, "..." );
- test( 2, 3, "..." );
-
- test( 0, 0, "...." );
- test( 0, 1, "...." );
- test( 1, 1, "...." );
- test( 1, 2, "...." );
- test( 2, 2, "...." );
- test( 2, 3, "...." );
- return 0;
-}
-
-##### OUTPUT #####
-run 0 0: 0 failure
-run 0 1: 0 failure
-run 1 1: 0 failure
-run 1 2: 0 failure
-run 2 2: 0 failure
-run 2 3: 0 failure
-run . 0 0: 0 failure
-run . 0 1: 1 success
-run . 1 1: 1 success
-run . 1 2: 1 success
-run . 2 2: 1 failure
-run . 2 3: 1 failure
-run .. 0 0: 0 failure
-run .. 0 1: 1 failure
-run .. 1 1: 1 failure
-run .. 1 2: 2 success
-run .. 2 2: 2 success
-run .. 2 3: 2 success
-run ... 0 0: 0 failure
-run ... 0 1: 1 failure
-run ... 1 1: 1 failure
-run ... 1 2: 2 failure
-run ... 2 2: 2 failure
-run ... 2 3: 3 success
-run .... 0 0: 0 failure
-run .... 0 1: 1 failure
-run .... 1 1: 1 failure
-run .... 1 2: 2 failure
-run .... 2 2: 2 failure
-run .... 2 3: 3 failure
diff --git a/test/ragel.d/condrep3.rl b/test/ragel.d/condrep3.rl
deleted file mode 100644
index df5f3f25..00000000
--- a/test/ragel.d/condrep3.rl
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * @LANG: c++
- */
-
-#include <iostream>
-#include <string.h>
-using std::cout;
-using std::endl;
-
-%%{
- machine foo;
-
-
- action init { c = 0; }
- action inc { c += 1; }
- action min { ({ c >= min; }) }
- action max { ({ c < max; }) }
-
- main :=
- :condstar( any, init, inc, min, max ): <: '.' 0;
-
-}%%
-
-%% write data noerror;
-
-void test( int min, int max, const char *str )
-{
- int cs;
- const char *p = str;
- const char *pe = str + strlen( str ) + 1;
- int c = 0, seen = 0;
-
- cout << "run " << str << " " << min << " " << max << ":";
-
- %% write init;
- %% write exec;
-
- cout << " " << seen;
-
- if ( cs >= foo_first_final )
- cout << " success" << endl;
- else
- cout << " failure" << endl;
-}
-
-int main()
-{
- test( 0, 0, "" );
- test( 0, 1, "" );
- test( 1, 1, "" );
- test( 1, 2, "" );
- test( 2, 2, "" );
- test( 2, 3, "" );
-
- test( 0, 0, "." );
- test( 0, 1, "." );
- test( 1, 1, "." );
- test( 1, 2, "." );
- test( 2, 2, "." );
- test( 2, 3, "." );
-
- test( 0, 0, ".." );
- test( 0, 1, ".." );
- test( 1, 1, ".." );
- test( 1, 2, ".." );
- test( 2, 2, ".." );
- test( 2, 3, ".." );
-
- test( 0, 0, "..." );
- test( 0, 1, "..." );
- test( 1, 1, "..." );
- test( 1, 2, "..." );
- test( 2, 2, "..." );
- test( 2, 3, "..." );
-
- test( 0, 0, "...." );
- test( 0, 1, "...." );
- test( 1, 1, "...." );
- test( 1, 2, "...." );
- test( 2, 2, "...." );
- test( 2, 3, "...." );
- return 0;
-}
-
-##### OUTPUT #####
-run 0 0: 0 failure
-run 0 1: 0 failure
-run 1 1: 0 failure
-run 1 2: 0 failure
-run 2 2: 0 failure
-run 2 3: 0 failure
-run . 0 0: 0 success
-run . 0 1: 0 failure
-run . 1 1: 0 failure
-run . 1 2: 0 failure
-run . 2 2: 0 failure
-run . 2 3: 0 failure
-run .. 0 0: 0 failure
-run .. 0 1: 0 success
-run .. 1 1: 0 success
-run .. 1 2: 0 failure
-run .. 2 2: 0 failure
-run .. 2 3: 0 failure
-run ... 0 0: 0 failure
-run ... 0 1: 0 failure
-run ... 1 1: 0 failure
-run ... 1 2: 0 success
-run ... 2 2: 0 success
-run ... 2 3: 0 failure
-run .... 0 0: 0 failure
-run .... 0 1: 0 failure
-run .... 1 1: 0 failure
-run .... 1 2: 0 failure
-run .... 2 2: 0 failure
-run .... 2 3: 0 success
diff --git a/test/ragel.d/condrep4.rl b/test/ragel.d/condrep4.rl
deleted file mode 100644
index 3a8bb85c..00000000
--- a/test/ragel.d/condrep4.rl
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * @LANG: c++
- */
-
-#include <iostream>
-#include <string.h>
-using std::cout;
-using std::endl;
-
-%%{
- machine foo;
-
-
- action init { c = 0; }
- action inc { c += 1; }
- action min { ({ c >= min; }) }
- action max { ({ c < max; }) }
-
- main :=
- :condstar( any, init, inc, min, max ): :> '.' 0;
-
-}%%
-
-%% write data noerror;
-
-void test( int min, int max, const char *str )
-{
- int cs;
- const char *p = str;
- const char *pe = str + strlen( str ) + 1;
- int c = 0, seen = 0;
-
- cout << "run " << str << " " << min << " " << max << ":";
-
- %% write init;
- %% write exec;
-
- cout << " " << seen;
-
- if ( cs >= foo_first_final )
- cout << " success" << endl;
- else
- cout << " failure" << endl;
-}
-
-int main()
-{
- test( 0, 0, "" );
- test( 0, 1, "" );
- test( 1, 1, "" );
- test( 1, 2, "" );
- test( 2, 2, "" );
- test( 2, 3, "" );
-
- test( 0, 0, "." );
- test( 0, 1, "." );
- test( 1, 1, "." );
- test( 1, 2, "." );
- test( 2, 2, "." );
- test( 2, 3, "." );
-
- test( 0, 0, ".." );
- test( 0, 1, ".." );
- test( 1, 1, ".." );
- test( 1, 2, ".." );
- test( 2, 2, ".." );
- test( 2, 3, ".." );
-
- test( 0, 0, "..." );
- test( 0, 1, "..." );
- test( 1, 1, "..." );
- test( 1, 2, "..." );
- test( 2, 2, "..." );
- test( 2, 3, "..." );
-
- test( 0, 0, "...." );
- test( 0, 1, "...." );
- test( 1, 1, "...." );
- test( 1, 2, "...." );
- test( 2, 2, "...." );
- test( 2, 3, "...." );
- return 0;
-}
-
-##### OUTPUT #####
-run 0 0: 0 failure
-run 0 1: 0 failure
-run 1 1: 0 failure
-run 1 2: 0 failure
-run 2 2: 0 failure
-run 2 3: 0 failure
-run . 0 0: 0 success
-run . 0 1: 0 success
-run . 1 1: 0 failure
-run . 1 2: 0 failure
-run . 2 2: 0 failure
-run . 2 3: 0 failure
-run .. 0 0: 0 failure
-run .. 0 1: 0 failure
-run .. 1 1: 0 success
-run .. 1 2: 0 success
-run .. 2 2: 0 failure
-run .. 2 3: 0 failure
-run ... 0 0: 0 failure
-run ... 0 1: 0 failure
-run ... 1 1: 0 failure
-run ... 1 2: 0 failure
-run ... 2 2: 0 success
-run ... 2 3: 0 success
-run .... 0 0: 0 failure
-run .... 0 1: 0 failure
-run .... 1 1: 0 failure
-run .... 1 2: 0 failure
-run .... 2 2: 0 failure
-run .... 2 3: 0 failure
diff --git a/test/ragel.d/condrep5.rl b/test/ragel.d/condrep5.rl
deleted file mode 100644
index 7ccba667..00000000
--- a/test/ragel.d/condrep5.rl
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * @LANG: indep
- * @NEEDS_EOF: yes
- */
-
-int q_1;
-
-%%{
- machine pattern_0001;
-
- action match { print_str "match\n"; }
-
- action ini_1 {
- print_str "ini = 0\n";
- q_1 = 0;
- }
-
- action inc_1 {
- print_str "inc to ";
- print_int q_1 + 1;
- print_str "\n";
- q_1 = q_1 + 1;
- }
-
- action min_1 { q_1 >= 5 }
- action max_1 { q_1 < 10 }
-
- main :=
- :condstar( 'a', ini_1, inc_1, min_1, max_1 ):
- %match;
-}%%
-
-##### INPUT #####
-""
-"a"
-"aa"
-"aaa"
-"aaaa"
-"aaaaa"
-##### OUTPUT #####
-ini = 0
-FAIL
-ini = 0
-inc to 1
-FAIL
-ini = 0
-inc to 1
-inc to 2
-FAIL
-ini = 0
-inc to 1
-inc to 2
-inc to 3
-FAIL
-ini = 0
-inc to 1
-inc to 2
-inc to 3
-inc to 4
-FAIL
-ini = 0
-inc to 1
-inc to 2
-inc to 3
-inc to 4
-inc to 5
-match
-ACCEPT
diff --git a/test/ragel.d/cppscan1.h b/test/ragel.d/cppscan1.h
deleted file mode 100644
index 346dd9b6..00000000
--- a/test/ragel.d/cppscan1.h
+++ /dev/null
@@ -1,112 +0,0 @@
-#ifndef _CPPSCAN1_H
-#define _CPPSCAN1_H
-
-#include <iostream>
-#include <cstdlib>
-#include <cstring>
-
-using namespace std;
-
-#define BUFSIZE 2048
-
-#define TK_Dlit 192
-#define TK_Slit 193
-#define TK_Float 194
-#define TK_Id 195
-#define TK_NameSep 197
-#define TK_Arrow 211
-#define TK_PlusPlus 212
-#define TK_MinusMinus 213
-#define TK_ArrowStar 214
-#define TK_DotStar 215
-#define TK_ShiftLeft 216
-#define TK_ShiftRight 217
-#define TK_IntegerDecimal 218
-#define TK_IntegerOctal 219
-#define TK_IntegerHex 220
-#define TK_EqualsEquals 223
-#define TK_NotEquals 224
-#define TK_AndAnd 225
-#define TK_OrOr 226
-#define TK_MultAssign 227
-#define TK_DivAssign 228
-#define TK_PercentAssign 229
-#define TK_PlusAssign 230
-#define TK_MinusAssign 231
-#define TK_AmpAssign 232
-#define TK_CaretAssign 233
-#define TK_BarAssign 234
-#define TK_DotDotDot 240
-
-/* A growable buffer for collecting headers. */
-struct Buffer
-{
- Buffer() : data(0), allocated(0), length(0) { }
- Buffer( const Buffer &other ) {
- data = (char*)malloc( other.allocated );
- memcpy( data, other.data, other.length );
- allocated = other.allocated;
- length = other.length;
- }
- ~Buffer() { empty(); }
-
- void append( char p ) {
- if ( ++length > allocated )
- upAllocate( length*2 );
- data[length-1] = p;
- }
- void append( char *str, int len ) {
- if ( (length += len) > allocated )
- upAllocate( length*2 );
- memcpy( data+length-len, str, len );
- }
-
- void clear() { length = 0; }
- void upAllocate( int len );
- void empty();
-
- char *data;
- int allocated;
- int length;
-};
-
-
-struct Scanner
-{
- Scanner( std::ostream &out )
- : out(out) { }
-
- std::ostream &out;
-
- int line, col;
- int tokStart;
- int inlineDepth;
- int count;
- Buffer tokBuf;
- Buffer nonTokBuf;
-
- void pass(char c) { nonTokBuf.append(c); }
- void buf(char c) { tokBuf.append(c); }
- void token( int id );
-
- int cs, stack, top;
-
- // Initialize the machine. Invokes any init statement blocks. Returns 0
- // if the machine begins in a non-accepting state and 1 if the machine
- // begins in an accepting state.
- void init( );
-
- // Execute the machine on a block of data. Returns -1 if after processing
- // the data, the machine is in the error state and can never accept, 0 if
- // the machine is in a non-accepting state and 1 if the machine is in an
- // accepting state.
- int execute( const char *data, int len );
-
- // Indicate that there is no more data. Returns -1 if the machine finishes
- // in the error state and does not accept, 0 if the machine finishes
- // in any other non-accepting state and 1 if the machine finishes in an
- // accepting state.
- int finish( );
-};
-
-#endif
diff --git a/test/ragel.d/cppscan1.rl b/test/ragel.d/cppscan1.rl
deleted file mode 100644
index b523227e..00000000
--- a/test/ragel.d/cppscan1.rl
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * @LANG: c++
- *
- * Test works with split code gen.
- */
-
-#include "cppscan1.h"
-
-#ifdef PERF_TEST
-
-/* Calibrated to 1s on yoho. */
-#define perf_iters ( 158428ll * S )
-
-int _perf_dummy = 0;
-#define perf_printf(...) ( _perf_dummy += 1 )
-#define perf_loop long _pi; for ( _pi = 0; _pi < perf_iters; _pi++ )
-
-#else
-
-#define perf_printf(...) printf( __VA_ARGS__ )
-#define perf_loop
-
-#endif
-
-%%{
- machine Scanner;
- access fsm->;
-
- action pass { fsm->pass(fc); }
- action buf { fsm->buf(fc); }
-
- action emit_slit { fsm->token( TK_Slit ); }
- action emit_dlit { fsm->token( TK_Dlit ); }
- action emit_id { fsm->token( TK_Id ); }
- action emit_integer_decimal { fsm->token( TK_IntegerDecimal ); }
- action emit_integer_octal { fsm->token( TK_IntegerOctal ); }
- action emit_integer_hex { fsm->token( TK_IntegerHex ); }
- action emit_float { fsm->token( TK_Float ); }
- action emit_symbol { fsm->token( fsm->tokBuf.data[0] ); }
- action tokst { fsm->tokStart = fsm->col; }
-
- # Single and double literals.
- slit = ( 'L'? ( "'" ( [^'\\\n] | /\\./ )* "'" ) $buf ) >tokst %emit_slit;
- dlit = ( 'L'? ( '"' ( [^"\\\n] | /\\./ )* '"' ) $buf ) >tokst %emit_dlit;
-
- # Identifiers
- id = ( [a-zA-Z_] [a-zA-Z0-9_]* ) >tokst $buf %emit_id;
-
- # Floating literals.
- fract_const = digit* '.' digit+ | digit+ '.';
- exponent = [eE] [+\-]? digit+;
- float_suffix = [flFL];
- float =
- ( fract_const exponent? float_suffix? |
- digit+ exponent float_suffix? ) >tokst $buf %emit_float;
-
- # Integer decimal. Leading part buffered by float.
- integer_decimal = ( ( '0' | [1-9] [0-9]* ) [ulUL]{0,3} $buf ) %emit_integer_decimal;
-
- # Integer octal. Leading part buffered by float.
- integer_octal = ( '0' [0-9]+ [ulUL]{0,2} $buf ) %emit_integer_octal;
-
- # Integer hex. Leading 0 buffered by float.
- integer_hex = ( '0' ( 'x' [0-9a-fA-F]+ [ulUL]{0,2} ) $buf ) %emit_integer_hex;
-
- # Only buffer the second item, first buffered by symbol. */
- namesep = '::' @buf %{fsm->token( TK_NameSep );};
- deqs = '==' @buf %{fsm->token( TK_EqualsEquals );};
- neqs = '!=' @buf %{fsm->token( TK_NotEquals );};
- and_and = '&&' @buf %{fsm->token( TK_AndAnd );};
- or_or = '||' @buf %{fsm->token( TK_OrOr );};
- mult_assign = '*=' @buf %{fsm->token( TK_MultAssign );};
- percent_assign = '%=' @buf %{fsm->token( TK_PercentAssign );};
- plus_assign = '+=' @buf %{fsm->token( TK_PlusAssign );};
- minus_assign = '-=' @buf %{fsm->token( TK_MinusAssign );};
- amp_assign = '&=' @buf %{fsm->token( TK_AmpAssign );};
- caret_assign = '^=' @buf %{fsm->token( TK_CaretAssign );};
- bar_assign = '|=' @buf %{fsm->token( TK_BarAssign );};
- plus_plus = '++' @buf %{fsm->token( TK_PlusPlus );};
- minus_minus = '--' @buf %{fsm->token( TK_MinusMinus );};
- arrow = '->' @buf %{fsm->token( TK_Arrow );};
- arrow_star = '->*' @buf %{fsm->token( TK_ArrowStar );};
- dot_star = '.*' @buf %{fsm->token( TK_DotStar );};
-
- # Buffer both items. *
- div_assign = '/=' @{fsm->buf('/');fsm->buf(fc);} %{fsm->token( TK_DivAssign );};
-
- # Double dot is sent as two dots.
- dot_dot = '..' %{fsm->token('.'); fsm->buf('.'); fsm->token('.');};
-
- # Three char compounds, first item already buffered. */
- dot_dot_dot = '...' %{fsm->buf('.'); fsm->buf('.'); fsm->token( TK_DotDotDot );};
-
- # All compunds
- compound = namesep | deqs | neqs | and_and | or_or | mult_assign |
- div_assign | percent_assign | plus_assign | minus_assign |
- amp_assign | caret_assign | bar_assign | plus_plus | minus_minus |
- arrow | arrow_star | dot_star | dot_dot | dot_dot_dot;
-
- # Single char symbols.
- symbol =
- ( punct - [./_"'] ) >tokst $buf %emit_symbol |
- # Do not immediately buffer slash, may be start of comment.
- '/' >tokst %{ fsm->buf('/'); fsm->token( '/' ); } |
- # Dot covered by float.
- '.' %emit_symbol;
-
- # Comments and whitespace.
- commc = '/*' @{fsm->pass('/'); fsm->pass('*');} ( any* $0 '*/' @1 ) $pass;
- commcc = '//' @{fsm->pass('/'); fsm->pass('/');} ( any* $0 '\n' @1 ) $pass;
- whitespace = ( any - ( 0 | 33..126 ) )+ $pass;
-
- action onEOFChar {
- /* On EOF char, write out the non token buffer. */
- fsm->nonTokBuf.append(0);
-#ifndef PERF_TEST
- cout << fsm->nonTokBuf.data;
-#endif
- fsm->nonTokBuf.clear();
- }
-
- # Using 0 as eof. If seeingAs a result all null characters get ignored.
- EOF = 0 @onEOFChar;
-
- # All outside code tokens.
- tokens = (
- id | slit | dlit | float | integer_decimal |
- integer_octal | integer_hex | compound | symbol );
- nontok = ( commc | commcc | whitespace | EOF );
-
- position = (
- '\n' @{ fsm->line += 1; fsm->col = 1; } |
- [^\n] @{ fsm->col += 1; } )*;
-
- main := ( ( tokens | nontok )** ) & position;
-}%%
-
-%% write data;
-
-void Scanner::init( )
-{
-}
-
-int Scanner::execute( const char *data, int len )
-{
- perf_loop
- {
- Scanner *fsm = this;
-
- /* A count of the number of characters in
- * a token. Used for % sequences. */
- count = 0;
- line = 1;
- col = 1;
-
- %% write init;
- const char *p = data;
- const char *pe = data + len;
- const char *eof = pe;
-
- %% write exec;
- }
-
- if ( cs == Scanner_error )
- return -1;
- if ( cs >= Scanner_first_final )
- return 1;
- return 0;
-}
-
-int Scanner::finish( )
-{
- if ( cs == Scanner_error )
- return -1;
- if ( cs >= Scanner_first_final )
- return 1;
- return 0;
-}
-
-void Scanner::token( int id )
-{
- /* Leader. */
- if ( nonTokBuf.length > 0 ) {
- nonTokBuf.append(0);
-#ifndef PERF_TEST
- cout << nonTokBuf.data;
-#endif
- nonTokBuf.clear();
- }
-
- /* Token data. */
- tokBuf.append(0);
-#ifndef PERF_TEST
- cout << '<' << id << '>' << tokBuf.data;
-#endif
- tokBuf.clear();
-}
-
-void Buffer::empty()
-{
- if ( data != 0 ) {
- free( data );
-
- data = 0;
- length = 0;
- allocated = 0;
- }
-}
-
-void Buffer::upAllocate( int len )
-{
- if ( data == 0 )
- data = (char*) malloc( len );
- else
- data = (char*) realloc( data, len );
- allocated = len;
-}
-
-void test( const char *buf )
-{
- Scanner scanner(cout);
- scanner.execute( buf, strlen(buf) );
-
- /* The last token is ignored (because there is no next token). Send
- * trailing null to force the last token into whitespace. */
- char eof = 0;
- if ( scanner.execute( &eof, 1 ) <= 0 ) {
-#ifndef PERF_TEST
- cerr << "cppscan: scan failed" << endl;
-#endif
- return;
- }
-#ifndef PERF_TEST
- cout.flush();
-#endif
-}
-
-int main()
-{
- test(
- "/*\n"
- " * Copyright \n"
- " */\n"
- "\n"
- "/* Construct an fsmmachine from a graph. */\n"
- "RedFsmAp::RedFsmAp( FsmAp *graph, bool complete )\n"
- ":\n"
- " graph(graph),\n"
- "{\n"
- " assert( sizeof(RedTransAp) <= sizeof(TransAp) );\n"
- "\n"
- " reduceMachine();\n"
- "}\n"
- "\n"
- "{\n"
- " /* Get the transition that we want to extend. */\n"
- " RedTransAp *extendTrans = list[pos].value;\n"
- "\n"
- " /* Look ahead in the transition list. */\n"
- " for ( int next = pos + 1; next < list.length(); pos++, next++ ) {\n"
- " if ( ! keyOps->eq( list[pos].highKey, nextKey ) )\n"
- " break;\n"
- " }\n"
- " return false;\n"
- "}\n"
- "\n" );
-
- test(
- "->*\n"
- ".*\n"
- "/*\"*/\n"
- "\"/*\"\n"
- "L'\"'\n"
- "L\"'\"\n" );
-
- return 0;
-}
-
-##### OUTPUT #####
-/*
- * Copyright
- */
-
-/* Construct an fsmmachine from a graph. */
-<195>RedFsmAp<197>::<195>RedFsmAp<40>( <195>FsmAp <42>*<195>graph<44>, <195>bool <195>complete <41>)
-<58>:
- <195>graph<40>(<195>graph<41>)<44>,
-<123>{
- <195>assert<40>( <195>sizeof<40>(<195>RedTransAp<41>) <60><<61>= <195>sizeof<40>(<195>TransAp<41>) <41>)<59>;
-
- <195>reduceMachine<40>(<41>)<59>;
-<125>}
-
-<123>{
- /* Get the transition that we want to extend. */
- <195>RedTransAp <42>*<195>extendTrans <61>= <195>list<91>[<195>pos<93>]<46>.<195>value<59>;
-
- /* Look ahead in the transition list. */
- <195>for <40>( <195>int <195>next <61>= <195>pos <43>+ <218>1<59>; <195>next <60>< <195>list<46>.<195>length<40>(<41>)<59>; <195>pos<212>++<44>, <195>next<212>++ <41>) <123>{
- <195>if <40>( <33>! <195>keyOps<211>-><195>eq<40>( <195>list<91>[<195>pos<93>]<46>.<195>highKey<44>, <195>nextKey <41>) <41>)
- <195>break<59>;
- <125>}
- <195>return <195>false<59>;
-<125>}
-
-<214>->*
-<215>.*
-/*"*/
-<192>"/*"
-<193>L'"'
-<192>L"'"
diff --git a/test/ragel.d/cppscan2.rl b/test/ragel.d/cppscan2.rl
deleted file mode 100644
index 0c29a792..00000000
--- a/test/ragel.d/cppscan2.rl
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
- * @LANG: c++
- */
-
-#include <iostream>
-#include <string.h>
-using namespace std;
-
-#define TK_Dlit 192
-#define TK_Slit 193
-#define TK_Float 194
-#define TK_Id 195
-#define TK_NameSep 197
-#define TK_Arrow 211
-#define TK_PlusPlus 212
-#define TK_MinusMinus 213
-#define TK_ArrowStar 214
-#define TK_DotStar 215
-#define TK_ShiftLeft 216
-#define TK_ShiftRight 217
-#define TK_IntegerDecimal 218
-#define TK_IntegerOctal 219
-#define TK_IntegerHex 220
-#define TK_EqualsEquals 223
-#define TK_NotEquals 224
-#define TK_AndAnd 225
-#define TK_OrOr 226
-#define TK_MultAssign 227
-#define TK_DivAssign 228
-#define TK_PercentAssign 229
-#define TK_PlusAssign 230
-#define TK_MinusAssign 231
-#define TK_AmpAssign 232
-#define TK_CaretAssign 233
-#define TK_BarAssign 234
-#define TK_DotDotDot 240
-#define TK_Whitespace 241
-#define TK_Comment 242
-
-#define BUFSIZE 4096
-
-int tok;
-char buf[BUFSIZE];
-const char *ts, *te;
-void token( const char *data, int len );
-bool discard = false;
-
-struct Scanner
-{
- int cs;
-
- // Initialize the machine. Invokes any init statement blocks. Returns 0
- // if the machine begins in a non-accepting state and 1 if the machine
- // begins in an accepting state.
- int init( );
-
- // Execute the machine on a block of data. Returns -1 if after processing
- // the data, the machine is in the error state and can never accept, 0 if
- // the machine is in a non-accepting state and 1 if the machine is in an
- // accepting state.
- int execute( const char *data, int len );
-
- // Indicate that there is no more data. Returns -1 if the machine finishes
- // in the error state and does not accept, 0 if the machine finishes
- // in any other non-accepting state and 1 if the machine finishes in an
- // accepting state.
- int finish( );
-};
-
-%%{
- machine Scanner;
-
- # Single and double literals.
- slit = ( 'L'? "'" ( [^'\\\n] | /\\./ )* "'" ) @{tok = TK_Slit;};
- dlit = ( 'L'? '"' ( [^"\\\n] | /\\./ )* '"' ) @{tok = TK_Dlit;};
-
- # Identifiers
- id = ( [a-zA-Z_] [a-zA-Z0-9_]* ) @{tok = TK_Id;};
-
- # Floating literals.
- fract_const = digit* '.' digit+ | digit+ '.';
- exponent = [eE] [+\-]? digit+;
- float_suffix = [flFL];
- float =
- ( fract_const exponent? float_suffix? |
- digit+ exponent float_suffix? ) @{tok = TK_Float;};
-
- # Integer decimal. Leading part buffered by float.
- integer_decimal = ( ( '0' | [1-9] [0-9]* ) [ulUL]{0,3} ) @{tok = TK_IntegerDecimal;};
-
- # Integer octal. Leading part buffered by float.
- integer_octal = ( '0' [0-9]+ [ulUL]{0,2} ) @{tok = TK_IntegerOctal;};
-
- # Integer hex. Leading 0 buffered by float.
- integer_hex = ( '0' ( 'x' [0-9a-fA-F]+ [ulUL]{0,2} ) ) @{tok = TK_IntegerHex;};
-
- # Only buffer the second item, first buffered by symbol. */
- namesep = '::' @{tok = TK_NameSep;};
- deqs = '==' @{tok = TK_EqualsEquals;};
- neqs = '!=' @{tok = TK_NotEquals;};
- and_and = '&&' @{tok = TK_AndAnd;};
- or_or = '||' @{tok = TK_OrOr;};
- mult_assign = '*=' @{tok = TK_MultAssign;};
- div_assign = '/=' @{tok = TK_DivAssign;};
- percent_assign = '%=' @{tok = TK_PercentAssign;};
- plus_assign = '+=' @{tok = TK_PlusAssign;};
- minus_assign = '-=' @{tok = TK_MinusAssign;};
- amp_assign = '&=' @{tok = TK_AmpAssign;};
- caret_assign = '^=' @{tok = TK_CaretAssign;};
- bar_assign = '|=' @{tok = TK_BarAssign;};
- plus_plus = '++' @{tok = TK_PlusPlus;};
- minus_minus = '--' @{tok = TK_MinusMinus;};
- arrow = '->' @{tok = TK_Arrow;};
- arrow_star = '->*' @{tok = TK_ArrowStar;};
- dot_star = '.*' @{tok = TK_DotStar;};
-
- # Three char compounds, first item already buffered. */
- dot_dot_dot = '...' @{tok = TK_DotDotDot;};
-
- # All compunds
- compound = namesep | deqs | neqs | and_and | or_or | mult_assign |
- div_assign | percent_assign | plus_assign | minus_assign |
- amp_assign | caret_assign | bar_assign | plus_plus | minus_minus |
- arrow | arrow_star | dot_star | dot_dot_dot;
-
- # Single char symbols.
- symbol = ( punct - [_"'] ) @{tok = fc;};
-
- action discard {
- discard = true;
- }
-
- # Comments and whitespace.
- commc = '/*' @discard ( any* $0 '*/' @1 ) @{tok = TK_Comment;};
- commcc = '//' @discard ( any* $0 '\n' @1 ) @{tok = TK_Comment;};
- whitespace = ( any - 33..126 )+ >discard @{tok = TK_Whitespace;};
-
- # All outside code tokens.
- tokens = (
- id | slit | dlit | float | integer_decimal |
- integer_octal | integer_hex | compound | symbol |
- commc | commcc | whitespace );
-
- action onError {
- if ( tok != 0 ) {
- const char *rst_data;
-
- if ( tok == TK_Comment || tok == TK_Whitespace ) {
- /* Reset comment status, don't send. */
- discard = false;
-
- /* Restart right at the error point if consuming whitespace or
- * a comment. Consume may have spanned multiple buffers. */
- rst_data = fpc;
- }
- else {
- /* Send the token. */
- token( ts, te - ts + 1 );
-
- /* Restart right after the token. */
- rst_data = te+1;
- }
-
- ts = 0;
- fexec rst_data;
- fgoto main;
- }
- }
-
- main := tokens >{ts=fpc;} @{te=fpc;} $!onError;
-}%%
-
-%% write data;
-
-int Scanner::init( )
-{
- tok = 0;
- ts = 0;
- te = 0;
-
- %% write init;
- return 1;
-}
-
-int Scanner::execute( const char *data, int len )
-{
- const char *p = data;
- const char *pe = data + len;
- const char *eof = pe;
-
- %% write exec;
-
- if ( cs == Scanner_error )
- return -1;
- if ( cs >= Scanner_first_final )
- return 1;
- return 0;
-}
-
-int Scanner::finish( )
-{
- if ( cs == Scanner_error )
- return -1;
- if ( cs >= Scanner_first_final )
- return 1;
- return 0;
-}
-
-
-void token( const char *data, int len )
-{
- cout << "<" << tok << "> ";
- for ( int i = 0; i < len; i++ )
- cout << data[i];
- cout << '\n';
-}
-
-void test( const char * data )
-{
- Scanner scanner;
- scanner.init();
- scanner.execute( data, strlen(data) );
- scanner.finish();
- if ( tok != 0 && tok != TK_Comment && tok != TK_Whitespace )
- token( ts, te - ts + 1 );
-}
-
-int main()
-{
- test(
- "/*\n"
- " * Copyright \n"
- " */\n"
- "\n"
- "\n"
- "/* Move ranges to the singles list. */\n"
- "void RedFsmAp::move( RedStateAp *state )\n"
- "{\n"
- " RedTranst &range = state->outRange;\n"
- " for ( int rpos = 0; rpos < range.length(); ) {\n"
- " if ( can( range, rpos ) ) {\n"
- " while ( range[rpos].value != range[rpos+1].value ) {\n"
- " single.append( range[rpos+1] );\n"
- " }\n"
- " \n"
- " range[rpos].highKey = range[rpos+1].highKey;\n"
- " }\n"
- " else if ( keyOps->span( range[rpos].lowKey, range[rpos].highKey ) == 1 ) {\n"
- " single.append( range[rpos] );\n"
- " }\n"
- " }\n"
- "}\n"
- "\n" );
-
- test(
- "->*\n"
- ".*\n"
- "/*\"*/\n"
- "\"/*\"\n"
- "L'\"'\n"
- "L\"'\"\n"
- "...\n" );
-}
-
-##### OUTPUT #####
-<195> void
-<195> RedFsmAp
-<197> ::
-<195> move
-<40> (
-<195> RedStateAp
-<42> *
-<195> state
-<41> )
-<123> {
-<195> RedTranst
-<38> &
-<195> range
-<61> =
-<195> state
-<211> ->
-<195> outRange
-<59> ;
-<195> for
-<40> (
-<195> int
-<195> rpos
-<61> =
-<218> 0
-<59> ;
-<195> rpos
-<60> <
-<195> range
-<46> .
-<195> length
-<40> (
-<41> )
-<59> ;
-<41> )
-<123> {
-<195> if
-<40> (
-<195> can
-<40> (
-<195> range
-<44> ,
-<195> rpos
-<41> )
-<41> )
-<123> {
-<195> while
-<40> (
-<195> range
-<91> [
-<195> rpos
-<93> ]
-<46> .
-<195> value
-<224> !=
-<195> range
-<91> [
-<195> rpos
-<43> +
-<218> 1
-<93> ]
-<46> .
-<195> value
-<41> )
-<123> {
-<195> single
-<46> .
-<195> append
-<40> (
-<195> range
-<91> [
-<195> rpos
-<43> +
-<218> 1
-<93> ]
-<41> )
-<59> ;
-<125> }
-<195> range
-<91> [
-<195> rpos
-<93> ]
-<46> .
-<195> highKey
-<61> =
-<195> range
-<91> [
-<195> rpos
-<43> +
-<218> 1
-<93> ]
-<46> .
-<195> highKey
-<59> ;
-<125> }
-<195> else
-<195> if
-<40> (
-<195> keyOps
-<211> ->
-<195> span
-<40> (
-<195> range
-<91> [
-<195> rpos
-<93> ]
-<46> .
-<195> lowKey
-<44> ,
-<195> range
-<91> [
-<195> rpos
-<93> ]
-<46> .
-<195> highKey
-<41> )
-<223> ==
-<218> 1
-<41> )
-<123> {
-<195> single
-<46> .
-<195> append
-<40> (
-<195> range
-<91> [
-<195> rpos
-<93> ]
-<41> )
-<59> ;
-<125> }
-<125> }
-<125> }
-<214> ->*
-<215> .*
-<192> "/*"
-<193> L'"'
-<192> L"'"
-<240> ...
diff --git a/test/ragel.d/cppscan3.rl b/test/ragel.d/cppscan3.rl
deleted file mode 100644
index 747d8512..00000000
--- a/test/ragel.d/cppscan3.rl
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * @LANG: c++
- */
-
-#include <iostream>
-#include <string.h>
-using namespace std;
-
-#define TK_Dlit 192
-#define TK_Slit 193
-#define TK_Float 194
-#define TK_Id 195
-#define TK_NameSep 197
-#define TK_Arrow 211
-#define TK_PlusPlus 212
-#define TK_MinusMinus 213
-#define TK_ArrowStar 214
-#define TK_DotStar 215
-#define TK_ShiftLeft 216
-#define TK_ShiftRight 217
-#define TK_IntegerDecimal 218
-#define TK_IntegerOctal 219
-#define TK_IntegerHex 220
-#define TK_EqualsEquals 223
-#define TK_NotEquals 224
-#define TK_AndAnd 225
-#define TK_OrOr 226
-#define TK_MultAssign 227
-#define TK_DivAssign 228
-#define TK_PercentAssign 229
-#define TK_PlusAssign 230
-#define TK_MinusAssign 231
-#define TK_AmpAssign 232
-#define TK_CaretAssign 233
-#define TK_BarAssign 234
-#define TK_DotDotDot 240
-#define TK_Whitespace 241
-#define TK_Comment 242
-
-#define BUFSIZE 4096
-
-char buf[BUFSIZE];
-
-struct Scanner
-{
- int cs, act;
- const char *ts, *te;
-
- void token( int tok );
- void run();
-
- void init( );
- void execute( const char *data, int len );
- int finish( );
-};
-
-%%{
- machine Scanner;
-
- main := |*
-
- # Single and double literals.
- ( 'L'? "'" ( [^'\\\n] | /\\./ )* "'" )
- => { token( TK_Slit );};
- ( 'L'? '"' ( [^"\\\n] | /\\./ )* '"' )
- => { token( TK_Dlit );};
-
- # Identifiers
- ( [a-zA-Z_] [a-zA-Z0-9_]* )
- =>{ token( TK_Id );};
-
- # Floating literals.
- fract_const = digit* '.' digit+ | digit+ '.';
- exponent = [eE] [+\-]? digit+;
- float_suffix = [flFL];
-
- ( fract_const exponent? float_suffix? |
- digit+ exponent float_suffix? )
- => { token( TK_Float );};
-
- # Integer decimal. Leading part buffered by float.
- ( ( '0' | [1-9] [0-9]* ) [ulUL]{0,3} )
- => { token( TK_IntegerDecimal );};
-
- # Integer octal. Leading part buffered by float.
- ( '0' [0-9]+ [ulUL]{0,2} )
- => { token( TK_IntegerOctal );};
-
- # Integer hex. Leading 0 buffered by float.
- ( '0' ( 'x' [0-9a-fA-F]+ [ulUL]{0,2} ) )
- => { token( TK_IntegerHex );};
-
- # Only buffer the second item, first buffered by symbol. */
- '::' => {token( TK_NameSep );};
- '==' => {token( TK_EqualsEquals );};
- '!=' => {token( TK_NotEquals );};
- '&&' => {token( TK_AndAnd );};
- '||' => {token( TK_OrOr );};
- '*=' => {token( TK_MultAssign );};
- '/=' => {token( TK_DivAssign );};
- '%=' => {token( TK_PercentAssign );};
- '+=' => {token( TK_PlusAssign );};
- '-=' => {token( TK_MinusAssign );};
- '&=' => {token( TK_AmpAssign );};
- '^=' => {token( TK_CaretAssign );};
- '|=' => {token( TK_BarAssign );};
- '++' => {token( TK_PlusPlus );};
- '--' => {token( TK_MinusMinus );};
- '->' => {token( TK_Arrow );};
- '->*' => {token( TK_ArrowStar );};
- '.*' => {token( TK_DotStar );};
-
- # Three char compounds, first item already buffered. */
- '...' => { token( TK_DotDotDot );};
-
- # Single char symbols.
- ( punct - [_"'] ) => { token( ts[0] );};
-
- action comment {
- token( TK_Comment );
- }
-
- # Comments and whitespace.
- '/*' ( any* $0 '*/' @1 ) => comment;
- '//' ( any* $0 '\n' @1 ) => comment;
- ( any - 33..126 )+ => { token( TK_Whitespace );};
-
- *|;
-}%%
-
-%% write data;
-
-void Scanner::init( )
-{
- %% write init;
-}
-
-/* Returns the count of bytes still in the buffer
- * (shifted to the biginning) */
-void Scanner::execute( const char *data, int len )
-{
- const char *p = data;
- const char *pe = data + len;
- const char *eof = pe;
-
- %% write exec;
-
- cout << "P: " << (p - data) << endl;
-}
-
-int Scanner::finish( )
-{
- if ( cs == Scanner_error )
- return -1;
- if ( cs >= Scanner_first_final )
- return 1;
- return 0;
-}
-
-
-void Scanner::token( int tok )
-{
- const char *data = ts;
- int len = te - ts;
- cout << "<" << tok << "> ";
- for ( int i = 0; i < len; i++ )
- cout << data[i];
- cout << '\n';
-}
-
-void test( const char *buf )
-{
- int len = strlen( buf );
- std::ios::sync_with_stdio(false);
- Scanner scanner;
- scanner.init();
-
- scanner.execute( buf, len );
- if ( scanner.cs == Scanner_error ) {
- /* Machine failed before finding a token. */
- cout << "PARSE ERROR" << endl;
- }
-
- /* FIXME: Last token may get lost. */
- scanner.finish();
-}
-
-int main()
-{
- test(
- "\"\\\"hi\" /*\n"
- "*/\n"
- "44 .44\n"
- "44. 44\n"
- "44 . 44\n"
- "44.44\n"
- "_hithere22"
- );
-
- test(
- "'\\''\"\\n\\d'\\\"\"\n"
- "hi\n"
- "99\n"
- ".99\n"
- "99e-4\n"
- "->*\n"
- "||\n"
- "0x98\n"
- "0x\n"
- "//\n"
- "/* * */"
- );
-
- test(
- "'\n"
- "'\n"
- );
-
-}
-
-##### OUTPUT #####
-<192> "\"hi"
-<241>
-<242> /*
-*/
-<241>
-
-<218> 44
-<241>
-<194> .44
-<241>
-
-<194> 44.
-<241>
-<218> 44
-<241>
-
-<218> 44
-<241>
-<46> .
-<241>
-<218> 44
-<241>
-
-<194> 44.44
-<241>
-
-<195> _hithere22
-P: 51
-<193> '\''
-<192> "\n\d'\""
-<241>
-
-<195> hi
-<241>
-
-<218> 99
-<241>
-
-<194> .99
-<241>
-
-<194> 99e-4
-<241>
-
-<214> ->*
-<241>
-
-<226> ||
-<241>
-
-<220> 0x98
-<241>
-
-<218> 0
-<195> x
-<241>
-
-<242> //
-
-<242> /* * */
-P: 55
-P: 1
-PARSE ERROR
diff --git a/test/ragel.d/cppscan4.rl b/test/ragel.d/cppscan4.rl
deleted file mode 100644
index 9fb2f10c..00000000
--- a/test/ragel.d/cppscan4.rl
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * @LANG: d
- */
-
-module cppscan;
-
-import std.c.stdio;
-import std.stdio;
-import std.string;
-
-const int BUFSIZE = 2048;
-
-const int TK_Dlit = 192;
-const int TK_Slit = 193;
-const int TK_Float = 194;
-const int TK_Id = 195;
-const int TK_NameSep = 197;
-const int TK_Arrow = 211;
-const int TK_PlusPlus = 212;
-const int TK_MinusMinus = 213;
-const int TK_ArrowStar = 214;
-const int TK_DotStar = 215;
-const int TK_ShiftLeft = 216;
-const int TK_ShiftRight = 217;
-const int TK_IntegerDecimal = 218;
-const int TK_IntegerOctal = 219;
-const int TK_IntegerHex = 220;
-const int TK_EqualsEquals = 223;
-const int TK_NotEquals = 224;
-const int TK_AndAnd = 225;
-const int TK_OrOr = 226;
-const int TK_MultAssign = 227;
-const int TK_DivAssign = 228;
-const int TK_PercentAssign = 229;
-const int TK_PlusAssign = 230;
-const int TK_MinusAssign = 231;
-const int TK_AmpAssign = 232;
-const int TK_CaretAssign = 233;
-const int TK_BarAssign = 234;
-const int TK_DotDotDot = 240;
-
-
-class Scanner
-{
- int line, col;
- int tokStart;
- int inlineDepth;
- int count;
- const (char)[] tokBuf;
- const (char)[] nonTokBuf;
-
- void pass(char c) { nonTokBuf ~= c; }
- void buf(char c) { tokBuf ~= c; }
- void token( int id )
- {
- /* Leader. */
- if ( nonTokBuf.length > 0 ) {
- writef("%s", cast(string)nonTokBuf);
- nonTokBuf = "";
- }
-
- /* Token data. */
- writef("<%d>%s", id, cast(string)tokBuf);
-
- tokBuf = "";
- }
-
- int cs, stack, top;
-
- %%{
- machine Scanner;
-
- action pass { pass(fc); }
- action buf { buf(fc); }
-
- action emit_slit { token( TK_Slit ); }
- action emit_dlit { token( TK_Dlit ); }
- action emit_id { token( TK_Id ); }
- action emit_integer_decimal { token( TK_IntegerDecimal ); }
- action emit_integer_octal { token( TK_IntegerOctal ); }
- action emit_integer_hex { token( TK_IntegerHex ); }
- action emit_float { token( TK_Float ); }
- action emit_symbol { token( tokBuf[0] ); }
- action tokst { tokStart = col; }
-
- # Single and double literals.
- slit = ( 'L'? ( "'" ( [^'\\\n] | /\\./ )* "'" ) $buf ) >tokst %emit_slit;
- dlit = ( 'L'? ( '"' ( [^"\\\n] | /\\./ )* '"' ) $buf ) >tokst %emit_dlit;
-
- # Identifiers
- id = ( [a-zA-Z_] [a-zA-Z0-9_]* ) >tokst $buf %emit_id;
-
- # Floating literals.
- fract_const = digit* '.' digit+ | digit+ '.';
- exponent = [eE] [+\-]? digit+;
- float_suffix = [flFL];
- float =
- ( fract_const exponent? float_suffix? |
- digit+ exponent float_suffix? ) >tokst $buf %emit_float;
-
- # Integer decimal. Leading part buffered by float.
- integer_decimal = ( ( '0' | [1-9] [0-9]* ) [ulUL]{0,3} $buf ) %emit_integer_decimal;
-
- # Integer octal. Leading part buffered by float.
- integer_octal = ( '0' [0-9]+ [ulUL]{0,2} $buf ) %emit_integer_octal;
-
- # Integer hex. Leading 0 buffered by float.
- integer_hex = ( '0' ( 'x' [0-9a-fA-F]+ [ulUL]{0,2} ) $buf ) %emit_integer_hex;
-
- # Only buffer the second item, first buffered by symbol. */
- namesep = '::' @buf %{token( TK_NameSep );};
- deqs = '==' @buf %{token( TK_EqualsEquals );};
- neqs = '!=' @buf %{token( TK_NotEquals );};
- and_and = '&&' @buf %{token( TK_AndAnd );};
- or_or = '||' @buf %{token( TK_OrOr );};
- mult_assign = '*=' @buf %{token( TK_MultAssign );};
- percent_assign = '%=' @buf %{token( TK_PercentAssign );};
- plus_assign = '+=' @buf %{token( TK_PlusAssign );};
- minus_assign = '-=' @buf %{token( TK_MinusAssign );};
- amp_assign = '&=' @buf %{token( TK_AmpAssign );};
- caret_assign = '^=' @buf %{token( TK_CaretAssign );};
- bar_assign = '|=' @buf %{token( TK_BarAssign );};
- plus_plus = '++' @buf %{token( TK_PlusPlus );};
- minus_minus = '--' @buf %{token( TK_MinusMinus );};
- arrow = '->' @buf %{token( TK_Arrow );};
- arrow_star = '->*' @buf %{token( TK_ArrowStar );};
- dot_star = '.*' @buf %{token( TK_DotStar );};
-
- # Buffer both items. *
- div_assign = '/=' @{buf('/');buf(fc);} %{token( TK_DivAssign );};
-
- # Double dot is sent as two dots.
- dot_dot = '..' %{token('.'); buf('.'); token('.');};
-
- # Three char compounds, first item already buffered. */
- dot_dot_dot = '...' %{buf('.'); buf('.'); token( TK_DotDotDot );};
-
- # All compunds
- compound = namesep | deqs | neqs | and_and | or_or | mult_assign |
- div_assign | percent_assign | plus_assign | minus_assign |
- amp_assign | caret_assign | bar_assign | plus_plus | minus_minus |
- arrow | arrow_star | dot_star | dot_dot | dot_dot_dot;
-
- # Single char symbols.
- symbol =
- ( punct - [./_"'] ) >tokst $buf %emit_symbol |
- # Do not immediately buffer slash, may be start of comment.
- '/' >tokst %{ buf('/'); token( '/' ); } |
- # Dot covered by float.
- '.' %emit_symbol;
-
- # Comments and whitespace.
- commc = '/*' @{pass('/'); pass('*');} ( any* $0 '*/' @1 ) $pass;
- commcc = '//' @{pass('/'); pass('/');} ( any* $0 '\n' @1 ) $pass;
- whitespace = ( any - ( 0 | 33..126 ) )+ $pass;
-
- action onEOFChar {
- /* On EOF char, write out the non token buffer. */
- writef("%s", cast(string)nonTokBuf);
- nonTokBuf = "";
- }
-
- # Using 0 as eof. If seeingAs a result all null characters get ignored.
- EOF = 0 @onEOFChar;
-
- # All outside code tokens.
- tokens = (
- id | slit | dlit | float | integer_decimal |
- integer_octal | integer_hex | compound | symbol );
- nontok = ( commc | commcc | whitespace | EOF );
-
- position = (
- '\n' @{ line += 1; col = 1; } |
- [^\n] @{ col += 1; } )*;
-
- main := ( ( tokens | nontok )** ) & position;
- }%%
-
- %% write data noprefix;
-
- void init( )
- {
- /* A count of the number of characters in
- * a token. Used for % sequences. */
- count = 0;
- line = 1;
- col = 1;
- %% write init;
- }
-
- int execute( const(char)* _data, ulong _len )
- {
- const(char) *p = _data;
- const(char) *pe = _data + _len;
- const(char) *eof = null;
-
- %% write exec;
-
- if ( cs == error )
- return -1;
- if ( cs >= first_final )
- return 1;
- return 0;
- }
-
- // Indicate that there is no more data. Returns -1 if the machine finishes
- // in the error state and does not accept, 0 if the machine finishes
- // in any other non-accepting state and 1 if the machine finishes in an
- // accepting state.
- int finish( )
- {
- if ( cs == error )
- return -1;
- if ( cs >= first_final )
- return 1;
- return 0;
- }
-};
-
-void test(const(char)[] buf)
-{
- Scanner scanner = new Scanner();
- scanner.init();
- scanner.execute( buf.ptr, buf.length );
-
- /* The last token is ignored (because there is no next token). Send
- * trailing null to force the last token into whitespace. */
- const(char) eof_char = 0;
- if ( scanner.execute( &eof_char, 1 ) <= 0 ) {
- std.stdio.stderr.writef("cppscan: scan failed\n");
- }
-}
-
-int main()
-{
- test(
- "/*\n"
- " * Copyright \n"
- " */\n"
- "\n"
- "RedTransAp *RedFsmAp::reduceTrans( TransAp *trans )\n"
- "{\n"
- " RedAction *action = 0;\n"
- " if ( trans->actionTable.length() > 0 ) {\n"
- " if ( actionMap.insert( trans->actionTable, &action ) )\n"
- " action->id = nextActionId++;\n"
- " }\n"
- " \n"
- " RedStateAp *targ = (RedStateAp*)trans->toState;\n"
- " if ( action == 0 ) {\n"
- " delete trans;\n"
- " return 0;\n"
- " }\n"
- "\n"
- " trans->~TransAp();\n"
- " inDict = new(trans) RedTransAp( targ, action, nextTransId++ );\n"
- " transSet.insert( inDict );\n"
- "}\n"
- );
-
- test(
- "->*\n"
- ".*\n"
- "/*\"*/\n"
- "\"/*\"\n"
- "L'\"'\n"
- "L\"'\"\n"
- );
-
- return 0;
-}
-
-##### OUTPUT #####
-/*
- * Copyright
- */
-
-<195>RedTransAp <42>*<195>RedFsmAp<197>::<195>reduceTrans<40>( <195>TransAp <42>*<195>trans <41>)
-<123>{
- <195>RedAction <42>*<195>action <61>= <218>0<59>;
- <195>if <40>( <195>trans<211>-><195>actionTable<46>.<195>length<40>(<41>) <62>> <218>0 <41>) <123>{
- <195>if <40>( <195>actionMap<46>.<195>insert<40>( <195>trans<211>-><195>actionTable<44>, <38>&<195>action <41>) <41>)
- <195>action<211>-><195>id <61>= <195>nextActionId<212>++<59>;
- <125>}
-
- <195>RedStateAp <42>*<195>targ <61>= <40>(<195>RedStateAp<42>*<41>)<195>trans<211>-><195>toState<59>;
- <195>if <40>( <195>action <223>== <218>0 <41>) <123>{
- <195>delete <195>trans<59>;
- <195>return <218>0<59>;
- <125>}
-
- <195>trans<211>-><126>~<195>TransAp<40>(<41>)<59>;
- <195>inDict <61>= <195>new<40>(<195>trans<41>) <195>RedTransAp<40>( <195>targ<44>, <195>action<44>, <195>nextTransId<212>++ <41>)<59>;
- <195>transSet<46>.<195>insert<40>( <195>inDict <41>)<59>;
-<125>}
-<214>->*
-<215>.*
-/*"*/
-<192>"/*"
-<193>L'"'
-<192>L"'"
diff --git a/test/ragel.d/cppscan5.rl b/test/ragel.d/cppscan5.rl
deleted file mode 100644
index e4244129..00000000
--- a/test/ragel.d/cppscan5.rl
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * @LANG: d
- */
-
-/*
- * Test in and out state actions.
- */
-
-import std.c.stdio;
-import std.string;
-
-static const int TK_Dlit = 192;
-static const int TK_Slit = 193;
-static const int TK_Float = 194;
-static const int TK_Id = 195;
-static const int TK_NameSep = 197;
-static const int TK_Arrow = 211;
-static const int TK_PlusPlus = 212;
-static const int TK_MinusMinus = 213;
-static const int TK_ArrowStar = 214;
-static const int TK_DotStar = 215;
-static const int TK_ShiftLeft = 216;
-static const int TK_ShiftRight = 217;
-static const int TK_IntegerDecimal = 218;
-static const int TK_IntegerOctal = 219;
-static const int TK_IntegerHex = 220;
-static const int TK_EqualsEquals = 223;
-static const int TK_NotEquals = 224;
-static const int TK_AndAnd = 225;
-static const int TK_OrOr = 226;
-static const int TK_MultAssign = 227;
-static const int TK_DivAssign = 228;
-static const int TK_PercentAssign = 229;
-static const int TK_PlusAssign = 230;
-static const int TK_MinusAssign = 231;
-static const int TK_AmpAssign = 232;
-static const int TK_CaretAssign = 233;
-static const int TK_BarAssign = 234;
-static const int TK_DotDotDot = 240;
-static const int TK_Whitespace = 241;
-static const int TK_Comment = 242;
-
-class Scanner
-{
- int cs, act;
- const(char) *ts, te;
-
- void token( int tok )
- {
- const(char) *data = ts;
- long len = te - ts;
- printf( "<%i> ", tok );
- for ( int i = 0; i < len; i++ )
- printf( "%c", data[i] );
- printf( "\n" );
- }
-
- %%{
-
- machine Scanner;
-
- main := |*
-
- # Single and double literals.
- ( 'L'? "'" ( [^'\\\n] | /\\./ )* "'" )
- => { token( TK_Slit );};
- ( 'L'? '"' ( [^"\\\n] | /\\./ )* '"' )
- => { token( TK_Dlit );};
-
- # Identifiers
- ( [a-zA-Z_] [a-zA-Z0-9_]* )
- =>{ token( TK_Id );};
-
- # Floating literals.
- fract_const = digit* '.' digit+ | digit+ '.';
- exponent = [eE] [+\-]? digit+;
- float_suffix = [flFL];
-
- ( fract_const exponent? float_suffix? |
- digit+ exponent float_suffix? )
- => { token( TK_Float );};
-
- # Integer decimal. Leading part buffered by float.
- ( ( '0' | [1-9] [0-9]* ) [ulUL]{0,3} )
- => { token( TK_IntegerDecimal );};
-
- # Integer octal. Leading part buffered by float.
- ( '0' [0-9]+ [ulUL]{0,2} )
- => { token( TK_IntegerOctal );};
-
- # Integer hex. Leading 0 buffered by float.
- ( '0' ( 'x' [0-9a-fA-F]+ [ulUL]{0,2} ) )
- => { token( TK_IntegerHex );};
-
- # Only buffer the second item, first buffered by symbol. */
- '::' => {token( TK_NameSep );};
- '==' => {token( TK_EqualsEquals );};
- '!=' => {token( TK_NotEquals );};
- '&&' => {token( TK_AndAnd );};
- '||' => {token( TK_OrOr );};
- '*=' => {token( TK_MultAssign );};
- '/=' => {token( TK_DivAssign );};
- '%=' => {token( TK_PercentAssign );};
- '+=' => {token( TK_PlusAssign );};
- '-=' => {token( TK_MinusAssign );};
- '&=' => {token( TK_AmpAssign );};
- '^=' => {token( TK_CaretAssign );};
- '|=' => {token( TK_BarAssign );};
- '++' => {token( TK_PlusPlus );};
- '--' => {token( TK_MinusMinus );};
- '->' => {token( TK_Arrow );};
- '->*' => {token( TK_ArrowStar );};
- '.*' => {token( TK_DotStar );};
-
- # Three char compounds, first item already buffered. */
- '...' => { token( TK_DotDotDot );};
-
- # Single char symbols.
- ( punct - [_"'] ) => { token( ts[0] );};
-
- action comment {
- token( TK_Comment );
- }
-
- # Comments and whitespace.
- '/*' ( any* $0 '*/' @1 ) => comment;
- '//' ( any* $0 '\n' @1 ) => comment;
- ( any - 33..126 )+ => { token( TK_Whitespace );};
-
- *|;
-
- }%%
-
- %% write data noprefix;
-
- void init( )
- {
- %% write init;
- }
-
- void execute( const(char)* data, ulong len )
- {
- const(char) *p = data;
- const(char) *pe = data + len;
- const(char) *eof = pe;
-
- %% write exec;
- }
-
- // Indicate that there is no more data. Returns -1 if the machine finishes
- // in the error state and does not accept, 0 if the machine finishes
- // in any other non-accepting state and 1 if the machine finishes in an
- // accepting state.
- int finish( )
- {
- if ( cs == error )
- return -1;
- if ( cs >= first_final )
- return 1;
- return 0;
- }
-};
-
-static const int BUFSIZE = 12;
-
-void test( const(char) buf[] )
-{
- Scanner scanner = new Scanner();
- scanner.init();
-
- scanner.execute( buf.ptr, buf.length );
- if ( scanner.cs == Scanner.error ) {
- /* Machine failed before finding a token. */
- printf("PARSE ERROR\n");
- }
- scanner.finish();
-}
-
-int main()
-{
- test(
- "\"\\\"hi\" /*\n"
- "*/\n"
- "44 .44\n"
- "44. 44\n"
- "44 . 44\n"
- "44.44\n"
- "_hithere22"
- );
-
- test(
- "'\\''\"\\n\\d'\\\"\"\n"
- "hi\n"
- "99\n"
- ".99\n"
- "99e-4\n"
- "->*\n"
- "||\n"
- "0x98\n"
- "0x\n"
- "//\n"
- "/* * */"
- );
-
- test(
- "'\n"
- "'\n"
- );
-
- return 0;
-}
-
-##### OUTPUT #####
-<192> "\"hi"
-<241>
-<242> /*
-*/
-<241>
-
-<218> 44
-<241>
-<194> .44
-<241>
-
-<194> 44.
-<241>
-<218> 44
-<241>
-
-<218> 44
-<241>
-<46> .
-<241>
-<218> 44
-<241>
-
-<194> 44.44
-<241>
-
-<195> _hithere22
-<193> '\''
-<192> "\n\d'\""
-<241>
-
-<195> hi
-<241>
-
-<218> 99
-<241>
-
-<194> .99
-<241>
-
-<194> 99e-4
-<241>
-
-<214> ->*
-<241>
-
-<226> ||
-<241>
-
-<220> 0x98
-<241>
-
-<218> 0
-<195> x
-<241>
-
-<242> //
-
-<242> /* * */
-PARSE ERROR
diff --git a/test/ragel.d/cppscan6.rl b/test/ragel.d/cppscan6.rl
deleted file mode 100644
index 3952733b..00000000
--- a/test/ragel.d/cppscan6.rl
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- * @LANG: indep
- * @PROHIBIT_LANGUAGES: cv ruby ocaml rust crack
- * @NEEDS_EOF: yes
- *
- * const char *data = ts;
- * int len = te - ts;
- * cout << "<" << tok << "> ";
- * for ( int i = 0; i < len; i++ )
- * cout << data[i];
- * cout << '\n';
- */
-
-ptr ts;
-ptr te;
-int act;
-int token;
-
-%%{
- machine scanner;
-
- action comment {
- token = 242;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- }
-
-
- main := |*
-
- # Single and double literals.
- ( 'L'? "'" ( [^'\\\n] | '\\' any )* "'" )
- => {
- token = 193;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- ( 'L'? '"' ( [^"\\\n] | '\\' any )* '"' )
- => {
- token = 192;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
-
- # Identifiers
- ( [a-zA-Z_] [a-zA-Z0-9_]* )
- =>{
- token = 195;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
-
- # Floating literals.
- fract_const = digit* '.' digit+ | digit+ '.';
- exponent = [eE] [+\-]? digit+;
- float_suffix = [flFL];
-
- ( fract_const exponent? float_suffix? |
- digit+ exponent float_suffix? )
- => {
- token = 194;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
-
- # Integer decimal. Leading part buffered by float.
- ( ( '0' | [1-9] [0-9]* ) [ulUL]? )
- => {
- token = 218;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
-
- # Integer octal. Leading part buffered by float.
- ( '0' [0-9]+ [ulUL]? )
- => {
- token = 219;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
-
- # Integer hex. Leading 0 buffered by float.
- ( '0' ( 'x' [0-9a-fA-F]+ [ulUL]? ) )
- => {
- token = 220;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
-
- # Only buffer the second item, first buffered by symbol.
- '::' => {
- token = 197;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- '==' => {
- token = 223;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- '!=' => {
- token = 224;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- '&&' => {
- token = 225;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- '||' => {
- token = 226;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- '*=' => {
- token = 227;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- '/=' => {
- token = 228;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- '%=' => {
- token = 229;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- '+=' => {
- token = 230;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- '-=' => {
- token = 231;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- '&=' => {
- token = 232;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- '^=' => {
- token = 233;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- '|=' => {
- token = 234;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- '++' => {
- token = 212;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- '--' => {
- token = 213;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- '->' => {
- token = 211;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- '->*' => {
- token = 214;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- '.*' => {
- token = 215;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
-
- # Three char compounds, first item already buffered.
- '...' => {
- token = 240;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
-
- # Single char symbols.
- ( punct - [_"'] ) => {
- token = <int>(first_token_char);
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
-
- # Comments and whitespace.
- '/!' ( any* $0 '!/' @1 ) => comment;
- '//' ( any* $0 '\n' @1 ) => comment;
- ( any - 33..126 )+ => {
- token = 241;
- print_str "<";
- print_int token;
- print_str "> ";
- print_token;
- print_str "\n";
- };
- *|;
-}%%
-
-##### INPUT #####
-"\"\\\"hi\" /!\n!/\n44 .44\n44. 44\n44 . 44\n44.44\n_hithere22"
-"'\\''\"\\n\\d'\\\"\"\nhi\n99\n.99\n99e-4\n->*\n||\n0x98\n0x\n//\n/! * !/"
-"'\n'\n"
-##### OUTPUT #####
-<192> "\"hi"
-<241>
-<242> /!
-!/
-<241>
-
-<218> 44
-<241>
-<194> .44
-<241>
-
-<194> 44.
-<241>
-<218> 44
-<241>
-
-<218> 44
-<241>
-<46> .
-<241>
-<218> 44
-<241>
-
-<194> 44.44
-<241>
-
-<195> _hithere22
-ACCEPT
-<193> '\''
-<192> "\n\d'\""
-<241>
-
-<195> hi
-<241>
-
-<218> 99
-<241>
-
-<194> .99
-<241>
-
-<194> 99e-4
-<241>
-
-<214> ->*
-<241>
-
-<226> ||
-<241>
-
-<220> 0x98
-<241>
-
-<218> 0
-<195> x
-<241>
-
-<242> //
-
-<242> /! * !/
-ACCEPT
-FAIL
diff --git a/test/ragel.d/crack1.rl b/test/ragel.d/crack1.rl
deleted file mode 100644
index 2154416d..00000000
--- a/test/ragel.d/crack1.rl
+++ /dev/null
@@ -1,39 +0,0 @@
-// @LANG: crack
-
-import crack.io cout;
-
-%%{
- machine atoi;
-
- main := '-'? [0-9]+ '.' @{
- cout `match\n`;
- };
-}%%
-
-%% write data;
-
-void m( String s )
-{
- byteptr data = s.buffer;
- int p = 0;
- int pe = s.size;
- int cs;
-
- %% write init;
- %% write exec;
-}
-
-void main()
-{
- m( "-99." );
- m( "100." );
- m( "100x." );
- m( "1000." );
-}
-
-main();
-
-##### OUTPUT #####
-match
-match
-match
diff --git a/test/ragel.d/curs1.rl b/test/ragel.d/curs1.rl
deleted file mode 100644
index 71c5c43c..00000000
--- a/test/ragel.d/curs1.rl
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * @LANG: indep
- */
-
-int return_to;
-
-%%{
- machine curs1;
-
- unused := 'unused';
-
- one := 'one' @{
- print_str "one\n";
- fnext *return_to;
- };
-
- two := 'two' @{
- print_str "two\n";
- fnext *return_to;
- };
-
- main :=
- '1' @{ return_to = fcurs; fnext one; }
- | '2' @{ return_to = fcurs; fnext two; }
- | '\n';
-}%%
-
-##### INPUT #####
-"1one2two1one\n"
-##### OUTPUT #####
-one
-two
-one
-ACCEPT
diff --git a/test/ragel.d/element1.rl b/test/ragel.d/element1.rl
deleted file mode 100644
index 5150ec17..00000000
--- a/test/ragel.d/element1.rl
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * @LANG: c++
- */
-
-#include <iostream>
-using namespace std;
-
-struct LangEl
-{
- int key;
- const char *name;
-};
-
-struct Fsm
-{
- int cs;
-
- // Initialize the machine. Invokes any init statement blocks. Returns 0
- // if the machine begins in a non-accepting state and 1 if the machine
- // begins in an accepting state.
- int init( );
-
- // Execute the machine on a block of data. Returns -1 if after processing
- // the data, the machine is in the error state and can never accept, 0 if
- // the machine is in a non-accepting state and 1 if the machine is in an
- // accepting state.
- int execute( LangEl *data, int len );
-
- // Indicate that there is no more data. Returns -1 if the machine finishes
- // in the error state and does not accept, 0 if the machine finishes
- // in any other non-accepting state and 1 if the machine finishes in an
- // accepting state.
- int finish( );
-
-};
-
-%%{
- machine Fsm;
-
- alphtype int;
- getkey fpc->key;
- variable eof eof_marker;
-
- action a1 {}
- action a2 {}
- action a3 {}
-
- main := ( 1 2* 3 )
- ${cout << fpc->name << endl;}
- %/{cout << "accept" << endl;};
-}%%
-
-%% write data;
-
-int Fsm::init( )
-{
- %% write init;
- return 0;
-}
-
-int Fsm::execute( LangEl *data, int len )
-{
- LangEl *p = data;
- LangEl *pe = data + len;
- LangEl *eof_marker = pe;
- %% write exec;
-
- if ( cs == Fsm_error )
- return -1;
- if ( cs >= Fsm_first_final )
- return 1;
- return 0;
-}
-
-int Fsm::finish( )
-{
- if ( cs == Fsm_error )
- return -1;
- if ( cs >= Fsm_first_final )
- return 1;
- return 0;
-}
-
-int main( )
-{
- static Fsm fsm;
- static LangEl lel[] = {
- {1, "one"},
- {2, "two-a"},
- {2, "two-b"},
- {2, "two-c"},
- {3, "three"}
- };
-
- fsm.init();
- fsm.execute( lel, 5 );
- fsm.finish();
- return 0;
-}
-
-##### OUTPUT #####
-one
-two-a
-two-b
-two-c
-three
-accept
diff --git a/test/ragel.d/element2.rl b/test/ragel.d/element2.rl
deleted file mode 100644
index ff129612..00000000
--- a/test/ragel.d/element2.rl
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stdio.h>
-
-struct LangEl
-{
- int key;
- char *name;
-};
-
-struct fsm
-{
- int cs;
-};
-
-%%{
- machine fsm;
- alphtype int;
- getkey fpc->key;
- variable cs fsm->cs;
-
- action a1 {}
- action a2 {}
- action a3 {}
-
- main := ( 1 2* 3 )
- ${printf("%s\n", fpc->name);}
- %/{printf("accept\n");};
-}%%
-
-%% write data;
-
-void fsm_init( struct fsm *fsm )
-{
- %% write init;
-}
-
-void fsm_execute( struct fsm *fsm, struct LangEl *_data, int _len )
-{
- struct LangEl *p = _data;
- struct LangEl *pe = _data+_len;
- struct LangEl *eof = pe;
-
- %% write exec;
-}
-
-int fsm_finish( struct fsm *fsm )
-{
- if ( fsm->cs == fsm_error )
- return -1;
- if ( fsm->cs >= fsm_first_final )
- return 1;
- return 0;
-}
-
-int main()
-{
- static struct fsm fsm;
- static struct LangEl lel[] = {
- {1, "one"},
- {2, "two-a"},
- {2, "two-b"},
- {2, "two-c"},
- {3, "three"}
- };
-
- fsm_init( &fsm );
- fsm_execute( &fsm, lel, 5 );
- fsm_finish( &fsm );
-
- return 0;
-}
-
-##### OUTPUT #####
-one
-two-a
-two-b
-two-c
-three
-accept
diff --git a/test/ragel.d/element3.rl b/test/ragel.d/element3.rl
deleted file mode 100644
index a62db226..00000000
--- a/test/ragel.d/element3.rl
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * @LANG: obj-c
- */
-
-#include <stdio.h>
-#include <Foundation/Foundation.h>
-
-struct LangEl
-{
- int key;
- char *name;
-};
-
-@interface Fsm : NSObject
-{
-@public
- int cs;
-};
-
-// Initialize the machine. Invokes any init statement blocks. Returns 0
-// if the machine begins in a non-accepting state and 1 if the machine
-// begins in an accepting state.
-- (int) initFsm;
-
-// Execute the machine on a block of data. Returns -1 if after processing
-// the data, the machine is in the error state and can never accept, 0 if
-// the machine is in a non-accepting state and 1 if the machine is in an
-// accepting state.
-- (int) executeWithData:( struct LangEl *)data len:(int)len;
-
-// Indicate that there is no more data. Returns -1 if the machine finishes
-// in the error state and does not accept, 0 if the machine finishes
-// in any other non-accepting state and 1 if the machine finishes in an
-// accepting state.
-- (int) finish;
-
-@end;
-
-
-@implementation Fsm
-
-%%{
- machine Fsm;
-
- alphtype int;
- getkey fpc->key;
-
- action a1 {}
- action a2 {}
- action a3 {}
-
- main := ( 1 2* 3 )
- ${printf("%s\n", fpc->name);}
- %/{printf("accept\n");};
-}%%
-
-%% write data;
-
-- (int) initFsm;
-{
- %% write init;
- return 0;
-}
-
-- (int) executeWithData:( struct LangEl *)_data len:(int)_len;
-{
- struct LangEl *p = _data;
- struct LangEl *pe = _data + _len;
- struct LangEl *eof = pe;
- %% write exec;
-
- if ( self->cs == Fsm_error )
- return -1;
- return ( self->cs >= Fsm_first_final ) ? 1 : 0;
-}
-
-- (int) finish;
-{
- if ( self->cs == Fsm_error )
- return -1;
- return ( self->cs >= Fsm_first_final ) ? 1 : 0;
-}
-
-
-@end
-
-int main()
-{
- static Fsm *fsm;
- static struct LangEl lel[] = {
- {1, "one"},
- {2, "two-a"},
- {2, "two-b"},
- {2, "two-c"},
- {3, "three"}
- };
-
- fsm = [[Fsm alloc] init];
- [fsm initFsm];
- [fsm executeWithData:lel len:5];
- [fsm finish];
-
- return 0;
-}
-
-@interface Fsm2 : NSObject
-{
- // The current state may be read and written to from outside of the
- // machine. From within action code, curs is -1 and writing to it has no
- // effect.
- @public
- int cs;
-
- @protected
-
-}
-
-// Execute the machine on a block of data. Returns -1 if after processing
-// the data, the machine is in the error state and can never accept, 0 if
-// the machine is in a non-accepting state and 1 if the machine is in an
-// accepting state.
-- (int)
-executeWithElements:(int) elements
-length:(unsigned)length;
-
-@end
-
-@implementation Fsm2
-- (int)
-executeWithElements:(int)elements
-length:(unsigned)length;
-{
- return 0;
-}
-@end
-
-##### OUTPUT #####
-one
-two-a
-two-b
-two-c
-three
-accept
diff --git a/test/ragel.d/empty1.rl b/test/ragel.d/empty1.rl
deleted file mode 100644
index 39078902..00000000
--- a/test/ragel.d/empty1.rl
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * @LANG: indep
- */
-
-%%{
- machine empty1;
- main := empty;
-}%%
-
-##### INPUT #####
-""
-"x"
-##### OUTPUT #####
-FAIL
-FAIL
diff --git a/test/ragel.d/eofact.h b/test/ragel.d/eofact.h
deleted file mode 100644
index d547f87e..00000000
--- a/test/ragel.d/eofact.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef _EOFACT_H
-#define _EOFACT_H
-
-struct eofact
-{
- int cs;
-};
-
-#endif
diff --git a/test/ragel.d/eofact.rl b/test/ragel.d/eofact.rl
deleted file mode 100644
index 83ad2a7e..00000000
--- a/test/ragel.d/eofact.rl
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * @LANG: indep
- * @NEEDS_EOF: yes
- *
- * Test works with split code gen.
- */
-
-%%{
- machine eofact;
-
- action a1 { print_str "a1\n"; }
- action a2 { print_str "a2\n"; }
- action a3 { print_str "a3\n"; }
- action a4 { print_str "a4\n"; }
-
-
- main := (
- 'hello' @eof a1 %eof a2 '\n'? |
- 'there' @eof a3 %eof a4
- );
-
-}%%
-
-##### INPUT #####
-""
-"h"
-"hell"
-"hello"
-"hello\n"
-"t"
-"ther"
-"there"
-"friend"
-##### OUTPUT #####
-a1
-a3
-FAIL
-a1
-FAIL
-a1
-FAIL
-a2
-ACCEPT
-ACCEPT
-a3
-FAIL
-a3
-FAIL
-a4
-ACCEPT
-FAIL
diff --git a/test/ragel.d/eofcall1.rl b/test/ragel.d/eofcall1.rl
deleted file mode 100644
index 89175548..00000000
--- a/test/ragel.d/eofcall1.rl
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * @LANG: indep
- * @NEEDS_EOF: yes
- * @PROHIBIT_LANGUAGES: cv ruby ocaml rust crack
- * @PROHIBIT_FLAGS: --var-backend
- *
- * Testing fcall in an EOF action.
- */
-
-bool neg;
-int value;
-
-value = 0;
-neg = false;
-
-int top;
-int stack[32];
-
-%%{
- machine atoi;
-
- action begin {
- neg = false;
- value = 0;
- }
-
- action see_neg {
- neg = true;
- }
-
- action add_digit {
- value = value * 10 + <int>(fc - 48);
- }
-
- action finish {
- if ( neg ) {
- value = -1 * value;
- }
- }
- action print {
- print_int value;
- print_str "\n";
- }
-
-
- atoi = (
- ('-'@see_neg | '+')? (digit @add_digit)+
- ) >begin %finish;
-
- action done
- {
- print_str "done: ";
- print_off;
- print_str "\n";
- }
-
- action extra
- {
- print_str "goto extra\n";
- fhold;
- fcall extra;
- }
-
- extra := "" %done;
-
- main := atoi '\n' @print %extra;
-}%%
-
-##### INPUT #####
- "1\n"
- "12\n"
- "222222\n"
- "+2123\n"
- "213 3213\n"
- "-12321\n"
- "--123\n"
- "-99\n"
- " -3000\n"
-##### OUTPUT #####
-1
-goto extra
-done: 2
-ACCEPT
-12
-goto extra
-done: 3
-ACCEPT
-222222
-goto extra
-done: 7
-ACCEPT
-2123
-goto extra
-done: 6
-ACCEPT
-FAIL
--12321
-goto extra
-done: 7
-ACCEPT
-FAIL
--99
-goto extra
-done: 4
-ACCEPT
-FAIL
diff --git a/test/ragel.d/eofcall2.rl b/test/ragel.d/eofcall2.rl
deleted file mode 100644
index eabfac75..00000000
--- a/test/ragel.d/eofcall2.rl
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * @LANG: indep
- * @NEEDS_EOF: yes
- * @PROHIBIT_LANGUAGES: cv ruby ocaml rust crack
- * @PROHIBIT_FLAGS: --var-backend
- *
- * Testing fcall * in an EOF action.
- */
-
-bool neg;
-int value;
-
-value = 0;
-neg = false;
-
-int top;
-int stack[32];
-
-%%{
- machine atoi;
-
- action begin {
- neg = false;
- value = 0;
- }
-
- action see_neg {
- neg = true;
- }
-
- action add_digit {
- value = value * 10 + <int>(fc - 48);
- }
-
- action finish {
- if ( neg ) {
- value = -1 * value;
- }
- }
- action print {
- print_int value;
- print_str "\n";
- }
-
-
- atoi = (
- ('-'@see_neg | '+')? (digit @add_digit)+
- ) >begin %finish;
-
- action done
- {
- print_str "done: ";
- print_off;
- print_str "\n";
- }
-
- action extra
- {
- print_str "goto extra\n";
- fhold;
- fcall *fentry(extra);
- }
-
- extra := "" %done;
-
- main := atoi '\n' @print %extra;
-}%%
-
-##### INPUT #####
- "1\n"
- "12\n"
- "222222\n"
- "+2123\n"
- "213 3213\n"
- "-12321\n"
- "--123\n"
- "-99\n"
- " -3000\n"
-##### OUTPUT #####
-1
-goto extra
-done: 2
-ACCEPT
-12
-goto extra
-done: 3
-ACCEPT
-222222
-goto extra
-done: 7
-ACCEPT
-2123
-goto extra
-done: 6
-ACCEPT
-FAIL
--12321
-goto extra
-done: 7
-ACCEPT
-FAIL
--99
-goto extra
-done: 4
-ACCEPT
-FAIL
diff --git a/test/ragel.d/eofgoto1.rl b/test/ragel.d/eofgoto1.rl
deleted file mode 100644
index e253d0f7..00000000
--- a/test/ragel.d/eofgoto1.rl
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * @LANG: indep
- * @NEEDS_EOF: yes
- * @PROHIBIT_LANGUAGES: cv ruby ocaml rust crack
- * @PROHIBIT_FLAGS: --var-backend
- *
- * Testing fgoto in an EOF action.
- */
-
-
-bool neg;
-int value;
-
-value = 0;
-neg = false;
-
-%%{
- machine atoi;
-
- action begin {
- neg = false;
- value = 0;
- }
-
- action see_neg {
- neg = true;
- }
-
- action add_digit {
- value = value * 10 + <int>(fc - 48);
- }
-
- action finish {
- if ( neg ) {
- value = -1 * value;
- }
- }
- action print {
- print_int value;
- print_str "\n";
- }
-
-
- atoi = (
- ('-'@see_neg | '+')? (digit @add_digit)+
- ) >begin %finish;
-
- action done
- {
- print_str "done: ";
- print_off;
- print_str "\n";
- }
-
- action extra
- {
- print_str "goto extra\n";
- fhold;
- fgoto extra;
- }
-
- extra := "" %done;
-
- main := atoi '\n' @print %extra;
-}%%
-
-##### INPUT #####
- "1\n"
- "12\n"
- "222222\n"
- "+2123\n"
- "213 3213\n"
- "-12321\n"
- "--123\n"
- "-99\n"
- " -3000\n"
-##### OUTPUT #####
-1
-goto extra
-done: 2
-ACCEPT
-12
-goto extra
-done: 3
-ACCEPT
-222222
-goto extra
-done: 7
-ACCEPT
-2123
-goto extra
-done: 6
-ACCEPT
-FAIL
--12321
-goto extra
-done: 7
-ACCEPT
-FAIL
--99
-goto extra
-done: 4
-ACCEPT
-FAIL
diff --git a/test/ragel.d/eofgoto2.rl b/test/ragel.d/eofgoto2.rl
deleted file mode 100644
index f42048d7..00000000
--- a/test/ragel.d/eofgoto2.rl
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * @LANG: indep
- * @NEEDS_EOF: yes
- * @PROHIBIT_LANGUAGES: cv ruby ocaml rust crack
- * @PROHIBIT_FLAGS: --var-backend
- *
- * Testing fgoto * in an EOF action.
- */
-
-bool neg;
-int value;
-
-value = 0;
-neg = false;
-
-%%{
- machine atoi;
-
- action begin {
- neg = false;
- value = 0;
- }
-
- action see_neg {
- neg = true;
- }
-
- action add_digit {
- value = value * 10 + <int>(fc - 48);
- }
-
- action finish {
- if ( neg ) {
- value = -1 * value;
- }
- }
- action print {
- print_int value;
- print_str "\n";
- }
-
-
- atoi = (
- ('-'@see_neg | '+')? (digit @add_digit)+
- ) >begin %finish;
-
- action done
- {
- print_str "done: ";
- print_off;
- print_str "\n";
- }
-
- action extra
- {
- print_str "goto extra\n";
- fhold;
- fgoto *fentry(extra);
- }
-
- extra := "" %done;
-
- main := atoi '\n' @print %extra;
-}%%
-
-##### INPUT #####
- "1\n"
- "12\n"
- "222222\n"
- "+2123\n"
- "213 3213\n"
- "-12321\n"
- "--123\n"
- "-99\n"
- " -3000\n"
-##### OUTPUT #####
-1
-goto extra
-done: 2
-ACCEPT
-12
-goto extra
-done: 3
-ACCEPT
-222222
-goto extra
-done: 7
-ACCEPT
-2123
-goto extra
-done: 6
-ACCEPT
-FAIL
--12321
-goto extra
-done: 7
-ACCEPT
-FAIL
--99
-goto extra
-done: 4
-ACCEPT
-FAIL
diff --git a/test/ragel.d/eofret1.rl b/test/ragel.d/eofret1.rl
deleted file mode 100644
index fc2b8cab..00000000
--- a/test/ragel.d/eofret1.rl
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * @LANG: indep
- * @NEEDS_EOF: yes
- * @PROHIBIT_LANGUAGES: cv ruby ocaml rust crack
- * @PROHIBIT_FLAGS: --var-backend
- *
- * Testing fret in an EOF action.
- */
-
-bool neg;
-int value;
-
-value = 0;
-neg = false;
-
-int top;
-int stack[32];
-
-%%{
- machine atoi;
-
- action begin {
- neg = false;
- value = 0;
- }
-
- action see_neg {
- neg = true;
- }
-
- action add_digit {
- value = value * 10 + <int>(fc - 48);
- }
-
- action finish {
- if ( neg ) {
- value = -1 * value;
- }
- }
- action print {
- print_int value;
- print_str "\n";
- }
-
-
- atoi = (
- ('-'@see_neg | '+')? (digit @add_digit)+
- ) >begin %finish;
-
- action done
- {
- print_str "done: ";
- print_off;
- print_str "\n";
- }
-
- action extra
- {
- print_str "goto extra\n";
- fhold;
- fret;
- }
-
- # Jump to the real main so we can fret back here to check the offset.
- main := any @{ fhold; fcall atoi; } "" %done;
-
- main_ := atoi '\n' @print %extra;
-}%%
-
-##### INPUT #####
- "1\n"
- "12\n"
- "222222\n"
- "+2123\n"
- "213 3213\n"
- "-12321\n"
- "--123\n"
- "-99\n"
- " -3000\n"
-##### OUTPUT #####
-1
-goto extra
-done: 2
-ACCEPT
-12
-goto extra
-done: 3
-ACCEPT
-222222
-goto extra
-done: 7
-ACCEPT
-2123
-goto extra
-done: 6
-ACCEPT
-FAIL
--12321
-goto extra
-done: 7
-ACCEPT
-FAIL
--99
-goto extra
-done: 4
-ACCEPT
-FAIL
diff --git a/test/ragel.d/erract1.rl b/test/ragel.d/erract1.rl
deleted file mode 100644
index 65b9f27d..00000000
--- a/test/ragel.d/erract1.rl
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * @LANG: c++
- */
-
-/*
- * Test error actions.
- */
-
-#include <iostream>
-#include <stdio.h>
-#include <string.h>
-
-using namespace std;
-
-struct ErrAct
-{
- int cs;
-
- // Initialize the machine. Invokes any init statement blocks. Returns 0
- // if the machine begins in a non-accepting state and 1 if the machine
- // begins in an accepting state.
- int init( );
-
- // Execute the machine on a block of data. Returns -1 if after processing
- // the data, the machine is in the error state and can never accept, 0 if
- // the machine is in a non-accepting state and 1 if the machine is in an
- // accepting state.
- int execute( const char *data, int len );
-
- // Indicate that there is no more data. Returns -1 if the machine finishes
- // in the error state and does not accept, 0 if the machine finishes
- // in any other non-accepting state and 1 if the machine finishes in an
- // accepting state.
- int finish( );
-};
-
-%%{
- machine ErrAct;
-
- action expect_digit_plus_minus { printf(" DIGIT PLUS MINUS\n"); }
- action expect_digit { printf(" DIGIT\n"); }
- action expect_digit_decimal { printf(" DIGIT DECIMAL\n"); }
-
- float = (
- (
- [\-+] >err expect_digit_plus_minus %err expect_digit |
- ""
- )
- ( [0-9] [0-9]* $err expect_digit_decimal )
- ( '.' [0-9]+ $err expect_digit )?
- );
-
- main := float '\n';
-}%%
-
-%% write data;
-
-int ErrAct::init( )
-{
- %% write init;
- return 0;
-}
-
-int ErrAct::execute( const char *_data, int _len )
-{
- const char *p = _data;
- const char *pe = _data+_len;
- const char *eof = pe;
- %% write exec;
-
- if ( cs == ErrAct_error )
- return -1;
- if ( cs >= ErrAct_first_final )
- return 1;
- return 0;
-}
-
-int ErrAct::finish( )
-{
- if ( cs == ErrAct_error )
- return -1;
- if ( cs >= ErrAct_first_final )
- return 1;
- return 0;
-}
-
-#define BUFSIZE 1024
-
-void test( const char *buf )
-{
- ErrAct errAct;
- errAct.init();
- errAct.execute( buf, strlen(buf) );
- if ( errAct.finish() > 0 )
- cout << "ACCEPT" << endl;
- else
- cout << "FAIL" << endl;
-}
-
-int main()
-{
- test( "1\n" );
- test( "+1\n" );
- test( "-1\n" );
- test( "1.1\n" );
- test( "+1.1\n" );
- test( "-1.1\n" );
- test( "a\n" );
- test( "-\n" );
- test( "+\n" );
- test( "-a\n" );
- test( "+b\n" );
- test( "1.\n" );
- test( "1d\n" );
- test( "1.d\n" );
- test( "1.1d\n" );
- return 0;
-}
-
-##### OUTPUT #####
-ACCEPT
-ACCEPT
-ACCEPT
-ACCEPT
-ACCEPT
-ACCEPT
- DIGIT PLUS MINUS
-FAIL
- DIGIT
-FAIL
- DIGIT
-FAIL
- DIGIT
-FAIL
- DIGIT
-FAIL
- DIGIT
-FAIL
- DIGIT DECIMAL
-FAIL
- DIGIT
-FAIL
- DIGIT
-FAIL
diff --git a/test/ragel.d/erract2.rl b/test/ragel.d/erract2.rl
deleted file mode 100644
index f6007151..00000000
--- a/test/ragel.d/erract2.rl
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * @LANG: indep
- * @NEEDS_EOF: yes
- *
- * Test error actions.
- */
-
-%%{
- machine erract;
-
- action err_start { print_str "err_start\n"; }
- action err_all { print_str "err_all\n"; }
- action err_middle { print_str "err_middle\n"; }
- action err_out { print_str "err_out\n"; }
-
- action eof_start { print_str "eof_start\n"; }
- action eof_all { print_str "eof_all\n"; }
- action eof_middle { print_str "eof_middle\n"; }
- action eof_out { print_str "eof_out\n"; }
-
- main := ( 'hello'
- >err err_start $err err_all <>err err_middle %err err_out
- >eof eof_start $eof eof_all <>eof eof_middle %eof eof_out
- ) '\n';
-}%%
-
-##### INPUT #####
-""
-"h"
-"x"
-"he"
-"hx"
-"hel"
-"hex"
-"hell"
-"helx"
-"hello"
-"hellx"
-"hello\n"
-"hellox"
-##### OUTPUT #####
-err_start
-eof_start
-err_all
-eof_all
-FAIL
-err_all
-err_middle
-eof_all
-eof_middle
-FAIL
-err_start
-err_all
-FAIL
-err_all
-err_middle
-eof_all
-eof_middle
-FAIL
-err_all
-err_middle
-FAIL
-err_all
-err_middle
-eof_all
-eof_middle
-FAIL
-err_all
-err_middle
-FAIL
-err_all
-err_middle
-eof_all
-eof_middle
-FAIL
-err_all
-err_middle
-FAIL
-err_all
-err_out
-eof_all
-eof_out
-FAIL
-err_all
-err_middle
-FAIL
-ACCEPT
-err_all
-err_out
-FAIL
diff --git a/test/ragel.d/erract3.rl b/test/ragel.d/erract3.rl
deleted file mode 100644
index 6de07dbb..00000000
--- a/test/ragel.d/erract3.rl
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stdio.h>
-#define IDENT_BUFLEN 256
-
-struct erract
-{
- int cs;
-};
-
-%%{
- machine erract;
- variable cs fsm->cs;
-
- # The data that is to go into the fsm structure.
- action hello_fails { printf("hello fails\n");}
-
- newline = ( any | '\n' @{printf("newline\n");} )*;
- hello = 'hello\n'* $lerr hello_fails @eof hello_fails;
- main := newline | hello;
-}%%
-
-%% write data;
-
-void erract_init( struct erract *fsm )
-{
- %% write init;
-}
-
-void erract_execute( struct erract *fsm, const char *_data, int _len )
-{
- const char *p = _data;
- const char *pe = _data+_len;
- const char *eof = pe;
- %% write exec;
-}
-
-int erract_finish( struct erract *fsm )
-{
- if ( fsm->cs == erract_error )
- return -1;
- else if ( fsm->cs >= erract_first_final )
- return 1;
- return 0;
-}
-
-#include <stdio.h>
-#include <string.h>
-
-struct erract fsm;
-
-void test( char *buf )
-{
- int len = strlen(buf);
- erract_init( &fsm );
- erract_execute( &fsm, buf, len );
- if ( erract_finish( &fsm ) > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
-}
-
-int main()
-{
- test(
- "hello\n"
- "hello\n"
- "hello\n"
- );
-
- test(
- "hello\n"
- "hello\n"
- "hello there\n"
- );
-
- test(
- "hello\n"
- "hello\n"
- "he" );
-
- test( "" );
-
- return 0;
-}
-
-##### OUTPUT #####
-newline
-newline
-newline
-ACCEPT
-newline
-newline
-hello fails
-newline
-ACCEPT
-newline
-newline
-hello fails
-ACCEPT
-ACCEPT
diff --git a/test/ragel.d/erract4.rl b/test/ragel.d/erract4.rl
deleted file mode 100644
index b6910d70..00000000
--- a/test/ragel.d/erract4.rl
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * @LANG: obj-c
- */
-
-#include <stdio.h>
-#include <Foundation/Foundation.h>
-
-#define IDENT_BUFLEN 256
-
-@interface ErrAct : NSObject
-{
-@public
- int cs;
-};
-
-// Initialize the machine. Invokes any init statement blocks. Returns 0
-// if the machine begins in a non-accepting state and 1 if the machine
-// begins in an accepting state.
-- (int) initFsm;
-
-// Execute the machine on a block of data. Returns -1 if after processing
-// the data, the machine is in the error state and can never accept, 0 if
-// the machine is in a non-accepting state and 1 if the machine is in an
-// accepting state.
-- (void) executeWithData:(const char *)data len:(int)len;
-
-// Indicate that there is no more data. Returns -1 if the machine finishes
-// in the error state and does not accept, 0 if the machine finishes
-// in any other non-accepting state and 1 if the machine finishes in an
-// accepting state.
-- (int) finish;
-
-@end
-
-@implementation ErrAct
-
-%%{
- machine ErrAct;
-
- # The data that is to go into the fsm structure.
- action hello_fails { printf("hello fails\n");}
-
- newline = ( any | '\n' @{printf("newline\n");} )*;
- hello = 'hello\n'* $^hello_fails @/hello_fails;
- main := newline | hello;
-}%%
-
-%% write data;
-
-- (int) initFsm;
-{
- %% write init;
- return 1;
-}
-
-- (void) executeWithData:(const char *)_data len:(int)_len;
-{
- const char *p = _data;
- const char *pe = _data + _len;
- const char *eof = pe;
- %% write exec;
-}
-
-- (int) finish;
-{
- if ( cs == ErrAct_error )
- return -1;
- else if ( cs >= ErrAct_first_final )
- return 1;
- return 0;
-}
-
-@end
-
-#include <stdio.h>
-#include <string.h>
-#define BUFSIZE 2048
-
-ErrAct *fsm;
-char buf[BUFSIZE];
-
-void test( char *buf )
-{
- int len = strlen(buf);
- fsm = [[ErrAct alloc] init];
-
- [fsm initFsm];
- [fsm executeWithData:buf len:len];
- if ( [fsm finish] > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
-}
-
-
-int main()
-{
- test(
- "hello\n"
- "hello\n"
- "hello\n"
- );
-
- test(
- "hello\n"
- "hello\n"
- "hello there\n"
- );
-
- test(
- "hello\n"
- "hello\n"
- "he" );
-
- test( "" );
-
- return 0;
-}
-
-##### OUTPUT #####
-newline
-newline
-newline
-ACCEPT
-newline
-newline
-hello fails
-newline
-ACCEPT
-newline
-newline
-hello fails
-ACCEPT
-ACCEPT
diff --git a/test/ragel.d/erract5.rl b/test/ragel.d/erract5.rl
deleted file mode 100644
index d9dca844..00000000
--- a/test/ragel.d/erract5.rl
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * @LANG: obj-c
- */
-
-/*
- * Test error actions.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <Foundation/Foundation.h>
-
-@interface ErrAct : NSObject
-{
-@public
- int cs;
-};
-
-// Initialize the machine. Invokes any init statement blocks. Returns 0
-// if the machine begins in a non-accepting state and 1 if the machine
-// begins in an accepting state.
-- (int) initFsm;
-
-// Execute the machine on a block of data. Returns -1 if after processing
-// the data, the machine is in the error state and can never accept, 0 if
-// the machine is in a non-accepting state and 1 if the machine is in an
-// accepting state.
-- (void) executeWithData:(const char *)data len:(int)len;
-
-// Indicate that there is no more data. Returns -1 if the machine finishes
-// in the error state and does not accept, 0 if the machine finishes
-// in any other non-accepting state and 1 if the machine finishes in an
-// accepting state.
-- (int) finish;
-
-@end
-
-@implementation ErrAct
-
-%%{
- machine ErrAct;
-
- action expect_digit_plus_minus { printf(" DIGIT PLUS MINUS\n"); }
- action expect_digit { printf(" DIGIT\n"); }
- action expect_digit_decimal { printf(" DIGIT DECIMAL\n"); }
-
- float = (
- (
- [\-+] >!expect_digit_plus_minus %!expect_digit |
- ""
- )
- ( [0-9] [0-9]* $!expect_digit_decimal )
- ( '.' [0-9]+ $!expect_digit )?
- );
-
- main := float '\n';
-}%%
-
-%% write data;
-
-- (int) initFsm;
-{
- %% write init;
- return 1;
-}
-
-- (void) executeWithData:(const char *)_data len:(int)_len;
-{
- const char *p = _data;
- const char *pe = _data + _len;
- const char *eof = pe;
- %% write exec;
-}
-
-- (int) finish;
-{
- if ( cs == ErrAct_error )
- return -1;
- else if ( cs >= ErrAct_first_final )
- return 1;
- return 0;
-}
-
-
-@end
-
-#define BUFSIZE 1024
-
-void test( char *buf )
-{
- ErrAct *errAct = [[ErrAct alloc] init];
- [errAct initFsm];
- [errAct executeWithData:buf len:strlen(buf)];
- if ( [errAct finish] > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
-}
-
-int main()
-{
- test( "1\n" );
- test( "+1\n" );
- test( "-1\n" );
- test( "1.1\n" );
- test( "+1.1\n" );
- test( "-1.1\n" );
- test( "a\n" );
- test( "-\n" );
- test( "+\n" );
- test( "-a\n" );
- test( "+b\n" );
- test( "1.\n" );
- test( "1d\n" );
- test( "1.d\n" );
- test( "1.1d\n" );
- return 0;
-}
-
-##### OUTPUT #####
-ACCEPT
-ACCEPT
-ACCEPT
-ACCEPT
-ACCEPT
-ACCEPT
- DIGIT PLUS MINUS
-FAIL
- DIGIT
-FAIL
- DIGIT
-FAIL
- DIGIT
-FAIL
- DIGIT
-FAIL
- DIGIT
-FAIL
- DIGIT DECIMAL
-FAIL
- DIGIT
-FAIL
- DIGIT
-FAIL
diff --git a/test/ragel.d/erract6.rl b/test/ragel.d/erract6.rl
deleted file mode 100644
index def2fcec..00000000
--- a/test/ragel.d/erract6.rl
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * @LANG: c
- */
-
-/*
- * Test of a transition going to the error state.
- */
-
-#include <stdio.h>
-#define BUFSIZE 2048
-
-struct errintrans
-{
- int cs;
-};
-
-%%{
- machine errintrans;
- variable cs fsm->cs;
-
- char = any - (digit | '\n');
- line = char* "\n";
- main := line+;
-}%%
-
-%% write data;
-
-void errintrans_init( struct errintrans *fsm )
-{
- %% write init;
-}
-
-void errintrans_execute( struct errintrans *fsm, const char *_data, int _len )
-{
- const char *p = _data;
- const char *pe = _data+_len;
-
- %% write exec;
-}
-
-int errintrans_finish( struct errintrans *fsm )
-{
- if ( fsm->cs == errintrans_error )
- return -1;
- if ( fsm->cs >= errintrans_first_final )
- return 1;
- return 0;
-}
-
-
-struct errintrans fsm;
-#include <string.h>
-
-void test( char *buf )
-{
- int len = strlen( buf );
- errintrans_init( &fsm );
- errintrans_execute( &fsm, buf, len );
- if ( errintrans_finish( &fsm ) > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
-}
-
-
-int main()
-{
- test(
- "good, does not have numbers\n"
- );
-
- test(
- "bad, has numbers 666\n"
- );
-
- return 0;
-}
-
-##### OUTPUT #####
-ACCEPT
-FAIL
diff --git a/test/ragel.d/erract7.rl b/test/ragel.d/erract7.rl
deleted file mode 100644
index 2a101d26..00000000
--- a/test/ragel.d/erract7.rl
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stdio.h>
-#include <string.h>
-
-%%{
- machine foo;
-
- action on_char { printf("char: %c\n", *p); }
- action on_err { printf("err: %c\n", *p); }
- action to_state { printf("to state: %c\n", *p); }
-
- main := 'heXXX' $on_char $err(on_err) $to(to_state);
-}%%
-
-%% write data;
-
-int main()
-{
- int cs;
- char *p = "hello", *pe = p + strlen(p);
- char *eof = pe;
- %%{
- write init;
- write exec;
- }%%
-
- printf( "rest: %s\n", p );
-
- return 0;
-}
-
-##### OUTPUT #####
-char: h
-to state: h
-char: e
-to state: e
-err: l
-rest: llo
diff --git a/test/ragel.d/erract8.rl b/test/ragel.d/erract8.rl
deleted file mode 100644
index 7d1f3f28..00000000
--- a/test/ragel.d/erract8.rl
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * @LANG: java
- */
-
-class erract8
-{
- %%{
- machine erract8;
-
- action on_char { System.out.println("char: " + data[p]); }
- action on_err { System.out.println("err: " + data[p]); }
- action to_state { System.out.println("to state: " + data[p]); }
-
- main := 'heXXX' $on_char $err(on_err) $to(to_state);
- }%%
-
- %% write data;
-
- static void test( char data[] )
- {
- int cs, p = 0, pe = data.length;
- int eof = pe;
- int top;
-
- %% write init;
- %% write exec;
-
- System.out.println("rest: " + data[p] + data[p+1] + data[p+2]);
- }
-
- public static void main( String args[] )
- {
- test( "hello".toCharArray() );
- }
-}
-
-##### OUTPUT #####
-char: h
-to state: h
-char: e
-to state: e
-err: l
-rest: llo
diff --git a/test/ragel.d/erract9.rl b/test/ragel.d/erract9.rl
deleted file mode 100644
index e95a2282..00000000
--- a/test/ragel.d/erract9.rl
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-# @LANG: ruby
-#
-# Test the host language scanning for ruby.
-#
-
-%%{
- machine erract9;
-
- action on_char { print("char: ", data[p..p], "\n"); }
- action on_err { print("err: ", data[p..p], "\n"); }
- action to_state { print("to state: " , data[p..p], "\n"); }
-
- main := 'heXXX' $on_char $err(on_err) $to(to_state);
-}%%
-
-%% write data;
-
-def run_machine( data )
- p = 0;
- pe = data.length
- eof = pe
- cs = 0
-
- %% write init;
- %% write exec;
-
- print("rest: " , data[p..p+2], "\n")
-end
-
-inp = [
- "hello\n",
-]
-
-inp.each { |str| run_machine(str) }
-
-##### OUTPUT #####
-char: h
-to state: h
-char: e
-to state: e
-err: l
-rest: llo
diff --git a/test/ragel.d/export1.rl b/test/ragel.d/export1.rl
deleted file mode 100644
index dbdb697f..00000000
--- a/test/ragel.d/export1.rl
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stdio.h>
-#include <string.h>
-
-%%{
- machine test;
-
- export c1 = 'c';
- export c2 = 'z';
- export c3 = 't';
-
- commands := (
- c1 . digit* '\n' @{ printf( "c1\n" );} |
- c2 . alpha* '\n' @{ printf( "c2\n" );}|
- c3 . '.'* '\n' @{ printf( "c3\n" );}
- )*;
-
- some_other := any*;
-}%%
-
-%% write exports;
-%% write data;
-
-int test( const char *data, int len )
-{
- int cs = test_en_commands;
- const char *p = data, *pe = data + len;
-
- %% write init nocs;
- %% write exec;
-
- if ( cs >= test_first_final )
- printf("ACCEPT\n");
- else
- printf("ERROR\n");
- return 0;
-}
-
-char data[] = {
- test_ex_c1, '1', '2', '\n',
- test_ex_c2, 'a', 'b', '\n',
- test_ex_c3, '.', '.', '\n', 0
-};
-
-int main()
-{
- test( data, strlen( data ) );
- return 0;
-}
-
-##### OUTPUT #####
-c1
-c2
-c3
-ACCEPT
diff --git a/test/ragel.d/export2.rl b/test/ragel.d/export2.rl
deleted file mode 100644
index 886685de..00000000
--- a/test/ragel.d/export2.rl
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * @LANG: java
- */
-
-class export2
-{
- %%{
- machine test;
-
- export c1 = 'c';
- export c2 = 'z';
- export c3 = 't';
-
- commands := (
- c1 . digit* '\n' @{ System.out.println( "c1" );} |
- c2 . alpha* '\n' @{ System.out.println( "c2" );}|
- c3 . '.'* '\n' @{ System.out.println( "c3" );}
- )*;
-
- other := any*;
- }%%
-
- %% write exports;
- %% write data;
-
- static void test( char data[] )
- {
- int cs = test_en_commands, p = 0, pe = data.length;
- int top;
-
- %% write init nocs;
- %% write exec;
-
- if ( cs >= test_first_final )
- System.out.println( "ACCEPT" );
- else
- System.out.println( "FAIL" );
- }
-
- public static void main( String args[] )
- {
- char data[] = {
- test_ex_c1, '1', '2', '\n',
- test_ex_c2, 'a', 'b', '\n',
- test_ex_c3, '.', '.', '\n',
- };
- test( data );
- }
-}
-
-
-##### OUTPUT #####
-c1
-c2
-c3
-ACCEPT
diff --git a/test/ragel.d/export3.rl b/test/ragel.d/export3.rl
deleted file mode 100644
index fa5ab071..00000000
--- a/test/ragel.d/export3.rl
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# @LANG: ruby
-#
-
-%%{
- machine test;
-
- export c1 = 'c';
- export c2 = 'z';
- export c3 = 't';
-
- commands := (
- c1 . digit* '\n' @{ puts "c1"; } |
- c2 . alpha* '\n' @{ puts "c2"; }|
- c3 . '.'* '\n' @{ puts "c3"; }
- )*;
-
- other := any*;
-}%%
-
-%% write exports;
-%% write data;
-
-def run_machine( data )
- p = 0;
- pe = data.length
- cs = test_en_commands
- val = 0;
- neg = false;
-
- %% write init nocs;
- %% write exec;
- if cs >= test_first_final
- puts "ACCEPT"
- else
- puts "FAIL"
- end
-end
-
-inp = [
- test_ex_c1, ?1, ?2, ?\n,
- test_ex_c2, ?a, ?b, ?\n,
- test_ex_c3, ?., ?., ?\n
-]
-
-run_machine( inp );
-
-##### OUTPUT #####
-c1
-c2
-c3
-ACCEPT
diff --git a/test/ragel.d/export4.rl b/test/ragel.d/export4.rl
deleted file mode 100644
index 7600dd06..00000000
--- a/test/ragel.d/export4.rl
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * @LANG: d
- */
-
-import std.c.stdio;
-import std.string;
-
-%%{
- machine test;
-
- export c1 = 'c';
- export c2 = 'z';
- export c3 = 't';
-
- commands := (
- c1 . digit* '\n' @{ printf( "c1\n" );} |
- c2 . alpha* '\n' @{ printf( "c2\n" );}|
- c3 . '.'* '\n' @{ printf( "c3\n" );}
- )*;
-
- some_other := any*;
-}%%
-
-%% write exports;
-%% write data;
-
-int test( char data[] )
-{
- int cs = test_en_commands;
- char *p = data.ptr, pe = data.ptr + data.length;
-
- %% write init nocs;
- %% write exec;
-
- if ( cs >= test_first_final )
- printf("ACCEPT\n");
- else
- printf("ERROR\n");
- return 0;
-}
-
-char data[] = [
- test_ex_c1, '1', '2', '\n',
- test_ex_c2, 'a', 'b', '\n',
- test_ex_c3, '.', '.', '\n'
-];
-
-int main()
-{
- test( data );
- return 0;
-}
-
-##### OUTPUT #####
-c1
-c2
-c3
-ACCEPT
diff --git a/test/ragel.d/fbreak1.rl b/test/ragel.d/fbreak1.rl
deleted file mode 100644
index 249d85b4..00000000
--- a/test/ragel.d/fbreak1.rl
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * @LANG: go
- *
- * This test case is GoLang only because we need to exercise access in translated
- * output.
- */
-
-package main
-import "fmt"
-
-%%{
- machine fbreak_eof;
- access foo_;
-
- main := "hello\n" %{ fbreak; };
-}%%
-
-%% write data;
-
-var foo_cs = 0;
-
-func prepare() {
- %%write init;
-}
-
-func exec(data string) {
- var p int = 0
- var pe int = len(data)
- var eof int = pe
- %% write exec;
-}
-
-func finish() {
- if foo_cs >= fbreak_eof_first_final {
- fmt.Println("ACCEPT")
- } else {
- fmt.Println("FAIL")
- }
-}
-
-var inp []string = []string {
- "hello\n",
- "there\n",
-};
-
-func main() {
- for _, data := range inp {
- prepare()
- exec(data)
- finish()
- }
-}
-
-##### OUTPUT #####
-ACCEPT
-FAIL
diff --git a/test/ragel.d/fnext1.rl b/test/ragel.d/fnext1.rl
deleted file mode 100644
index 631a29c7..00000000
--- a/test/ragel.d/fnext1.rl
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * @LANG: c
- * @PROHIBIT_FLAGS: --var-backend
- *
- * Tests fnext in combination with fbreak.
- */
-
-#include <string.h>
-#include <stdio.h>
-
-char comm;
-int top;
-int stack [32];
-
-%%{
- machine fnext;
- action break {fbreak;}
-
- main := 'h' @{ /*h*/ fnext e; fbreak; };
- e := 'e' @{ /*e*/ fnext l; } @{ fbreak; };
- l := 'll' @{ /*ll*/ fnext o; } ${ fbreak; };
- o := |* 'o' { /*o*/ fnext nl; fbreak; }; *|;
- nl := '\n' @{ /*nl*/ fbreak; printf("ACCEPT\n"); };
-}%%
-
-int cs;
-char *ts, *te;
-int act;
-
-%% write data;
-
-void init()
-{
- %% write init;
-}
-
-void exec( char *data, int len )
-{
- char *p = data;
- char *pe = data + len;
-
- while ( cs != fnext_error && p < pe ) {
- printf( "%c\n", *p );
- %% write exec;
- }
-}
-
-void finish( )
-{
- if ( cs >= fnext_first_final )
- printf( "ACCEPT\n" );
- else
- printf( "FAIL\n" );
-}
-
-char *inp[] = {
- "hello\n"
-};
-
-int inplen = 1;
-
-int main( )
-{
- int i;
- for ( i = 0; i < inplen; i++ ) {
- init();
- exec( inp[i], strlen(inp[i]) );
- finish();
- }
- return 0;
-}
-
-##### OUTPUT #####
-h
-e
-l
-l
-o
-
-
-ACCEPT
diff --git a/test/ragel.d/fnext2.rl b/test/ragel.d/fnext2.rl
deleted file mode 100644
index 69bfee47..00000000
--- a/test/ragel.d/fnext2.rl
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * @LANG: c
- *
- * Tests fnext in combination with fbreak.
- */
-
-#include <string.h>
-#include <stdio.h>
-
-char comm;
-int top;
-int stack [32];
-
-%%{
- machine fnext;
- action break {fnbreak;}
-
- main := 'h' @{ /*h*/ fnext e; fnbreak; };
- e := 'e' @{ /*e*/ fnext l; } @{ fnbreak; };
- l := 'll' @{ /*ll*/ fnext o; } ${ fnbreak; };
- o := |* 'o' { /*o*/ fnext nl; fnbreak; }; *|;
- nl := '\n' @{ /*nl*/ fnbreak; printf("ACCEPT\n"); };
-}%%
-
-int cs;
-char *ts, *te;
-int act;
-
-%% write data;
-
-void init()
-{
- %% write init;
-}
-
-void exec( char *data, int len )
-{
- char *p = data;
- char *pe = data + len;
-
- while ( cs != fnext_error && p < pe ) {
- printf( "%c\n", *p );
- %% write exec;
- }
-}
-
-void finish( )
-{
- if ( cs >= fnext_first_final )
- printf( "ACCEPT\n" );
- else
- printf( "FAIL\n" );
-}
-
-char *inp[] = {
- "hello\n"
-};
-
-int inplen = 1;
-
-int main( )
-{
- int i;
- for ( i = 0; i < inplen; i++ ) {
- init();
- exec( inp[i], strlen(inp[i]) );
- finish();
- }
- return 0;
-}
-
-##### OUTPUT #####
-h
-e
-l
-l
-o
-
-
-ACCEPT
-ACCEPT
diff --git a/test/ragel.d/fnext3.rl b/test/ragel.d/fnext3.rl
deleted file mode 100644
index 69bfee47..00000000
--- a/test/ragel.d/fnext3.rl
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * @LANG: c
- *
- * Tests fnext in combination with fbreak.
- */
-
-#include <string.h>
-#include <stdio.h>
-
-char comm;
-int top;
-int stack [32];
-
-%%{
- machine fnext;
- action break {fnbreak;}
-
- main := 'h' @{ /*h*/ fnext e; fnbreak; };
- e := 'e' @{ /*e*/ fnext l; } @{ fnbreak; };
- l := 'll' @{ /*ll*/ fnext o; } ${ fnbreak; };
- o := |* 'o' { /*o*/ fnext nl; fnbreak; }; *|;
- nl := '\n' @{ /*nl*/ fnbreak; printf("ACCEPT\n"); };
-}%%
-
-int cs;
-char *ts, *te;
-int act;
-
-%% write data;
-
-void init()
-{
- %% write init;
-}
-
-void exec( char *data, int len )
-{
- char *p = data;
- char *pe = data + len;
-
- while ( cs != fnext_error && p < pe ) {
- printf( "%c\n", *p );
- %% write exec;
- }
-}
-
-void finish( )
-{
- if ( cs >= fnext_first_final )
- printf( "ACCEPT\n" );
- else
- printf( "FAIL\n" );
-}
-
-char *inp[] = {
- "hello\n"
-};
-
-int inplen = 1;
-
-int main( )
-{
- int i;
- for ( i = 0; i < inplen; i++ ) {
- init();
- exec( inp[i], strlen(inp[i]) );
- finish();
- }
- return 0;
-}
-
-##### OUTPUT #####
-h
-e
-l
-l
-o
-
-
-ACCEPT
-ACCEPT
diff --git a/test/ragel.d/forder1.rl b/test/ragel.d/forder1.rl
deleted file mode 100644
index a0139b87..00000000
--- a/test/ragel.d/forder1.rl
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stdio.h>
-#include <string.h>
-
-struct forder
-{
- int cs;
-};
-
-%%{
- machine forder;
- variable cs fsm->cs;
-
- second = 'b'
- >{printf("enter b1\n");}
- >{printf("enter b2\n");}
- ;
-
- first = 'a'
- %{printf("leave a\n");}
- @{printf("finish a\n");}
- ;
-
- main := first . second . '\n';
-}%%
-
-%% write data;
-
-void forder_init( struct forder *fsm )
-{
- %% write init;
-}
-
-void forder_execute( struct forder *fsm, const char *_data, int _len )
-{
- const char *p = _data;
- const char *pe = _data+_len;
-
- %% write exec;
-}
-
-int forder_finish( struct forder *fsm )
-{
- if ( fsm->cs == forder_error )
- return -1;
- if ( fsm->cs >= forder_first_final )
- return 1;
- return 0;
-}
-
-struct forder fsm;
-
-void test( char *buf )
-{
- int len = strlen(buf);
- forder_init( &fsm );
- forder_execute( &fsm, buf, len );
- if ( forder_finish( &fsm ) > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
-}
-
-int main()
-{
- test( "ab\n");
- test( "abx\n");
- test( "" );
-
- test(
- "ab\n"
- "fail after newline\n"
- );
-
- return 0;
-}
-
-##### OUTPUT #####
-finish a
-leave a
-enter b1
-enter b2
-ACCEPT
-finish a
-leave a
-enter b1
-enter b2
-FAIL
-FAIL
-finish a
-leave a
-enter b1
-enter b2
-FAIL
diff --git a/test/ragel.d/forder2.rl b/test/ragel.d/forder2.rl
deleted file mode 100644
index f9e8ec00..00000000
--- a/test/ragel.d/forder2.rl
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stdio.h>
-#include <string.h>
-
-/*
- * After the fact start and ending transitions. Behaves like constructors of
- * and destructors in c++.
- */
-
-struct forder
-{
- int cs;
-};
-
-%%{
- machine forder;
- variable cs fsm->cs;
-
- inner = 'inner'
- >{printf("enter inner\n");}
- ${printf("inside inner\n");}
- %{printf("leave inner\n");}
- ;
-
- outter = inner
- >{printf("enter outter\n");}
- ${printf("inside outter\n");}
- %{printf("leave outter\n");}
- ;
-
- main := outter . '\n';
-}%%
-
-%% write data;
-
-void forder_init( struct forder *fsm )
-{
- %% write init;
-}
-
-void forder_execute( struct forder *fsm, const char *_data, int _len )
-{
- const char *p = _data;
- const char *pe = _data+_len;
-
- %% write exec;
-}
-
-int forder_finish( struct forder *fsm )
-{
- if ( fsm->cs == forder_error )
- return -1;
- if ( fsm->cs >= forder_first_final )
- return 1;
- return 0;
-}
-
-struct forder fsm;
-
-void test( char *buf )
-{
- int len = strlen( buf );
- forder_init( &fsm );
- forder_execute( &fsm, buf, len );
- if ( forder_finish( &fsm ) > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
-}
-
-
-int main()
-{
- test( "inner\n");
-
- test(
- "inner\n"
- "foobar\n"
- );
-
- test( "" );
- test( "\n" );
- test( "inn\n" );
-
- return 0;
-}
-
-##### OUTPUT #####
-enter outter
-enter inner
-inside inner
-inside outter
-inside inner
-inside outter
-inside inner
-inside outter
-inside inner
-inside outter
-inside inner
-inside outter
-leave inner
-leave outter
-ACCEPT
-enter outter
-enter inner
-inside inner
-inside outter
-inside inner
-inside outter
-inside inner
-inside outter
-inside inner
-inside outter
-inside inner
-inside outter
-leave inner
-leave outter
-FAIL
-FAIL
-FAIL
-enter outter
-enter inner
-inside inner
-inside outter
-inside inner
-inside outter
-inside inner
-inside outter
-FAIL
diff --git a/test/ragel.d/forder3.rl b/test/ragel.d/forder3.rl
deleted file mode 100644
index 65eee519..00000000
--- a/test/ragel.d/forder3.rl
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stdio.h>
-#include <string.h>
-
-struct forder
-{
- int cs;
-};
-
-%%{
- machine forder;
- variable cs fsm->cs;
-
- m1 = ( "" %{printf("enter m1 aa\n");} |
- 'aa'* >{printf("enter m1 aa\n");} %{printf("leave m1 aa\n");} )
- 'b' @{printf("through m1 b\n");} . 'b'* . 'a'*;
-
- m2 = 'bbb'* 'aa'*;
-
- main := (
- m1 %{printf("accept m1\n");} |
- "" %{printf("enter m2\n");} |
- m2 >{printf("enter m2\n");} %{printf("accept m2\n");}
- ) . '\n';
-}%%
-
-%% write data;
-
-void forder_init( struct forder *fsm )
-{
- %% write init;
-}
-
-void forder_execute( struct forder *fsm, const char *_data, int _len )
-{
- const char *p = _data;
- const char *pe = _data+_len;
-
- %% write exec;
-}
-
-int forder_finish( struct forder *fsm )
-{
- if ( fsm->cs == forder_error )
- return -1;
- if ( fsm->cs >= forder_first_final )
- return 1;
- return 0;
-}
-
-struct forder fsm;
-
-void test( char *buf )
-{
- int len = strlen( buf );
- forder_init( &fsm );
- forder_execute( &fsm, buf, len );
- if ( forder_finish( &fsm ) > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
-}
-
-int main()
-{
- test( "aaaaaabbbaa\n" );
- test( "\n" );
- test( "bbbbbbaaaaaaa\n" );
- test( "bbbbbbaaaaaa\n" );
- test( "aaaaa\n" );
-
- return 0;
-}
-
-##### OUTPUT #####
-enter m1 aa
-enter m2
-leave m1 aa
-through m1 b
-accept m1
-ACCEPT
-enter m2
-enter m2
-accept m2
-ACCEPT
-enter m1 aa
-enter m1 aa
-leave m1 aa
-through m1 b
-enter m2
-accept m1
-ACCEPT
-enter m1 aa
-enter m1 aa
-leave m1 aa
-through m1 b
-enter m2
-accept m1
-accept m2
-ACCEPT
-enter m1 aa
-enter m2
-FAIL
diff --git a/test/ragel.d/genrep1.rl b/test/ragel.d/genrep1.rl
deleted file mode 100644
index 69cc809a..00000000
--- a/test/ragel.d/genrep1.rl
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-#include <stdio.h>
-
-const char s[4096];
-
-struct nfa_stack
-{
- void *data;
- unsigned long sz;
-};
-
-struct nfa_bp_rec
-{
- long state;
- const char *p;
- long popTrans;
- long q_2;
-};
-
-%%{
- machine genrep;
- alphtype unsigned char;
-
- action psh
- {
- nfa_bp[nfa_len].q_2 = q_2;
- }
-
- action pop
- { ({
- q_2 = nfa_bp[nfa_len].q_2;
- 1;
- }) }
-
- action ini_2 {
- ({ q_2 = 0; 1; })
- }
-
- action stay_2 {
- ({ 1; })
- }
-
- action repeat_2 {
- ({ ++q_2 < 10; })
- }
-
- action exit_2 {
- ({ ++q_2 >= 10; })
- }
-
- main :=
- (
- 'h' 'e' 'l' 'l' 'o' ' '?
- (:nfa( ( ' ' ), psh, pop, ini_2, stay_2, repeat_2, exit_2):)
- 't' 'h' 'e' 'r' 'e'
- )
- :>
- any @{
- printf( "------ MATCH\n" );
- };
-
- write data;
-}%%
-
-int test( const char *p )
-{
- int len = strlen( p ) + 1;
- const char *pe = p + len;
- const char *eof = pe;
- int cs;
-
- struct nfa_bp_rec *nfa_bp = (struct nfa_bp_rec*) s;
- long nfa_len = 0;
- long nfa_count = 0;
-
- long q_2 = 0;
-
- printf( "testing: %s\n", p );
-
- %%{
- machine genrep;
- write init;
- write exec;
- }%%
-
- return 0;
-}
-
-int main()
-{
- test( "hello there" );
- test( "hello there" );
- test( "hello there" );
- test( "hello there" );
- return 0;
-}
-
-###### OUTPUT ######
-testing: hello there
-testing: hello there
------- MATCH
-testing: hello there
------- MATCH
-testing: hello there
diff --git a/test/ragel.d/genrep2.rl b/test/ragel.d/genrep2.rl
deleted file mode 100644
index e428ac51..00000000
--- a/test/ragel.d/genrep2.rl
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-#include <stdio.h>
-
-const char s[4096];
-
-struct nfa_stack
-{
- void *data;
- unsigned long sz;
-};
-
-struct nfa_bp_rec
-{
- long state;
- const char *p;
- long popTrans;
- long q_2;
-};
-
-%%{
- machine genrep;
- alphtype unsigned char;
-
- action eol { p+1 == eof }
- eol = '' %when eol;
-
- action psh
- {
- nfa_bp[nfa_len].q_2 = q_2;
- }
-
- action pop
- { ({
- q_2 = nfa_bp[nfa_len].q_2;
- 1;
- }) }
-
- action ini_2 {
- ({ q_2 = 0; 1; })
- }
-
- action stay_2 {
- ({ 1; })
- }
-
- action repeat_2 {
- ({ ++q_2 < 3; })
- }
-
- action exit_2 {
- ({ ++q_2 >= 2; })
- }
-
-
- main :=
- (
- ( :nfa( ( 'a' ) ,
- psh, pop, ini_2, stay_2, repeat_2, exit_2 ): ) {2}
- eol
- )
- :>
- any
- @{ printf( "------ MATCH\n" ); };
-
- write data;
-}%%
-
-int test( const char *p )
-{
- int len = strlen( p ) + 1;
- const char *pe = p + len;
- const char *eof = pe;
- int cs;
-
- struct nfa_bp_rec *nfa_bp = (struct nfa_bp_rec*) s;
- long nfa_len = 0;
- long nfa_count = 0;
-
- long q_2 = 0;
-
- printf( "testing: %s\n", p );
-
- %%{
- machine genrep;
- write init;
- write exec;
- }%%
-
- return 0;
-}
-
-int main()
-{
- test( "a" );
- test( "aa" );
- test( "aaa" );
- test( "aaaa" );
- test( "aaaaa" );
- test( "aaaaaa" );
- test( "aaaaaaa" );
- test( "aaaaaaaa" );
- return 0;
-}
-
-###### OUTPUT ######
-testing: a
-testing: aa
-testing: aaa
-testing: aaaa
------- MATCH
-testing: aaaaa
------- MATCH
-testing: aaaaaa
------- MATCH
-testing: aaaaaaa
-testing: aaaaaaaa
diff --git a/test/ragel.d/genrep3.rl b/test/ragel.d/genrep3.rl
deleted file mode 100644
index c3940e1e..00000000
--- a/test/ragel.d/genrep3.rl
+++ /dev/null
@@ -1,623 +0,0 @@
-#
-# @LANG: asm
-#
-
-%%{
-
- machine gen_rep;
-
- action eol {
- # p+1 == eof
-
- # Not the most efficient
- movq $0, %rax
- movq %r12, %rcx
- addq $1, %rcx
- movq -8(%rbp), %rdx
- cmpq %rcx, %rdx
- jne 1f
- movq $1, %rax
- 1:
- }
-
- eol = '' %when eol;
-
-
- action ini {
- # ini
- movl $0, c(%rip)
- movq $1, %rax
- }
-
- action stay {
- # stay
- movq $1, %rax
- }
-
- action repeat {
- # repeat
-
- movl c(%rip), %eax
- addl $1, %eax
- movl %eax, c(%rip)
-
- cmpl $3, %eax
- setl %al
- movzbl %al, %eax
- }
-
- action exit {
- # exit
-
- movl c(%rip), %eax
- addl $1, %eax
- movl %eax, c(%rip)
-
- cmpl $2, %eax
- setge %al
- movzbl %al, %eax
- }
-
- action psh
- {
- # PUSH
- movq nfa_s@GOTPCREL(%rip), %rax
- movq -88(%rbp), %rcx
- sal $3, %rcx
- movl c(%rip), %edx
- movq %rdx, 0(%rax,%rcx,)
-
- # movl $.L_push, %edi
- # call puts
- }
-
- action pop
- {
- # POP
- movq nfa_s@GOTPCREL(%rip), %rax
- movq -88(%rbp), %rcx
- sal $3, %rcx
- movq 0(%rax,%rcx,), %rdx
- movl %edx, c(%rip)
- movq $1, %rax
-
- # movl $.L_pop, %edi
- # call puts
- }
-
- action char
- {
- # movl $.L_char, %edi
- # movq c(%rip), %rsi
- # movl $0, %eax
- # call printf
- }
-
- action marker1
- {
- movl $.L_marker, %edi
- call puts
- movl m1(%rip), %eax
- }
-
- action marker2
- {
- movl m2(%rip), %eax
- }
-
-
- main :=
- (
- ( ( '' %when marker1 | '' %when marker2 )
- :nfa( ( 'a' @char ) ,
- psh, pop, ini, stay, repeat, exit ): ' ' ) {2}
- eol
- )
- :>
- any
- @{
- # printf("----- MATCH\n");
- movl $.L_match, %edi
- call puts
- }
- ;
-
-}%%
- .file "tmp.c"
- .comm neg,4,4
- .comm val,8,8
- .comm cs,4,4
- .comm c,4,4
- .comm m1,4,4
- .comm m2,4,4
- .section .rodata
-
-%% write data;
-
-.L_fmt_si_nl:
- .string "set top: %ld\n"
-.L_fmt_ci_nl:
- .string "check top: %ld\n"
-.L_fmt_s_nl:
- .string "restart: %d\n"
-.L_marker:
- .string " marker"
-.L_match:
- .string "----- MATCH"
-
-.L_break:
- .string "============"
-
-.L_push:
- .string "push"
-.L_pop:
- .string "pop"
-.L_char:
- .string "char %d\n"
-.L_ini:
- .string "ini"
-.L_min:
- .string "min %d\n"
-.L_max:
- .string "max"
-
- .text
- .globl init
- .type init, @function
-init:
-.LFB0:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- movq $0, val(%rip)
- movl $0, neg(%rip)
-
-%% write init;
-
- movq %r11, cs(%rip)
-
- popq %rbp
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE0:
- .size init, .-init
- .section .rodata
-.LC0:
- .string "%i"
- .text
- .globl exec
- .type exec, @function
-exec:
-.LFB1:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- subq $96, %rsp
-
- pushq %r12
- pushq %r13
-
- movq nfa_bp@GOTPCREL(%rip), %rax
- movq %rax, -80(%rbp)
- movq $0, -88(%rbp)
-
- movq cs(%rip), %r11
- movq %rdi, %r12
- movq %rsi, %r13
-
- movq %r13, -8(%rbp)
-
-%% write exec;
-
- movq %r11, cs(%rip)
-
- popq %r13
- popq %r12
-
-.LRET:
- leave
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE1:
- .size exec, .-exec
-
- .text
- .globl finish
- .type finish, @function
-finish:
-.LFB2:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
-
- popq %rbp
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE2:
- .size finish, .-finish
- .globl inp
-
- .section .rodata
-.LC10:
- .string "a "
-.LC11:
- .string "aa "
-.LC12:
- .string "aaa "
-.LC13:
- .string "aaaa "
-.LC14:
- .string "a a "
-.LC15:
- .string "aa aa "
-.LC16:
- .string "aaa aaa "
-.LC17:
- .string "aaaa aaaa "
-.LC18:
- .string "a a a "
-.LC19:
- .string "aa aa aa "
-.LC20:
- .string "aaa aaa aaa "
-.LC21:
- .string "aaaa aaaa aaaa "
-.LC22:
- .string "aa a "
-.LC23:
- .string "aa aaa "
-.LC24:
- .string "aa aaaa "
-.LC25:
- .string "aaa a "
-.LC26:
- .string "aaa aa "
-.LC27:
- .string "aaa aaaa "
-
- .data
- .align 32
- .type inp, @object
- .size inp, 72
-inp:
- .quad .LC10
- .quad .LC11
- .quad .LC12
- .quad .LC13
- .quad .LC14
- .quad .LC15
- .quad .LC16
- .quad .LC17
- .quad .LC18
- .quad .LC19
- .quad .LC20
- .quad .LC21
- .quad .LC22
- .quad .LC23
- .quad .LC24
- .quad .LC25
- .quad .LC26
- .quad .LC27
- .globl inplen
- .align 4
- .type inplen, @object
- .size inplen, 4
-inplen:
- .long 18
- .text
-
- .globl test_run
- .type test_run, @function
-test_run:
-.LFB3:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- subq $16, %rsp
- movl $0, -4(%rbp)
-
- movl $.L_break, %edi
- call puts
-
- jmp .L39
-.L40:
- movl $0, %eax
- call init
-
- movl -4(%rbp), %eax
- cltq
- movq inp(,%rax,8), %rax
- movq %rax, %rdi
- call puts
-
- movl -4(%rbp), %eax
- cltq
- movq inp(,%rax,8), %rax
- movq %rax, %rdi
- call strlen
- movl %eax, %edx
- addl $1, %edx
- movl -4(%rbp), %eax
- cltq
- movq inp(,%rax,8), %rax
- movslq %edx, %rsi
- addq %rax, %rsi
- movq %rax, %rdi
- call exec
- movl $0, %eax
- call finish
- addl $1, -4(%rbp)
-.L39:
- movl inplen(%rip), %eax
- cmpl %eax, -4(%rbp)
- jl .L40
- movl $0, %eax
- leave
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE3:
- .size test_run, .-test_run
-
-
- .globl main
- .type main, @function
-main:
-.LFB4:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- subq $16, %rsp
- movl $0, -4(%rbp)
-
- movl $0, m1(%rip)
- movl $0, m2(%rip)
- call test_run
-
- movl $1, m1(%rip)
- movl $0, m2(%rip)
- call test_run
-
- movl $0, m1(%rip)
- movl $1, m2(%rip)
- call test_run
-
- movl $1, m1(%rip)
- movl $1, m2(%rip)
- call test_run
-
- movl $0, %eax
- leave
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE4:
- .size main, .-main
-
- .bss
- .align 16
- .type nfa_len, @object
- .size nfa_len, 8
-nfa_len:
- .zero 8
- .comm nfa_bp,16384,32
- .comm nfa_s,16384,32
-
- .ident "GCC: (Ubuntu 4.8.2-19ubuntu1) 4.8.2"
- .section .note.GNU-stack,"",@progbits
-
-##### OUTPUT #####
-============
-a
- marker
-aa
- marker
-aaa
- marker
-aaaa
- marker
-a a
- marker
-aa aa
- marker
-aaa aaa
- marker
-aaaa aaaa
- marker
-a a a
- marker
-aa aa aa
- marker
-aaa aaa aaa
- marker
-aaaa aaaa aaaa
- marker
-aa a
- marker
-aa aaa
- marker
-aa aaaa
- marker
-aaa a
- marker
-aaa aa
- marker
-aaa aaaa
- marker
-============
-a
- marker
-aa
- marker
- marker
-aaa
- marker
- marker
-aaaa
- marker
-a a
- marker
-aa aa
- marker
- marker
------ MATCH
-aaa aaa
- marker
- marker
------ MATCH
-aaaa aaaa
- marker
-a a a
- marker
-aa aa aa
- marker
- marker
-aaa aaa aaa
- marker
- marker
-aaaa aaaa aaaa
- marker
-aa a
- marker
- marker
-aa aaa
- marker
- marker
------ MATCH
-aa aaaa
- marker
- marker
-aaa a
- marker
- marker
-aaa aa
- marker
- marker
------ MATCH
-aaa aaaa
- marker
- marker
-============
-a
- marker
-aa
- marker
- marker
-aaa
- marker
- marker
-aaaa
- marker
-a a
- marker
-aa aa
- marker
- marker
------ MATCH
-aaa aaa
- marker
- marker
------ MATCH
-aaaa aaaa
- marker
-a a a
- marker
-aa aa aa
- marker
- marker
-aaa aaa aaa
- marker
- marker
-aaaa aaaa aaaa
- marker
-aa a
- marker
- marker
-aa aaa
- marker
- marker
------ MATCH
-aa aaaa
- marker
- marker
-aaa a
- marker
- marker
-aaa aa
- marker
- marker
------ MATCH
-aaa aaaa
- marker
- marker
-============
-a
- marker
-aa
- marker
- marker
-aaa
- marker
- marker
-aaaa
- marker
-a a
- marker
-aa aa
- marker
- marker
------ MATCH
-aaa aaa
- marker
- marker
------ MATCH
-aaaa aaaa
- marker
-a a a
- marker
-aa aa aa
- marker
- marker
-aaa aaa aaa
- marker
- marker
-aaaa aaaa aaaa
- marker
-aa a
- marker
- marker
-aa aaa
- marker
- marker
------ MATCH
-aa aaaa
- marker
- marker
-aaa a
- marker
- marker
-aaa aa
- marker
- marker
------ MATCH
-aaa aaaa
- marker
- marker
diff --git a/test/ragel.d/genrep4.rl b/test/ragel.d/genrep4.rl
deleted file mode 100644
index 861de34f..00000000
--- a/test/ragel.d/genrep4.rl
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stddef.h> /* NULL */
-#include <stdint.h> /* uint64_t */
-#include <stdlib.h> /* malloc(3) free(3) */
-#include <stdbool.h> /* bool */
-#include <string.h>
-#include <stdio.h>
-
-struct nfa_bp_rec
-{
- long state;
- const unsigned char *p;
- int popTrans;
- long q_2;
-};
-
-struct nfa_bp_rec nfa_bp[1024];
-long nfa_len = 0;
-long nfa_count = 0;
-
-long c;
-
-struct nfa_state_rec
-{
- long c;
-};
-
-struct nfa_state_rec nfa_s[1024];
-
-void nfa_push()
-{
- nfa_s[nfa_len].c = c;
-}
-
-void nfa_pop()
-{
- c = nfa_s[nfa_len].c;
-}
-
-long q_2;
-
-%%{
- machine match_any;
- alphtype unsigned char;
-
- action eol { p+1 == eof }
-
- eol = '' %when eol;
-
- action psh
- {
- nfa_bp[nfa_len].q_2 = q_2;
- }
-
- action pop
- { ({
- q_2 = nfa_bp[nfa_len].q_2;
- 1;
- }) }
-
- action ini {
- ({ q_2 = 0; 1; })
- }
-
- action stay {
- ({ 1; })
- }
-
- action repeat {
- ({ ++q_2 < 3; })
- }
-
- action exit {
- ({ ++q_2 >= 2; })
- }
-
- action marker
- { ({printf(" marker\n");1;}) }
-
- main :=
- ( '' %when(marker)
- :nfa( ( 'a' ), psh, pop, ini, stay, repeat, exit ): ' ' ) {2}
- eol
- any @{printf("----- MATCH\n");}
- ;
-
- write data;
-}%%
-
-int test( const char *data )
-{
- int cs;
- const unsigned char *p = (const unsigned char *)data;
- const unsigned char *pe = p + strlen(data) + 1;
- const unsigned char *eof = pe;
-
- printf( "%s\n", data );
-
- %% write init;
- %% write exec;
-
- return 0;
-}
-
-int main()
-{
- test( "a " );
- test( "aa " );
- test( "aaa " );
- test( "aaaa " );
-
- test( "a a " );
- test( "aa aa " );
- test( "aaa aaa " );
- test( "aaaa aaaa " );
-
- test( "a a a " );
- test( "aa aa aa " );
- test( "aaa aaa aaa " );
- test( "aaaa aaaa aaaa " );
-
- test( "aa a " );
- test( "aa aaa " );
- test( "aa aaaa " );
-
- test( "aaa a " );
- test( "aaa aa " );
- test( "aaa aaaa " );
-
- return 0;
-}
-
-##### OUTPUT #####
-a
- marker
-aa
- marker
- marker
-aaa
- marker
- marker
-aaaa
- marker
-a a
- marker
-aa aa
- marker
- marker
------ MATCH
-aaa aaa
- marker
- marker
------ MATCH
-aaaa aaaa
- marker
-a a a
- marker
-aa aa aa
- marker
- marker
-aaa aaa aaa
- marker
- marker
-aaaa aaaa aaaa
- marker
-aa a
- marker
- marker
-aa aaa
- marker
- marker
------ MATCH
-aa aaaa
- marker
- marker
-aaa a
- marker
- marker
-aaa aa
- marker
- marker
------ MATCH
-aaa aaaa
- marker
- marker
diff --git a/test/ragel.d/genrep5.rl b/test/ragel.d/genrep5.rl
deleted file mode 100644
index ebaf7e70..00000000
--- a/test/ragel.d/genrep5.rl
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-#include <stdio.h>
-
-const char s[4096];
-
-struct nfa_stack
-{
- void *data;
- unsigned long sz;
-};
-
-struct nfa_bp_rec
-{
- long state;
- const char *p;
- long popTrans;
- long q_2;
-};
-
-%%{
- machine genrep;
- alphtype unsigned char;
-
- action psh
- {
- nfa_bp[nfa_len].q_2 = q_2;
- }
-
- action pop
- { ({
- q_2 = nfa_bp[nfa_len].q_2;
- 1;
- }) }
-
- action ini_2 {
- ({ q_2 = 0; 1; })
- }
-
- action stay_2 {
- ({ 1; })
- }
-
- action repeat_2 {
- ({ ++q_2 < 2; })
- }
-
- action exit_2 {
- ({ ++q_2 >= 2; })
- }
-
- action leaving
- {
- printf( " -> leaving\n" );
- }
-
- main :=
- (
- 'hello' %leaving
- (:nfa( ( ' ' ), psh, pop, ini_2, stay_2, repeat_2, exit_2):)
- 'there'
- )
- :>
- any @{
- printf( "------ MATCH\n" );
- };
-
- write data;
-}%%
-
-int test( const char *p )
-{
- int len = strlen( p ) + 1;
- const char *pe = p + len;
- const char *eof = pe;
- int cs;
-
- struct nfa_bp_rec *nfa_bp = (struct nfa_bp_rec*) s;
- long nfa_len = 0;
- long nfa_count = 0;
-
- long q_2 = 0;
-
- printf( "testing: %s\n", p );
-
- %%{
- machine genrep;
- write init;
- write exec;
- }%%
-
- return 0;
-}
-
-int main()
-{
- test( "hellothere" );
- test( "hello there" );
- test( "hello there" );
- test( "hello there" );
- test( "hello there" );
- return 0;
-}
-
-########## OUTPUT ##########
-testing: hellothere
- -> leaving
-testing: hello there
- -> leaving
-testing: hello there
- -> leaving
------- MATCH
-testing: hello there
- -> leaving
-testing: hello there
- -> leaving
diff --git a/test/ragel.d/genrep6.rl b/test/ragel.d/genrep6.rl
deleted file mode 100644
index 26515b93..00000000
--- a/test/ragel.d/genrep6.rl
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-#include <stdio.h>
-
-const char s[4096];
-
-struct nfa_stack
-{
- void *data;
- unsigned long sz;
-};
-
-struct nfa_bp_rec
-{
- long state;
- const char *p;
- long popTrans;
- long q_2;
-};
-
-%%{
- machine genrep;
- alphtype unsigned char;
-
- action psh
- {
- nfa_bp[nfa_len].q_2 = q_2;
- }
-
- action pop
- { ({
- q_2 = nfa_bp[nfa_len].q_2;
- 1;
- }) }
-
- action ini_2 {
- ({ q_2 = 0; 1; })
- }
-
- action stay_2 {
- ({ 1; })
- }
-
- action repeat_2 {
- ({ ++q_2 < 1; })
- }
-
- action exit_2 {
- ({ ++q_2 >= 1; })
- }
-
- action leaving
- {
- printf( " -> leaving\n" );
- }
-
- action c1 { ({ printf( " -> c1\n"); c1; }) }
- action c2 { ({ printf( " -> c2\n"); c2; }) }
-
- main :=
- (
- (
- 'hello' %when c1 |
- 'hello' %when c2
- )
-
- :nfa( ( ' ' ), psh, pop, ini_2, stay_2, repeat_2, exit_2 ):
-
- 'there'
- )
- :>
- any @{
- printf( "------ MATCH\n" );
- };
-
- write data;
-}%%
-
-int test( int c1, int c2, const char *p )
-{
- int len = strlen( p ) + 1;
- const char *pe = p + len;
- const char *eof = pe;
- int cs;
-
- struct nfa_bp_rec *nfa_bp = (struct nfa_bp_rec*) s;
- long nfa_len = 0;
- long nfa_count = 0;
- long q_2 = 0;
-
- printf( "testing: %s\n", p );
-
- %%{
- machine genrep;
- write init;
- write exec;
- }%%
-
- return 0;
-}
-
-int main()
-{
- test( 0, 0, "hellothere" );
- test( 0, 0, "hello there" );
- test( 0, 0, "hello there" );
-
- printf( "------------\n" );
-
- test( 0, 1, "hellothere" );
- test( 0, 1, "hello there" );
- test( 0, 1, "hello there" );
-
- printf( "------------\n" );
-
- test( 1, 0, "hellothere" );
- test( 1, 0, "hello there" );
- test( 1, 0, "hello there" );
-
- printf( "------------\n" );
-
- test( 1, 1, "hellothere" );
- test( 1, 1, "hello there" );
- test( 1, 1, "hello there" );
-
- return 0;
-}
-
-########## OUTPUT ##########
-testing: hellothere
- -> c1
- -> c2
-testing: hello there
- -> c1
- -> c2
-testing: hello there
- -> c1
- -> c2
-------------
-testing: hellothere
- -> c1
- -> c2
-testing: hello there
- -> c1
- -> c2
------- MATCH
-testing: hello there
- -> c1
- -> c2
-------------
-testing: hellothere
- -> c1
- -> c2
-testing: hello there
- -> c1
- -> c2
------- MATCH
-testing: hello there
- -> c1
- -> c2
-------------
-testing: hellothere
- -> c1
- -> c2
-testing: hello there
- -> c1
- -> c2
------- MATCH
-testing: hello there
- -> c1
- -> c2
diff --git a/test/ragel.d/genrep7.rl b/test/ragel.d/genrep7.rl
deleted file mode 100644
index a535e201..00000000
--- a/test/ragel.d/genrep7.rl
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-#include <stdio.h>
-
-const char s[4096];
-
-struct nfa_stack
-{
- void *data;
- unsigned long sz;
-};
-
-struct nfa_bp_rec
-{
- long state;
- const char *p;
- long popTrans;
- long q_2;
-};
-
-%%{
- machine genrep;
- alphtype unsigned char;
-
- action eol { p+1 == eof }
- eol = '' %when eol;
-
- action psh
- {
- nfa_bp[nfa_len].q_2 = q_2;
- }
-
- action pop
- { ({
- q_2 = nfa_bp[nfa_len].q_2;
- 1;
- }) }
-
- action ini_2 {
- ({ q_2 = 0; 1; })
- }
-
- action stay_2 {
- ({ 1; })
- }
-
- action repeat_2 {
- ({ ++q_2 < 3; })
- }
-
- action exit_2 {
- ({ ++q_2 >= 2; })
- }
-
-
- # This one should print mulitple matches because it should finish in a
- # non-final state, triggering NFA pop.
- main :=
- ( :nfa( ( 'a' ) , psh, pop, ini_2, stay_2, repeat_2, exit_2 ): ) {2}
- '|x' >{ printf( "------ MATCH\n" ); };
-
- write data;
-}%%
-
-int test( const char *p )
-{
- int len = strlen( p );
- const char *pe = p + len;
- const char *eof = pe;
- int cs;
-
- struct nfa_bp_rec *nfa_bp = (struct nfa_bp_rec*) s;
- long nfa_len = 0;
- long nfa_count = 0;
-
- long q_2 = 0;
-
- printf( "testing: %s\n", p );
-
- %%{
- machine genrep;
- write init;
- write exec;
- }%%
-
- return 0;
-}
-
-int main()
-{
- test( "a|" );
- test( "aa|" );
- test( "aaa|" );
- test( "aaaa|" );
- test( "aaaaa|" );
- test( "aaaaaa|" );
- test( "aaaaaaa|" );
- test( "aaaaaaaa|" );
- return 0;
-}
-
-###### OUTPUT ######
-testing: a|
-testing: aa|
-testing: aaa|
-testing: aaaa|
------- MATCH
-testing: aaaaa|
------- MATCH
------- MATCH
-testing: aaaaaa|
------- MATCH
-testing: aaaaaaa|
-testing: aaaaaaaa|
diff --git a/test/ragel.d/genrep8.rl b/test/ragel.d/genrep8.rl
deleted file mode 100644
index 1e800e85..00000000
--- a/test/ragel.d/genrep8.rl
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * The var backend version genrep7 for checking NFA pop on non-final.
- * @LANG: cv
- */
-
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-#include <stdio.h>
-
-const char s[4096];
-
-struct nfa_stack
-{
- void *data;
- unsigned long sz;
-};
-
-struct nfa_bp_rec
-{
- long state;
- const char *p;
- long popTrans;
- long q_2;
-};
-
-%%{
- machine genrep;
- alphtype unsigned char;
-
- action eol { p+1 == eof }
- eol = '' %when eol;
-
- action psh
- {
- nfa_bp[nfa_len].q_2 = q_2;
- }
-
- action pop
- { ({
- q_2 = nfa_bp[nfa_len].q_2;
- 1;
- }) }
-
- action ini_2 {
- ({ q_2 = 0; 1; })
- }
-
- action stay_2 {
- ({ 1; })
- }
-
- action repeat_2 {
- ({ ++q_2 < 3; })
- }
-
- action exit_2 {
- ({ ++q_2 >= 2; })
- }
-
- # This one should print mulitple matches because it should finish in a
- # non-final state, triggering NFA pop.
- main :=
- ( :nfa( ( 'a' ) , psh, pop, ini_2, stay_2, repeat_2, exit_2 ): ) {2}
- '|x' >{ printf( "------ MATCH\n" ); };
-
- write data;
-}%%
-
-int test( const char *p )
-{
- int len = strlen( p );
- const char *pe = p + len;
- const char *eof = pe;
- int cs;
-
- struct nfa_bp_rec *nfa_bp = (struct nfa_bp_rec*) s;
- long nfa_len = 0;
- long nfa_count = 0;
-
- long q_2 = 0;
-
- printf( "testing: %s\n", p );
-
- %%{
- machine genrep;
- write init;
- write exec;
- }%%
-
- return 0;
-}
-
-int main()
-{
- test( "a|" );
- test( "aa|" );
- test( "aaa|" );
- test( "aaaa|" );
- test( "aaaaa|" );
- test( "aaaaaa|" );
- test( "aaaaaaa|" );
- test( "aaaaaaaa|" );
- return 0;
-}
-
-###### OUTPUT ######
-testing: a|
-testing: aa|
-testing: aaa|
-testing: aaaa|
------- MATCH
-testing: aaaaa|
------- MATCH
------- MATCH
-testing: aaaaaa|
------- MATCH
-testing: aaaaaaa|
-testing: aaaaaaaa|
diff --git a/test/ragel.d/gentests.sh b/test/ragel.d/gentests.sh
deleted file mode 100644
index ac3eef2a..00000000
--- a/test/ragel.d/gentests.sh
+++ /dev/null
@@ -1,506 +0,0 @@
-#!/bin/bash
-
-#
-# Test Case Features
-# ------------------
-# If the test case has a directory by the same name, copy it into the
-# working direcotory.
-#
-# @RAGEL_FILE: file name to pass on the command line instead of file created
-# by extracting section. Does not work with translated test cases.
-#
-
-TRANS=./trans
-
-# Make available to to test directories below us that are not part of this
-# repository and cannot source one dir up.
-export RAGEL_BIN="@SUBJ_RAGEL_BIN@"
-export RAGEL_CPPFLAGS="@SUBJ_RAGEL_CPPFLAGS@"
-export RAGEL_LDFLAGS="@SUBJ_RAGEL_LDFLAGS@"
-
-export RAGEL_C_BIN="@SUBJ_RAGEL_C_BIN@"
-export RAGEL_D_BIN="@SUBJ_RAGEL_D_BIN@"
-export RAGEL_JAVA_BIN="@SUBJ_RAGEL_JAVA_BIN@"
-export RAGEL_RUBY_BIN="@SUBJ_RAGEL_RUBY_BIN@"
-export RAGEL_CSHARP_BIN="@SUBJ_RAGEL_CSHARP_BIN@"
-export RAGEL_GO_BIN="@SUBJ_RAGEL_GO_BIN@"
-export RAGEL_OCAML_BIN="@SUBJ_RAGEL_OCAML_BIN@"
-export RAGEL_ASM_BIN="@SUBJ_RAGEL_ASM_BIN@"
-export RAGEL_RUST_BIN="@SUBJ_RAGEL_RUST_BIN@"
-export RAGEL_CRACK_BIN="@SUBJ_RAGEL_CRACK_BIN@"
-export RAGEL_JULIA_BIN="@SUBJ_RAGEL_JULIA_BIN@"
-
-function sig_exit()
-{
- echo
- exit 1;
-}
-
-trap sig_exit SIGINT
-trap sig_exit SIGQUIT
-trap sig_exit SIGTERM
-
-wk=working
-test -d $wk || mkdir $wk
-echo $wk/* | xargs rm -Rf
-
-while getopts "gcnmleT:F:W:G:P:CDJRAZOUKY-:" opt; do
- case $opt in
- T|F|W|G|P)
- genflags="$genflags -$opt$OPTARG"
- gen_opts="$gen_opts -$opt$OPTARG"
- ;;
- n|m|l|e)
- genflags="$genflags -$opt"
- gen_opts="$gen_opts -$opt"
- ;;
- c)
- compile_only="true"
- gen_opts="$gen_opts -$opt"
- ;;
- g)
- allow_generated="true"
- ;;
- C|D|J|R|A|Z|O|R|K|Y|U)
- langflags="$langflags -$opt"
- ;;
- -)
- case $OPTARG in
- asm)
- langflags="$langflags --$OPTARG"
- gen_opts="$gen_opts --$OPTARG"
- ;;
- integral-tables|string-tables)
- genflags="$genflags --$OPTARG"
- gen_opts="$gen_opts --$OPTARG"
- ;;
- *)
- echo "$0: unrecognized option --$OPTARG" >&2
- exit 1
- ;;
- esac
- ;;
- ?)
- exit 1;
- ;;
- esac
-done
-
-[ -z "$langflags" ] && langflags="-C --asm -R -Y -O -U -J -Z -D -A -K"
-[ -z "$genflags" ] && genflags="-T0 -T1 -F0 -F1 -W0 -W1 -G0 -G1 -G2 -n -m -e --string-tables"
-
-shift $((OPTIND - 1));
-
-[ -z "$*" ] && set -- *.rl
-
-ragel="@RAGEL_BIN@"
-
-cxx_compiler="@CXX@"
-c_compiler="@CC@"
-objc_compiler="@CC@"
-d_compiler="@D_BIN@"
-java_compiler="@JAVAC_BIN@"
-ruby_engine="@RUBY_BIN@"
-csharp_compiler="@CSHARP_BIN@"
-go_compiler="@GO_BIN@"
-ocaml_compiler="@OCAML_BIN@"
-rust_compiler="@RUST_BIN@"
-crack_interpreter="@CRACK_BIN@"
-julia_interpreter="@JULIA_BIN@"
-gnustep_config="@GNUSTEP_CONFIG@"
-assembler="@ASM_BIN@"
-
-if [ -z "$gnustep_config" ]; then
- objc_compiler=""
-fi
-
-function test_error
-{
- exit 1;
-}
-
-function exec_cmd()
-{
- lang=$1
-
- case $lang in
- java) exec_cmd="java -classpath $wk $classname" ;;
- ruby) exec_cmd="ruby $code_src" ;;
- csharp) exec_cmd="mono $binary" ;;
- ocaml) exec_cmd="ocaml $code_src" ;;
- crack) exec_cmd="$crack_interpreter $code_src" ;;
- julia) exec_cmd="$julia_interpreter $code_src" ;;
- indep) echo "error: exec_cmd: indep not executable"; exit 1 ;;
- *) exec_cmd=./$binary ;;
- esac
-}
-
-
-function lang_opts()
-{
- lang=$1
-
- case $lang in
- c)
- lang_opt=-C;
- code_suffix=c;
- interpreted=false
- compiler=$c_compiler;
- host_ragel=$RAGEL_BIN
- flags="-Wall -O3 -I. -Wno-variadic-macros"
- libs=""
- prohibit_flags=""
- ;;
- cg)
- # For testing ragel-c using goto based.
- lang_opt=-C;
- code_suffix=c;
- interpreted=false
- compiler=$c_compiler;
- host_ragel=$RAGEL_C_BIN
- flags="-Wall -O3 -I. -Wno-variadic-macros"
- libs=""
- prohibit_flags="--string-tables"
- ;;
- cv)
- # For testing ragel-c using var-based
- lang_opt=-C;
- code_suffix=c;
- interpreted=false
- compiler=$c_compiler;
- host_ragel="$RAGEL_C_BIN --var-backend"
- flags="-Wall -O3 -I. -Wno-variadic-macros"
- libs=""
- prohibit_flags="-G0 -G1 -G2 --string-tables"
- ;;
- c++)
- lang_opt=-C;
- code_suffix=cpp;
- interpreted=false
- compiler=$cxx_compiler;
- host_ragel=$RAGEL_BIN
- flags="-Wall -O3 -I. -Wno-variadic-macros"
- libs=""
- prohibit_flags=""
- ;;
- obj-c)
- lang_opt=-C;
- code_suffix=m;
- interpreted=false
- compiler=$objc_compiler
- host_ragel=$RAGEL_BIN
- if [ -z "$gnustep_config" ]; then
- flags=""
- else
- flags="`$gnustep_config --objc-flags`"
- fi
- libs="-lobjc -lgnustep-base"
- prohibit_flags=""
- ;;
- d)
- lang_opt=-D;
- code_suffix=d;
- interpreted=false
- compiler=$d_compiler;
- host_ragel=$RAGEL_D_BIN
- flags="-Wall -O3"
- libs=""
- prohibit_flags="--string-tables"
- ;;
- java)
- lang_opt=-J;
- code_suffix=java;
- interpreted=false
- compiler=$java_compiler
- host_ragel=$RAGEL_JAVA_BIN
- flags=""
- libs=""
- prohibit_flags="-G0 -G1 -G2 --string-tables"
- ;;
- ruby)
- lang_opt=-R;
- code_suffix=rb;
- interpreted=true
- compiler=$ruby_engine
- host_ragel=$RAGEL_RUBY_BIN
- flags=""
- libs=""
- prohibit_flags="-G0 -G1 -G2 --string-tables"
- ;;
- csharp)
- lang_opt="-A";
- code_suffix=cs;
- interpreted=false
- compiler=$csharp_compiler
- host_ragel=$RAGEL_CSHARP_BIN
- flags=""
- libs=""
- prohibit_flags="-G2 --string-tables"
- ;;
- go)
- lang_opt="-Z"
- code_suffix=go
- interpreted=false
- compiler=$go_compiler
- host_ragel=$RAGEL_GO_BIN
- flags="build"
- libs=""
- prohibit_flags="--string-tables"
- ;;
- ocaml)
- lang_opt="-O"
- code_suffix=ml
- interpreted=true
- compiler=$ocaml_compiler
- host_ragel=$RAGEL_OCAML_BIN
- flags=""
- libs=""
- prohibit_flags="-G0 -G1 -G2 --string-tables"
- ;;
- asm)
- lang_opt="--asm"
- code_suffix=s
- interpreted=false
- compiler="$assembler"
- host_ragel=$RAGEL_ASM_BIN
- flags=""
- libs=""
- prohibit_flags="-T0 -T1 -F0 -F1 -W0 -W1 -G0 -G1 --string-tables"
- ;;
- rust)
- lang_opt="-U"
- code_suffix=rs
- interpreted=false
- compiler=$rust_compiler
- host_ragel=$RAGEL_RUST_BIN
- flags="-A non_upper_case_globals -A dead_code \
- -A unused_variables -A unused_assignments -A unused_mut -A unused_parens"
- libs=""
- prohibit_flags="-G0 -G1 -G2 --string-tables"
- ;;
- crack)
- lang_opt="-K"
- code_suffix=crk
- interpreted=true
- compiler=$crack_interpreter
- host_ragel=$RAGEL_CRACK_BIN
- prohibit_flags="-G0 -G1 -G2 --string-tables"
- ;;
- julia)
- lang_opt="-Y"
- code_suffix=jl
- interpreted=true
- compiler=$julia_interpreter
- host_ragel=$RAGEL_JULIA_BIN
- prohibit_flags="-G0 -G1 -G2 --string-tables"
- ;;
- indep)
- ;;
- *)
- echo "$translated: unknown language type '$lang'" >&2
- exit 1;
- ;;
- esac
-
- prohibit_flags="$prohibit_flags $case_prohibit_flags"
-}
-
-function run_test()
-{
- code_src=$wk/`echo $lroot$gen_opt.$code_suffix | sed 's/-\+/_/g'`
- binary=$wk/`echo $lroot$gen_opt.bin | sed 's/-\+/_/g'`
- output=$wk/`echo $lroot$gen_opt.out | sed 's/-\+/_/g'`
- diff=$wk/`echo $lroot$gen_opt.diff | sed 's/-\+/_/g'`
- sh=$wk/`echo $lroot$gen_opt.sh | sed 's/-\+/_/g'`
- log=$wk/`echo $lroot$gen_opt.log | sed 's/-\+/_/g'`
- intermed=$wk/`echo $lroot$gen_opt.ri | sed 's/-\+/_/g'`
- classfile=$wk/`echo $lroot$gen_opt.class | sed 's/-\+/_/g'`
- classname=`echo $lroot$gen_opt | sed 's/-\+/_/g'`
-
- opts="$gen_opt $min_opt $enc_opt $f_opt"
- args="-I. $opts -o $code_src $translated"
-
- cat >> $sh <<-EOF
- echo testing $lroot $opts
- $host_ragel $args
- EOF
-
- if [ $lang == java ]; then
- cat >> $sh <<-EOF
- sed -i 's/\<$lroot\>/$classname/g' $code_src
- EOF
- fi
-
- out_args=""
- [ $lang != java ] && out_args="-o $binary";
- [ $lang == csharp ] && out_args="-out:$binary";
-
- # Some langs are just interpreted.
- if [ $interpreted != "true" ]; then
- cat >> $sh <<-EOF
- $compiler $flags $out_args $code_src \
- $libs >>$log 2>>$log
- EOF
- fi
-
- exec_cmd $lang
- if [ "$compile_only" != "true" ]; then
- if [ -n "$FILTER" ]; then
- exec_cmd="$exec_cmd | $FILTER"
- fi
-
- cat >> $sh <<-EOF
- $exec_cmd 2>> $log >> $output
- EOF
-
- cat >> $sh <<-EOF
- diff -u --strip-trailing-cr $expected_out $output > $diff
- # rm -f $intermed $code_src $binary $classfile $output
- EOF
-
- fi
-
- echo $sh
-}
-
-
-function run_options()
-{
- translated=$1
-
- lroot=`basename $translated`
- lroot=${lroot%.rl};
-
- lang_opts $lang
-
- [ -n "$additional_cflags" ] && flags="$flags $additional_cflags"
-
- # If we have no compiler for the source program then skip it.
- [ -z "$compiler" ] && return
-
- # Make sure that we are interested in the host language.
- echo "$langflags" | grep -qe $lang_opt || return
-
- for gen_opt in $genflags; do
- echo "" "$prohibit_flags" | \
- grep -e $gen_opt >/dev/null && continue
-
- run_test
- done
- unset gen_opt
-}
-
-function run_translate()
-{
- test_case=$1
-
- # Recompute the root.
- root=`basename $test_case`
- root=${root%.rl};
-
- # Check if we should ignore the test case
- enabled=`sed '/@ENABLED:/s/^.*: *//p;d' $test_case`
- if [ -n "$enabled" ] || [ "$enabled" = true ]; then
- return;
- fi
-
- # If the generated flag is given make sure that the test case is generated.
- is_generated=`sed '/@GENERATED:/s/^.*: *//p;d' $test_case`
- if [ "$is_generated" = true ] && [ "$allow_generated" != true ]; then
- return;
- fi
-
- # Override the test case file name.
- RAGEL_FILE=`sed '/@RAGEL_FILE:/s/^.*: *//p;d' $test_case`
-
- # Filter to pass output through. Shell code.
- FILTER=`sed '/@FILTER:/s/^.*: *//p;d' $test_case`
-
- # If the test case has a directory by the same name, copy it into the
- # working direcotory.
- if [ -d $root ]; then
- cp -a $root $wk/
- fi
-
- expected_out=$wk/$root.exp;
- case_rl=${root}.rl
-
- sed '1,/^##* * OUTPUT ##*/d' $test_case > $expected_out
-
- prohibit_languages=`sed '/@PROHIBIT_LANGUAGES:/s/^.*: *//p;d' $test_case`
-
- # Add these into the langugage-specific defaults selected in run_options
- case_prohibit_flags=`sed '/@PROHIBIT_FLAGS:/s/^.*: *//p;d' $test_case`
-
- lang=`sed '/@LANG:/s/^.*: *//p;d' $test_case`
- if [ -z "$lang" ]; then
- echo "$test_case: language unset"; >&2
- return
- fi
-
- cases=""
-
- if [ $lang == indep ]; then
- for lang in c cg cv asm d csharp go java ruby ocaml rust crack julia; do
- case $lang in
- c) lf="-C" ;;
- cg) lf="-C" ;;
- cv) lf="-C" ;;
- asm) lf="--asm" ;;
- d) lf="-D" ;;
- csharp) lf="-A" ;;
- go) lf="-Z" ;;
- java) lf="-J" ;;
- ruby) lf="-R" ;;
- ocaml) lf="-O" ;;
- rust) lf="-U" ;;
- crack) lf="-K" ;;
- julia) lf="-Y" ;;
- esac
-
- echo "$prohibit_languages" | grep -q "\<$lang\>" && continue;
- echo "$langflags" | grep -qe $lf || continue
-
- # Translate to target language and strip off output.
- targ=${root}_$lang.rl
-
- $TRANS $lang $wk/$targ $test_case ${root}_${lang}
-
- cases="$cases $wk/$targ"
-
- run_options $wk/$targ
- done
- else
-
- sed '/^##* * OUTPUT ##*/,$d' $test_case > $wk/$case_rl
-
- cases=$wk/$case_rl
-
- if [ -n "$RAGEL_FILE" ]; then
- cases="$RAGEL_FILE"
- fi
-
- run_options $cases
- fi
-}
-
-go()
-{
- # Before we generate and test cases verify that all files exist. It is nice
- # to catch this early.
- for test_case; do
- if ! [ -f $test_case ]; then
- echo "$test_case: could not find file" >&2
- missing_file=true
-
- fi
- done
-
- [ "$missing_file" = true ] && exit 1;
-
- for test_case; do
- run_translate $test_case
- done
-}
-
-go "$@"
diff --git a/test/ragel.d/goto1.rl b/test/ragel.d/goto1.rl
deleted file mode 100644
index 0bf121f4..00000000
--- a/test/ragel.d/goto1.rl
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * @LANG: indep
- * @PROHIBIT_LANGUAGES: cv ruby ocaml rust crack
- */
-
-int target;
-
-%%{
- machine goto1;
-
- unused := 'unused';
-
- one := 'one' @{
- print_str "one\n";
- target = fentry(main);
- fgoto *target;
- };
-
- two := 'two' @{
- print_str "two\n";
- target = fentry(main);
- fgoto *target;
- };
-
- main :=
- '1' @{ target = fentry(one); fgoto *target; }
- | '2' @{ target = fentry(two); fgoto *target; }
- | '\n';
-}%%
-
-##### INPUT #####
-"1one2two1one\n"
-##### OUTPUT #####
-one
-two
-one
-ACCEPT
diff --git a/test/ragel.d/gotocallret1.rl b/test/ragel.d/gotocallret1.rl
deleted file mode 100644
index 92ebb983..00000000
--- a/test/ragel.d/gotocallret1.rl
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * @LANG: indep
- * @PROHIBIT_LANGUAGES: cv ruby ocaml rust crack
- * @PROHIBIT_FLAGS: --var-backend
- * @NEEDS_EOF: yes
- */
-
-/*
- * Demonstrate the use of goto, call and return. This machine expects either a
- * lower case char or a digit as a command then a space followed by the command
- * arg. If the command is a char, then the arg must be an a string of chars.
- * If the command is a digit, then the arg must be a string of digits. This
- * choice is determined by action code, rather than though transition
- * desitinations.
- */
-
-char comm;
-int top;
-int stack[32];
-
-%%{
- machine GotoCallRet;
-
- # A reference to a state in an unused action caused a segfault in 5.8. */
- action unusedAction { fentry(garble_line); }
-
- action err_garbling_line { print_str "error: garbling line\n"; }
- action goto_main { fgoto main; }
- action recovery_failed { print_str "error: failed to recover\n"; }
-
- # Error machine, consumes to end of
- # line, then starts the main line over.
- garble_line := ( (any-'\n')*'\n')
- >err_garbling_line
- @goto_main
- $/recovery_failed;
-
- action hold_and_return {fhold; fret;}
-
- # Look for a string of alphas or of digits,
- # on anything else, hold the character and return.
- alp_comm := alpha+ $!hold_and_return;
- dig_comm := digit+ $!hold_and_return;
-
- # Choose which to machine to call into based on the command.
- action comm_arg {
- if ( comm >= 97 ) {
- fcall alp_comm;
- } else {
- fcall dig_comm;
- }
- }
-
- # Specifies command string. Note that the arg is left out.
- command = (
- [a-z0-9] @{comm = fc;} ' ' @comm_arg '\n'
- ) @{print_str "correct command\n";};
-
- # Any number of commands. If there is an
- # error anywhere, garble the line.
- main := command* $!{fhold;fgoto garble_line;};
-}%%
-
-##### INPUT #####
-"lkajsdf\n"
-"2134\n"
-"(\n"
-"\n"
-"*234234()0909 092 -234aslkf09`1 11\n"
-"1\n"
-"909\n"
-"1 a\n"
-"11 1\n"
-"a 1\n"
-"aa a\n"
-"1 1\n"
-"1 123456\n"
-"a a\n"
-"a abcdef\n"
-"h"
-"a aa1"
-##### OUTPUT #####
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-correct command
-ACCEPT
-correct command
-ACCEPT
-correct command
-ACCEPT
-correct command
-ACCEPT
-error: failed to recover
-FAIL
-error: garbling line
-error: failed to recover
-FAIL
diff --git a/test/ragel.d/gotocallret2.rl b/test/ragel.d/gotocallret2.rl
deleted file mode 100644
index 7d4c6c50..00000000
--- a/test/ragel.d/gotocallret2.rl
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * @LANG: indep
- * @NEEDS_EOF: yes
- * @PROHIBIT_LANGUAGES: cv ruby ocaml rust crack
- * @PROHIBIT_FLAGS: --var-backend
- */
-
-char comm;
-int top;
-int stack[32];
-ptr ts;
-ptr te;
-int act;
-int val;
-
-%%{
- machine GotoCallRet;
-
- sp = ' ';
-
- handle := any @{
- print_str "handle ";
- fhold;
- if ( val == 1 ) { fnext *fentry(one); }
- if ( val == 2 ) { fnext *fentry(two); }
- if ( val == 3 ) { fnext main; }
- };
-
- one := |*
- '{' => { print_str "{ "; fcall *fentry(one); };
- "[" => { print_str "[ "; fcall *fentry(two); };
- "}" sp* => { print_str "} "; fret; };
- [a-z]+ => { print_str "word "; val = 1; fgoto *fentry(handle); };
- ' ' => { print_str "space "; };
- *|;
-
- two := |*
- '{' => { print_str "{ "; fcall *fentry(one); };
- "[" => { print_str "[ "; fcall *fentry(two); };
- ']' sp* => { print_str "] "; fret; };
- [a-z]+ => { print_str "word "; val = 2; fgoto *fentry(handle); };
- ' ' => { print_str "space "; };
- *|;
-
- main := |*
- '{' => { print_str "{ "; fcall one; };
- "[" => { print_str "[ "; fcall two; };
- [a-z]+ => { print_str "word "; val = 3; fgoto handle; };
- [a-z] ' foil' => { print_str "this is the foil";};
- ' ' => { print_str "space "; };
- '\n';
- *|;
-}%%
-
-##### INPUT #####
-"{a{b[c d]d}c}\n"
-"[a{b[c d]d}c}\n"
-"[a[b]c]d{ef{g{h}i}j}l\n"
-"{{[]}}\n"
-"a b c\n"
-"{a b c}\n"
-"[a b c]\n"
-"{]\n"
-"{{}\n"
-"[[[[[[]]]]]]\n"
-"[[[[[[]]}]]]\n"
-##### OUTPUT #####
-{ word handle { word handle [ word handle space word handle ] word handle } word handle } ACCEPT
-[ word handle { word handle [ word handle space word handle ] word handle } word handle FAIL
-[ word handle [ word handle ] word handle ] word handle { word handle { word handle { word handle } word handle } word handle } word handle ACCEPT
-{ { [ ] } } ACCEPT
-word handle space word handle space word handle ACCEPT
-{ word handle space word handle space word handle } ACCEPT
-[ word handle space word handle space word handle ] ACCEPT
-{ FAIL
-{ { } FAIL
-[ [ [ [ [ [ ] ] ] ] ] ] ACCEPT
-[ [ [ [ [ [ ] ] FAIL
diff --git a/test/ragel.d/gotocallret3.rl b/test/ragel.d/gotocallret3.rl
deleted file mode 100644
index 6878f70f..00000000
--- a/test/ragel.d/gotocallret3.rl
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * @LANG: indep
- * @NEEDS_EOF: yes
- */
-
-/*
- * Demonstrate the use of goto, call and return. This machine expects either a
- * lower case char or a digit as a command then a space followed by the command
- * arg. If the command is a char, then the arg must be an a string of chars.
- * If the command is a digit, then the arg must be a string of digits. This
- * choice is determined by action code, rather than though transition
- * desitinations.
- */
-
-char comm;
-int top;
-int stack[32];
-
-%%{
- machine gotocallret;
-
- # A reference to a state in an unused action caused a segfault in 5.8. */
- action unusedAction { fentry(garble_line); }
-
- action err_garbling_line { print_str "error: garbling line\n"; }
- action goto_main { fnext main; }
- action recovery_failed { print_str "error: failed to recover\n"; }
-
- # Error machine, consumes to end of
- # line, then starts the main line over.
- garble_line := ( (any-'\n')*'\n')
- >err_garbling_line
- @goto_main
- $/recovery_failed;
-
- action hold_and_return {fhold; fnret;}
-
- # Look for a string of alphas or of digits,
- # on anything else, hold the character and return.
- alp_comm := alpha+ $!hold_and_return;
- dig_comm := digit+ $!hold_and_return;
-
- # Choose which to machine to call into based on the command.
- action comm_arg {
- if ( comm >= 97 ) {
- fncall alp_comm;
- } else {
- fncall dig_comm;
- }
- }
-
- # Specifies command string. Note that the arg is left out.
- command = (
- [a-z0-9] @{comm = fc;} ' ' @comm_arg @{print_str "prints\n";} '\n'
- ) @{print_str "correct command\n";};
-
- # Any number of commands. If there is an
- # error anywhere, garble the line.
- main := command* $!{fhold;fnext garble_line;};
-}%%
-
-##### INPUT #####
-"lkajsdf\n"
-"2134\n"
-"(\n"
-"\n"
-"*234234()0909 092 -234aslkf09`1 11\n"
-"1\n"
-"909\n"
-"1 a\n"
-"11 1\n"
-"a 1\n"
-"aa a\n"
-"1 1\n"
-"1 123456\n"
-"a a\n"
-"a abcdef\n"
-"h"
-"a aa1"
-##### OUTPUT #####
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-prints
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-prints
-error: garbling line
-ACCEPT
-error: garbling line
-ACCEPT
-prints
-correct command
-ACCEPT
-prints
-correct command
-ACCEPT
-prints
-correct command
-ACCEPT
-prints
-correct command
-ACCEPT
-error: failed to recover
-FAIL
-prints
-error: garbling line
-error: failed to recover
-FAIL
diff --git a/test/ragel.d/high1.rl b/test/ragel.d/high1.rl
deleted file mode 100644
index a901e19a..00000000
--- a/test/ragel.d/high1.rl
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * @LANG: c
- * @PROHIBIT_FLAGS: -F0 -F1
- */
-
-/**
- * Test a high character to make sure signedness
- * isn't messing us up.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-struct high
-{
- int cs;
-};
-
-%%{
- machine high;
- variable cs fsm->cs;
-
- # We Want the header portion.
- alphtype unsigned int;
-
- main := (
- 0x20 .. 0xefffffff @1 @{printf("gothigh1\n");} |
- 0xf0000000 @1 @{printf("gothigh1\n");} |
- 0x200 .. 0xfe000000 @1 @{printf("gothigh2\n");} |
- any @0 @{printf("else\n");}
- )*;
-}%%
-
-%% write data;
-
-void high_init( struct high *fsm )
-{
- %% write init;
-}
-
-void high_execute( struct high *fsm, const unsigned int *_data, int _len )
-{
- const unsigned int *p = _data;
- const unsigned int *pe = _data+_len;
-
- %% write exec;
-}
-
-int high_finish( struct high *fsm )
-{
- if ( fsm->cs == high_error )
- return -1;
- if ( fsm->cs >= high_first_final )
- return 1;
- return 0;
-}
-
-struct high high;
-
-#define BUFSIZE 1024
-char cbuf[BUFSIZE];
-unsigned int buf[BUFSIZE];
-int buflen = 0;
-char numbuf[9];
-int numlen = 0;
-
-struct tokenizer
-{
- int cs;
-};
-
-%%{
- machine tokenizer;
- variable cs fsm->cs;
-
- action bufdigit {
- if ( numlen < 8 )
- numbuf[numlen++] = fc;
- }
-
- action writeDigit {
- /* Null terminate the buffer storing the number and reset. */
- numbuf[numlen] = 0;
- numlen = 0;
-
- /* Store the number in the buf. If the buf is full then
- * flush and reset the buffer. */
- buf[buflen++] = strtoul( numbuf, 0, 16 );
- if ( buflen == BUFSIZE ) {
- high_execute( &high, buf, BUFSIZE );
- buflen = 0;
- }
- }
-
- action finish {
- if ( buflen > 0 )
- high_execute( &high, buf, buflen );
- if ( high_finish( &high ) > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
- }
-
- num = ( digit | 'a'..'f' )+ $bufdigit %writeDigit;
- main := ( num $1 %0 | space )* %/finish;
-}%%
-
-%% write data;
-
-void tokenizer_init( struct tokenizer *fsm )
-{
- %% write init;
-}
-
-void tokenizer_execute( struct tokenizer *fsm, const char *_data, int _len )
-{
- const char *p = _data;
- const char *pe = _data+_len;
- const char *eof = pe;
-
- %% write exec;
-}
-
-int tokenizer_finish( struct tokenizer *fsm )
-{
- if ( fsm->cs == tokenizer_error )
- return -1;
- if ( fsm->cs >= tokenizer_first_final )
- return 1;
- return 0;
-}
-
-struct tokenizer tok;
-
-void test( char *cbuf )
-{
- int len = strlen( cbuf );
- high_init( &high );
- tokenizer_init( &tok );
- tokenizer_execute( &tok, cbuf, len );
- if ( tokenizer_finish( &tok ) <= 0 )
- printf("Tokenizer FAIL\n");
-}
-
-char data[] =
- "10 20 30 40 50 200 300 400 \n"
- "d0000000 f0000000 fd000000 fe000000\n"
- "ff000000 ffffffffffffffffffffffffff\n"
- "ff\n";
-
-int main()
-{
- test( data );
- return 0;
-}
-
-##### OUTPUT #####
-else
-gothigh1
-gothigh1
-gothigh1
-gothigh1
-gothigh1
-gothigh2
-gothigh1
-gothigh2
-gothigh1
-gothigh2
-gothigh1
-gothigh2
-gothigh1
-gothigh2
-gothigh2
-gothigh2
-else
-else
-gothigh1
-ACCEPT
diff --git a/test/ragel.d/high2.rl b/test/ragel.d/high2.rl
deleted file mode 100644
index 457fdee8..00000000
--- a/test/ragel.d/high2.rl
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * @LANG: c++
- */
-
-/**
- * Test a high character to make sure signedness
- * isn't messing us up.
- */
-
-#include <stdio.h>
-#include <string.h>
-
-struct Fsm
-{
- int cs;
-
- // Initialize the machine. Invokes any init statement blocks. Returns 0
- // if the machine begins in a non-accepting state and 1 if the machine
- // begins in an accepting state.
- int init( );
-
- // Execute the machine on a block of data. Returns -1 if after processing
- // the data, the machine is in the error state and can never accept, 0 if
- // the machine is in a non-accepting state and 1 if the machine is in an
- // accepting state.
- int execute( const unsigned char *data, int len );
-
- // Indicate that there is no more data. Returns -1 if the machine finishes
- // in the error state and does not accept, 0 if the machine finishes
- // in any other non-accepting state and 1 if the machine finishes in an
- // accepting state.
- int finish( );
-};
-
-%%{
- machine Fsm;
-
- alphtype unsigned char;
-
- # Indicate we got the high character.
- action gothigh {
- printf("yes\n");
- }
-
- main := 0xe8 @gothigh '\n';
-}%%
-
-%% write data;
-
-int Fsm::init( )
-{
- %% write init;
- return 0;
-}
-
-int Fsm::execute( const unsigned char *_data, int _len )
-{
- const unsigned char *p = _data;
- const unsigned char *pe = _data+_len;
- %% write exec;
- if ( cs == Fsm_error )
- return -1;
- if ( cs >= Fsm_first_final )
- return 1;
- return 0;
-}
-
-int Fsm::finish()
-{
- if ( cs == Fsm_error )
- return -1;
- if ( cs >= Fsm_first_final )
- return 1;
- return 0;
-}
-
-Fsm fsm;
-
-void test( unsigned char *buf, int len )
-{
- fsm.init();
- fsm.execute( buf, len );
- if ( fsm.finish() > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
-}
-
-unsigned char data1[] = { 0xe8, 10 };
-unsigned char data2[] = { 0xf8, 10 };
-
-int main()
-{
- test( data1, 2 );
- test( data2, 2 );
- return 0;
-}
-
-##### OUTPUT #####
-yes
-ACCEPT
-FAIL
diff --git a/test/ragel.d/high3.rl b/test/ragel.d/high3.rl
deleted file mode 100644
index 454da6a8..00000000
--- a/test/ragel.d/high3.rl
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * @LANG: obj-c
- */
-
-/**
- * Test a high character to make sure signedness
- * isn't messing us up.
- */
-
-#include <stdio.h>
-#include <objc/Object.h>
-#include <Foundation/Foundation.h>
-
-@interface Fsm : NSObject
-{
-@public
- int cs;
-};
-
-// Initialize the machine. Invokes any init statement blocks. Returns 0
-// if the machine begins in a non-accepting state and 1 if the machine
-// begins in an accepting state.
-- (int) initFsm;
-
-// Execute the machine on a block of data. Returns -1 if after processing
-// the data, the machine is in the error state and can never accept, 0 if
-// the machine is in a non-accepting state and 1 if the machine is in an
-// accepting state.
-- (void) executeWithData:(const unsigned char *)data len:(int)len;
-
-// Indicate that there is no more data. Returns -1 if the machine finishes
-// in the error state and does not accept, 0 if the machine finishes
-// in any other non-accepting state and 1 if the machine finishes in an
-// accepting state.
-- (int) finish;
-
-@end
-
-@implementation Fsm
-
-%%{
- machine Fsm;
-
- alphtype unsigned char;
-
- # Indicate we got the high character.
- action gothigh {
- printf("yes\n");
- }
-
- main := 0xe8 @gothigh '\n';
-}%%
-
-%% write data;
-
-- (int) initFsm;
-{
- %% write init;
- return 1;
-}
-
-- (void) executeWithData:(const unsigned char *)_data len:(int)_len;
-{
- const unsigned char *p = _data;
- const unsigned char *pe = _data + _len;
- %% write exec;
-}
-
-- (int) finish;
-{
- if ( cs == Fsm_error )
- return -1;
- else if ( cs >= Fsm_first_final )
- return 1;
- return 0;
-}
-
-
-@end
-
-
-#define BUFSIZE 2048
-
-Fsm *fsm;
-unsigned char buf[BUFSIZE];
-
-void test( unsigned char *buf, int len )
-{
- fsm = [[Fsm alloc] init];
- [fsm initFsm];
- [fsm executeWithData:buf len:len];
- if ( [fsm finish] > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
-}
-
-unsigned char data1[] = { 0xe8, 10 };
-unsigned char data2[] = { 0xf8, 10 };
-
-int main()
-{
- test( data1, 2 );
- test( data2, 2 );
- return 0;
-}
-
-##### OUTPUT #####
-yes
-ACCEPT
-FAIL
diff --git a/test/ragel.d/import1.rl b/test/ragel.d/import1.rl
deleted file mode 100644
index 0c7769c3..00000000
--- a/test/ragel.d/import1.rl
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stdio.h>
-
-char *foo = "foo";
-
-char b = 98;
-char a = 97;
-char r = 114;
-
-#define SP 32
-#define NL '\n'
-
-%%{
- machine tmp;
- import "import1.rl";
-
- foobar =
- foo @{printf("foo\n"); } |
- b a r @{printf("bar\n");};
-
- main := ( foobar SP foobar NL )*;
-}%%
-
-%% write data;
-
-int cs;
-
-void exec_str( char *p, int len )
-{
- char *pe = p + len;
- %% write exec;
-}
-
-void exec_c( char c )
-{
- exec_str( &c, 1 );
-}
-
-int main()
-{
- %% write init;
-
- exec_str( foo, 3 );
- exec_c( SP );
- exec_c( b );
- exec_c( a );
- exec_c( r );
- exec_c( NL );
-
- exec_c( b );
- exec_c( a );
- exec_c( r );
- exec_c( SP );
- exec_str( foo, 3 );
- exec_c( NL );
-
- if ( cs < tmp_first_final )
- printf("FAIL\n");
- else
- printf("ACCEPT\n");
-
- return 0;
-}
-
-##### OUTPUT #####
-foo
-bar
-bar
-foo
-ACCEPT
diff --git a/test/ragel.d/import2.h b/test/ragel.d/import2.h
deleted file mode 100644
index 707271dd..00000000
--- a/test/ragel.d/import2.h
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-#define A 49
-
-#define B "2"
-
-#define C '3'
-
-int D = 52;
-
-const char *E = "5";
-
-char F = '6';
diff --git a/test/ragel.d/import2.rl b/test/ragel.d/import2.rl
deleted file mode 100644
index 8588a6a7..00000000
--- a/test/ragel.d/import2.rl
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stdio.h>
-
-%%{
- machine foo;
-
- import "import2.h";
-
- main := A B C D E F;
-
-}%%
-
-%% write data;
-
-int main()
-{
- printf( "run\n" );
-}
-
-##### OUTPUT #####
-run
diff --git a/test/ragel.d/include1.rl b/test/ragel.d/include1.rl
deleted file mode 100644
index 719eeead..00000000
--- a/test/ragel.d/include1.rl
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * @LANG: c
- * @ENABLED: false
- *
- * Provides definitions for include tests.
- */
-
-%%{
- machine include_test_1;
-
- action A {printf(" a1");}
- action B {printf(" b1");}
-
- action NonRef1 {printf(" nr1");}
-
- a1 = 'a' @A;
- b1 = 'b' @B;
-}%%
-
-%%{
- machine include_test_2;
-
- action NonRef2 {printf(" nr2");}
-
- a2 = 'a' @{printf(" a2");};
- b2 = 'b' @{printf(" b2");};
-}%%
-
diff --git a/test/ragel.d/include2.rl b/test/ragel.d/include2.rl
deleted file mode 100644
index 402ee36f..00000000
--- a/test/ragel.d/include2.rl
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stdio.h>
-#include <string.h>
-
-%%{
- machine include_test_4;
-
- action NonRef3 {printf(" nr3");}
-
- a3 = 'a'@{printf(" a3");};
- b3 = 'b'@{printf(" b3");};
-
-}%%
-
-%%{
- machine include_test_1;
-
- include "include1.rl";
-
- include include_test_2 "include1.rl";
-
- include include_test_4;
-
- main :=
- a1 b1 @NonRef1
- a2 b2 @NonRef2
- a3 b3 @NonRef3
- 0 @{fnbreak;};
-}%%
-
-%% write data;
-
-void test( char *p )
-{
- int cs;
- %% write init;
- %% write exec noend;
- printf("\n");
-}
-
-int main()
-{
- test( "ababab" );
- return 0;
-}
-
-##### OUTPUT #####
- a1 b1 nr1 a2 b2 nr2 a3 b3 nr3
diff --git a/test/ragel.d/include3.rl b/test/ragel.d/include3.rl
deleted file mode 100644
index 1ef55732..00000000
--- a/test/ragel.d/include3.rl
+++ /dev/null
@@ -1,6 +0,0 @@
-/*
- * @LANG: c
- * @RAGEL_FILE: include3/smtp_addr_parser.rl
- */
-
-##### OUTPUT #####
diff --git a/test/ragel.d/include3/smtp_addr_parser.rl b/test/ragel.d/include3/smtp_addr_parser.rl
deleted file mode 100644
index 4c446e1b..00000000
--- a/test/ragel.d/include3/smtp_addr_parser.rl
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * @LANG: c
- */
-
-%%{
- machine smtp_addr_parser;
- include smtp_address "smtp_address.rl";
-
- main := 'main';
-}%%
-
-%% write data;
-
-int main()
-{
-
-}
diff --git a/test/ragel.d/include3/smtp_address.rl b/test/ragel.d/include3/smtp_address.rl
deleted file mode 100644
index 1170ebfe..00000000
--- a/test/ragel.d/include3/smtp_address.rl
+++ /dev/null
@@ -1,8 +0,0 @@
-%%{
- machine smtp_address;
-
- include smtp_ip "smtp_ip.rl";
- include smtp_whitespace "smtp_whitespace.rl";
-
-
-}%%
diff --git a/test/ragel.d/include3/smtp_ip.rl b/test/ragel.d/include3/smtp_ip.rl
deleted file mode 100644
index f2b7633b..00000000
--- a/test/ragel.d/include3/smtp_ip.rl
+++ /dev/null
@@ -1,4 +0,0 @@
-%%{
- machine smtp_ip;
-
-}%%
diff --git a/test/ragel.d/include3/smtp_whitespace.rl b/test/ragel.d/include3/smtp_whitespace.rl
deleted file mode 100644
index a62f739c..00000000
--- a/test/ragel.d/include3/smtp_whitespace.rl
+++ /dev/null
@@ -1,4 +0,0 @@
-%%{
- machine smtp_whitespace;
-
-}%%
diff --git a/test/ragel.d/java1.rl b/test/ragel.d/java1.rl
deleted file mode 100644
index 68e3dd22..00000000
--- a/test/ragel.d/java1.rl
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * @LANG: java
- */
-
-class java1
-{
- %%{
- machine java1;
-
- one := 'one\n';
- two := 'two\n';
- four := 'four\n';
-
- main :=
- ( 'hello' | 'there' | 'friend' )
- '\n' @{int s = fentry(one); fgoto *s; char c = fc;}
- ( 'one' | 'two' | 'four' ) '\n';
- }%%
-
- %% write data;
-
- static void test( char data[] )
- {
- int cs, p = 0, pe = data.length;
- int top;
-
- %% write init;
- %% write exec;
-
- if ( cs >= java1_first_final )
- System.out.println( "ACCEPT" );
- else
- System.out.println( "FAIL" );
- }
-
- public static void main( String args[] )
- {
- test( "hello\none\n".toCharArray() );
- test( "there\ntwo\n".toCharArray() );
- test( "friend\nfour\n".toCharArray() );
- }
-}
-
-##### OUTPUT #####
-ACCEPT
-FAIL
-FAIL
diff --git a/test/ragel.d/java2.rl b/test/ragel.d/java2.rl
deleted file mode 100644
index 35a851cc..00000000
--- a/test/ragel.d/java2.rl
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * @LANG: java
- * @PROHIBIT_FLAGS: -F0 -F1
- */
-
-class java2
-{
- %%{
- machine java1;
- alphtype int;
-
- main := 1 2 3 4 (
- 5 6 7 8 |
- 9 10 11 12
- ) 1073741824;
-
- }%%
-
- %% write data;
-
- static void test( int data[] )
- {
- int cs, p = 0, pe = data.length;
- int top;
-
- %% write init;
- %% write exec;
-
- if ( cs >= java1_first_final )
- System.out.println( "ACCEPT" );
- else
- System.out.println( "FAIL" );
- }
-
- static final int t1[] = { 1, 2, 3, 4, 5, 6, 7, 8, 1073741824 };
- static final int t2[] = { 1, 2, 3, 4, 9, 10, 11, 12, 1073741824 };
- static final int t3[] = { 1, 2, 3, 4, 1073741824 };
-
- public static void main( String args[] )
- {
- test( t1 );
- test( t2 );
- test( t3 );
- }
-}
-
-##### OUTPUT #####
-ACCEPT
-ACCEPT
-FAIL
diff --git a/test/ragel.d/julia1.rl b/test/ragel.d/julia1.rl
deleted file mode 100644
index 4b349908..00000000
--- a/test/ragel.d/julia1.rl
+++ /dev/null
@@ -1,34 +0,0 @@
-// @LANG: julia
-
-%%{
- machine atoi;
-
- main := '-'? [0-9]+ '.' @{
- println( "match" );
- };
-}%%
-
-%% write data;
-
-function test( data_string::AbstractString )
- data = Vector{UInt8}( data_string )
- p = 0
- pe = length(data)
- eof = length(data)
- cs = 0
-
- %% write init;
-
- %% write exec;
-end
-
-
-test( "-99." )
-test( "100." )
-test( "100x." )
-test( "1000." )
-
-######## OUTPUT #######
-match
-match
-match
diff --git a/test/ragel.d/keller1.rl b/test/ragel.d/keller1.rl
deleted file mode 100644
index 9ec5da41..00000000
--- a/test/ragel.d/keller1.rl
+++ /dev/null
@@ -1,1074 +0,0 @@
-/*
- * @LANG: c++
- */
-
-/*
- * Automatically generated by keller. Do not edit.
- *
- * Parts of this file are copied from Keller source covered by the GNU
- * GPL. As a special exception, you may use the parts of this file copied
- * from Keller source without restriction. The remainder is derived from
- * "tmp.gmr" and inherits the copyright status of that file.
- */
-
-#line 1 "tmp.gmr"
-#include <iostream>
-using std::cout;
-using std::endl;
-
-
-#line 16 "tmp.rl"
-enum token_type_e {
- tt_id,
- tt_equals,
- tt_semi,
- tt_pipe,
- tt_amp,
- tt_minus,
- tt_dot,
- tt_colon,
- tt_percent,
- tt_dollar,
- tt_plus,
- tt_number,
- tt_star,
- tt_question,
- tt_not,
- tt_andFSM,
- tt_orFSM,
- tt_open,
- tt_close
-};
-
-struct LangEl
-{
- int line, lineEnd;
- int pos;
-
- int type;
- int state;
- LangEl *prev, *next;
-};
-
-struct Token : public LangEl
-{
- const char *value;
-};
-
-struct Lel_start : public LangEl
-{
-#line 32 "tmp.gmr"
-
- int si;
-#line 59 "tmp.rl"
-};
-
-struct Lel_M : public LangEl
-{
-#line 36 "tmp.gmr"
-
- int mi;
-#line 67 "tmp.rl"
-};
-
-#define l__error 19
-#define l_tt_id 0
-#define l_tt_equals 1
-#define l_tt_semi 2
-#define l_tt_pipe 3
-#define l_tt_amp 4
-#define l_tt_minus 5
-#define l_tt_dot 6
-#define l_tt_colon 7
-#define l_tt_percent 8
-#define l_tt_dollar 9
-#define l_tt_plus 10
-#define l_tt_number 11
-#define l_tt_star 12
-#define l_tt_question 13
-#define l_tt_not 14
-#define l_tt_andFSM 15
-#define l_tt_orFSM 16
-#define l_tt_open 17
-#define l_tt_close 18
-#define l_start 23
-#define l_M 24
-#define l_A 25
-#define l_E 26
-#define l_T 27
-#define l_N 28
-#define l_K 29
-#define l_F 30
-#define l__start 31
-#define l__eof 20
-
-struct LangEl;
-
-struct Parser
-{
- Parser();
-
- void parseLangEl( LangEl *langEl );
- int done( );
-
- void push( LangEl *lel ) {
- lel->prev = stack;
- stack = lel;
- }
- LangEl *pop() {
- LangEl *ret = stack;
- stack = stack->prev;
- return ret;
- }
- int pop( int n );
- void rem( LangEl *lel, int n );
- LangEl *stack;
- int next;
- LangEl *redLel;
- LangEl *rhs[10];
-
- int cs;
-
- // Initialize the machine. Invokes any init statement blocks. Returns 0
- // if the machine begins in a non-accepting state and 1 if the machine
- // begins in an accepting state.
- int init( );
-
- // Execute the machine on a block of data. Returns -1 if after processing
- // the data, the machine is in the error state and can never accept, 0 if
- // the machine is in a non-accepting state and 1 if the machine is in an
- // accepting state.
- int execute( LangEl *data, int len );
-
- // Indicate that there is no more data. Returns -1 if the machine finishes
- // in the error state and does not accept, 0 if the machine finishes
- // in any other non-accepting state and 1 if the machine finishes in an
- // accepting state.
- int finish( );
-};
-
-
-%%{
- machine Parser;
-
- getkey fpc->type;
-
- action shift {
- fpc->state = fcurs;
- push( fpc );
- }
-
- action pop1 { fnext *pop(1); }
- action pop2 { fnext *pop(2); }
- action pop3 { fnext *pop(3); }
- action pop4 { fnext *pop(4); }
-
- action new_error {
- redLel = new LangEl();
- redLel->type = 19;
- }
-
- action newstart {
- redLel = new Lel_start();
- redLel->type = 23;
- }
-
- action newM {
- redLel = new Lel_M();
- redLel->type = 24;
- }
-
- action newA {
- redLel = new LangEl();
- redLel->type = 25;
- }
-
- action newE {
- redLel = new LangEl();
- redLel->type = 26;
- }
-
- action newT {
- redLel = new LangEl();
- redLel->type = 27;
- }
-
- action newN {
- redLel = new LangEl();
- redLel->type = 28;
- }
-
- action newK {
- redLel = new LangEl();
- redLel->type = 29;
- }
-
- action newF {
- redLel = new LangEl();
- redLel->type = 30;
- }
-
- action new_eof {
- redLel = new LangEl();
- redLel->type = 20;
- }
-
- action new_epsilon {
- redLel = new LangEl();
- redLel->type = 21;
- }
-
- action new_null {
- redLel = new LangEl();
- redLel->type = 22;
- }
-
- action rem1 { rem(fpc, 1); }
- action rem2 { rem(fpc, 2); }
- action rem3 { rem(fpc, 3); }
- action rem4 { rem(fpc, 4); }
-
- action r_start_0
- {
-#line 41 "tmp.gmr"
-
- cout << "start = M;" << endl;
- static_cast<Lel_start*>(redLel)->si = static_cast<Lel_M*>(rhs[0])->mi;
-
-#line 214 "tmp.rl"
- }
-
- action r_M_0
- {
-#line 44 "tmp.gmr"
- cout << "M = M A;" << endl;
-#line 221 "tmp.rl"
- }
-
- action r_M_1
- {
-#line 45 "tmp.gmr"
- cout << "M = A;" << endl;
-#line 228 "tmp.rl"
- }
-
- action r_A_0
- {
-#line 46 "tmp.gmr"
- cout << "A = tt_id tt_equals E tt_semi;" << endl;
-#line 235 "tmp.rl"
- }
-
- action r_E_0
- {
-#line 47 "tmp.gmr"
- cout << "E = E tt_pipe T;" << endl;
-#line 242 "tmp.rl"
- }
-
- action r_E_1
- {
-#line 48 "tmp.gmr"
- cout << "E = E tt_amp T;" << endl;
-#line 249 "tmp.rl"
- }
-
- action r_E_2
- {
-#line 49 "tmp.gmr"
- cout << "E = E tt_minus T;" << endl;
-#line 256 "tmp.rl"
- }
-
- action r_E_3
- {
-#line 50 "tmp.gmr"
- cout << "E = T;" << endl;
-#line 263 "tmp.rl"
- }
-
- action r_T_0
- {
-#line 51 "tmp.gmr"
- cout << "T = T tt_dot N;" << endl;
-#line 270 "tmp.rl"
- }
-
- action r_T_1
- {
-#line 52 "tmp.gmr"
- cout << "T = T N;" << endl;
-#line 277 "tmp.rl"
- }
-
- action r_T_2
- {
-#line 53 "tmp.gmr"
- cout << "T = N;" << endl;
-#line 284 "tmp.rl"
- }
-
- action r_N_0
- {
-#line 54 "tmp.gmr"
- cout << "N = N tt_colon tt_id;" << endl;
-#line 291 "tmp.rl"
- }
-
- action r_N_1
- {
-#line 55 "tmp.gmr"
- cout << "N = N tt_percent tt_id;" << endl;
-#line 298 "tmp.rl"
- }
-
- action r_N_2
- {
-#line 56 "tmp.gmr"
- cout << "N = N tt_dollar tt_id;" << endl;
-#line 305 "tmp.rl"
- }
-
- action r_N_3
- {
-#line 57 "tmp.gmr"
- cout << "N = N tt_colon tt_plus tt_number;" << endl;
-#line 312 "tmp.rl"
- }
-
- action r_N_4
- {
-#line 58 "tmp.gmr"
- cout << "N = N tt_colon tt_minus tt_number;" << endl;
-#line 319 "tmp.rl"
- }
-
- action r_N_5
- {
-#line 59 "tmp.gmr"
- cout << "N = N tt_percent tt_plus tt_number;" << endl;
-#line 326 "tmp.rl"
- }
-
- action r_N_6
- {
-#line 60 "tmp.gmr"
- cout << "N = N tt_percent tt_minus tt_number;" << endl;
-#line 333 "tmp.rl"
- }
-
- action r_N_7
- {
-#line 61 "tmp.gmr"
- cout << "N = N tt_dollar tt_plus tt_number;" << endl;
-#line 340 "tmp.rl"
- }
-
- action r_N_8
- {
-#line 62 "tmp.gmr"
- cout << "N = N tt_dollar tt_minus tt_number;" << endl;
-#line 347 "tmp.rl"
- }
-
- action r_N_9
- {
-#line 63 "tmp.gmr"
- cout << "N = K;" << endl;
-#line 354 "tmp.rl"
- }
-
- action r_K_0
- {
-#line 64 "tmp.gmr"
- cout << "K = F tt_star;" << endl;
-#line 361 "tmp.rl"
- }
-
- action r_K_1
- {
-#line 65 "tmp.gmr"
- cout << "K = F tt_question;" << endl;
-#line 368 "tmp.rl"
- }
-
- action r_K_2
- {
-#line 66 "tmp.gmr"
- cout << "K = F tt_plus;" << endl;
-#line 375 "tmp.rl"
- }
-
- action r_K_3
- {
-#line 67 "tmp.gmr"
- cout << "K = F;" << endl;
-#line 382 "tmp.rl"
- }
-
- action r_K_4
- {
-#line 68 "tmp.gmr"
- cout << "K = tt_not F tt_star;" << endl;
-#line 389 "tmp.rl"
- }
-
- action r_K_5
- {
-#line 69 "tmp.gmr"
- cout << "K = tt_not F tt_question;" << endl;
-#line 396 "tmp.rl"
- }
-
- action r_K_6
- {
-#line 70 "tmp.gmr"
- cout << "K = tt_not F tt_plus;" << endl;
-#line 403 "tmp.rl"
- }
-
- action r_K_7
- {
-#line 71 "tmp.gmr"
- cout << "K = tt_not F;" << endl;
-#line 410 "tmp.rl"
- }
-
- action r_F_0
- {
-#line 72 "tmp.gmr"
- cout << "F = tt_andFSM;" << endl;
-#line 417 "tmp.rl"
- }
-
- action r_F_1
- {
-#line 73 "tmp.gmr"
- cout << "F = tt_orFSM;" << endl;
-#line 424 "tmp.rl"
- }
-
- action r_F_2
- {
-#line 74 "tmp.gmr"
- cout << "F = tt_id;" << endl;
-#line 431 "tmp.rl"
- }
-
- action r_F_3
- {
-#line 75 "tmp.gmr"
- cout << "F = tt_open E tt_close;" << endl;
-#line 438 "tmp.rl"
- }
-
- main :=
- s0: start: (
- 23 @shift -> s1 |
- 25 @shift -> s3 |
- 24 @shift -> s4 |
- 0 @shift -> s5
- ),
- s1: (
- 20 @shift -> s54
- ),
- s2: (
- (0|20) @pop2 @newM @r_M_0 @rem2 -> s54
- ),
- s3: (
- (0|20) @pop1 @newM @r_M_1 @rem1 -> s54
- ),
- s4: (
- 20 @pop1 @newstart @r_start_0 @rem1 -> s54 |
- 25 @shift -> s2 |
- 0 @shift -> s5
- ),
- s5: (
- 1 @shift -> s6
- ),
- s6: (
- 26 @shift -> s8 |
- 27 @shift -> s9 |
- 29 @shift -> s25 |
- 28 @shift -> s26 |
- 30 @shift -> s33 |
- 17 @shift -> s35 |
- 14 @shift -> s46 |
- 15 @shift -> s48 |
- 16 @shift -> s49 |
- 0 @shift -> s50
- ),
- s7: (
- (0|20) @pop4 @newA @r_A_0 @rem4 -> s54
- ),
- s8: (
- 2 @shift -> s7 |
- 3 @shift -> s37 |
- 4 @shift -> s38 |
- 5 @shift -> s39
- ),
- s9: (
- (2..5|18) @pop1 @newE @r_E_3 @rem1 -> s54 |
- 29 @shift -> s25 |
- 30 @shift -> s33 |
- 28 @shift -> s34 |
- 17 @shift -> s35 |
- 6 @shift -> s41 |
- 14 @shift -> s46 |
- 15 @shift -> s48 |
- 16 @shift -> s49 |
- 0 @shift -> s50
- ),
- s10: (
- (0|2..9|14..18) @pop3 @newN @r_N_0 @rem3 -> s54
- ),
- s11: (
- (0|2..9|14..18) @pop3 @newN @r_N_1 @rem3 -> s54
- ),
- s12: (
- (0|2..9|14..18) @pop3 @newN @r_N_2 @rem3 -> s54
- ),
- s13: (
- 11 @shift -> s14
- ),
- s14: (
- (0|2..9|14..18) @pop4 @newN @r_N_3 @rem4 -> s54
- ),
- s15: (
- 11 @shift -> s16
- ),
- s16: (
- (0|2..9|14..18) @pop4 @newN @r_N_4 @rem4 -> s54
- ),
- s17: (
- 11 @shift -> s18
- ),
- s18: (
- (0|2..9|14..18) @pop4 @newN @r_N_5 @rem4 -> s54
- ),
- s19: (
- 11 @shift -> s20
- ),
- s20: (
- (0|2..9|14..18) @pop4 @newN @r_N_6 @rem4 -> s54
- ),
- s21: (
- 11 @shift -> s22
- ),
- s22: (
- (0|2..9|14..18) @pop4 @newN @r_N_7 @rem4 -> s54
- ),
- s23: (
- 11 @shift -> s24
- ),
- s24: (
- (0|2..9|14..18) @pop4 @newN @r_N_8 @rem4 -> s54
- ),
- s25: (
- (0|2..9|14..18) @pop1 @newN @r_N_9 @rem1 -> s54
- ),
- s26: (
- (0|2..6|14..18) @pop1 @newT @r_T_2 @rem1 -> s54 |
- 7 @shift -> s27 |
- 8 @shift -> s28 |
- 9 @shift -> s29
- ),
- s27: (
- 0 @shift -> s10 |
- 10 @shift -> s13 |
- 5 @shift -> s15
- ),
- s28: (
- 0 @shift -> s11 |
- 10 @shift -> s17 |
- 5 @shift -> s19
- ),
- s29: (
- 0 @shift -> s12 |
- 10 @shift -> s21 |
- 5 @shift -> s23
- ),
- s30: (
- (0|2..9|14..18) @pop2 @newK @r_K_0 @rem2 -> s54
- ),
- s31: (
- (0|2..9|14..18) @pop2 @newK @r_K_1 @rem2 -> s54
- ),
- s32: (
- (0|2..9|14..18) @pop2 @newK @r_K_2 @rem2 -> s54
- ),
- s33: (
- (0|2..9|14..18) @pop1 @newK @r_K_3 @rem1 -> s54 |
- 12 @shift -> s30 |
- 13 @shift -> s31 |
- 10 @shift -> s32
- ),
- s34: (
- (0|2..6|14..18) @pop2 @newT @r_T_1 @rem2 -> s54 |
- 7 @shift -> s27 |
- 8 @shift -> s28 |
- 9 @shift -> s29
- ),
- s35: (
- 27 @shift -> s9 |
- 29 @shift -> s25 |
- 28 @shift -> s26 |
- 30 @shift -> s33 |
- 17 @shift -> s35 |
- 26 @shift -> s40 |
- 14 @shift -> s46 |
- 15 @shift -> s48 |
- 16 @shift -> s49 |
- 0 @shift -> s50
- ),
- s36: (
- (0|2..10|12..18) @pop3 @newF @r_F_3 @rem3 -> s54
- ),
- s37: (
- 29 @shift -> s25 |
- 28 @shift -> s26 |
- 30 @shift -> s33 |
- 17 @shift -> s35 |
- 14 @shift -> s46 |
- 15 @shift -> s48 |
- 16 @shift -> s49 |
- 0 @shift -> s50 |
- 27 @shift -> s53
- ),
- s38: (
- 29 @shift -> s25 |
- 28 @shift -> s26 |
- 30 @shift -> s33 |
- 17 @shift -> s35 |
- 14 @shift -> s46 |
- 15 @shift -> s48 |
- 16 @shift -> s49 |
- 0 @shift -> s50 |
- 27 @shift -> s52
- ),
- s39: (
- 29 @shift -> s25 |
- 28 @shift -> s26 |
- 30 @shift -> s33 |
- 17 @shift -> s35 |
- 27 @shift -> s42 |
- 14 @shift -> s46 |
- 15 @shift -> s48 |
- 16 @shift -> s49 |
- 0 @shift -> s50
- ),
- s40: (
- 18 @shift -> s36 |
- 3 @shift -> s37 |
- 4 @shift -> s38 |
- 5 @shift -> s39
- ),
- s41: (
- 29 @shift -> s25 |
- 30 @shift -> s33 |
- 17 @shift -> s35 |
- 14 @shift -> s46 |
- 15 @shift -> s48 |
- 16 @shift -> s49 |
- 0 @shift -> s50 |
- 28 @shift -> s51
- ),
- s42: (
- (2..5|18) @pop3 @newE @r_E_2 @rem3 -> s54 |
- 29 @shift -> s25 |
- 30 @shift -> s33 |
- 28 @shift -> s34 |
- 17 @shift -> s35 |
- 6 @shift -> s41 |
- 14 @shift -> s46 |
- 15 @shift -> s48 |
- 16 @shift -> s49 |
- 0 @shift -> s50
- ),
- s43: (
- (0|2..9|14..18) @pop3 @newK @r_K_4 @rem3 -> s54
- ),
- s44: (
- (0|2..9|14..18) @pop3 @newK @r_K_5 @rem3 -> s54
- ),
- s45: (
- (0|2..9|14..18) @pop3 @newK @r_K_6 @rem3 -> s54
- ),
- s46: (
- 17 @shift -> s35 |
- 30 @shift -> s47 |
- 15 @shift -> s48 |
- 16 @shift -> s49 |
- 0 @shift -> s50
- ),
- s47: (
- (0|2..9|14..18) @pop2 @newK @r_K_7 @rem2 -> s54 |
- 12 @shift -> s43 |
- 13 @shift -> s44 |
- 10 @shift -> s45
- ),
- s48: (
- (0|2..10|12..18) @pop1 @newF @r_F_0 @rem1 -> s54
- ),
- s49: (
- (0|2..10|12..18) @pop1 @newF @r_F_1 @rem1 -> s54
- ),
- s50: (
- (0|2..10|12..18) @pop1 @newF @r_F_2 @rem1 -> s54
- ),
- s51: (
- (0|2..6|14..18) @pop3 @newT @r_T_0 @rem3 -> s54 |
- 7 @shift -> s27 |
- 8 @shift -> s28 |
- 9 @shift -> s29
- ),
- s52: (
- (2..5|18) @pop3 @newE @r_E_1 @rem3 -> s54 |
- 29 @shift -> s25 |
- 30 @shift -> s33 |
- 28 @shift -> s34 |
- 17 @shift -> s35 |
- 6 @shift -> s41 |
- 14 @shift -> s46 |
- 15 @shift -> s48 |
- 16 @shift -> s49 |
- 0 @shift -> s50
- ),
- s53: (
- (2..5|18) @pop3 @newE @r_E_0 @rem3 -> s54 |
- 29 @shift -> s25 |
- 30 @shift -> s33 |
- 28 @shift -> s34 |
- 17 @shift -> s35 |
- 6 @shift -> s41 |
- 14 @shift -> s46 |
- 15 @shift -> s48 |
- 16 @shift -> s49 |
- 0 @shift -> s50
- ),
- s54: (
- '' -> final
- )
- ;
-}%%
-
-%% write data;
-
-Parser::Parser( )
-{ }
-
-int Parser::init( )
-{
- %% write init;
- return 0;
-}
-
-int Parser::execute( LangEl *_data, int _len )
-{
- LangEl *p = _data;
- LangEl *pe = _data+_len;
- %% write exec;
- if ( cs == Parser_error )
- return -1;
- if ( cs >= Parser_first_final )
- return 1;
- return 0;
-}
-
-int Parser::finish( )
-{
- if ( cs == Parser_error )
- return -1;
- if ( cs >= Parser_first_final )
- return 1;
- return 0;
-}
-
-void Parser::parseLangEl( LangEl *lel )
-{
- redLel = 0;
- execute( lel, 1 );
- while ( redLel != 0 ) {
- execute( redLel, 1 );
- redLel = 0;
- execute( lel, 1 );
- }
-}
-
-int Parser::pop( int n )
-{
- for ( int i = n-1; i >= 0; i-- )
- rhs[i] = pop();
- return rhs[0]->state;
-}
-
-void Parser::rem( LangEl *lel, int n )
-{
- for ( int i = n-1; i >= 0; i-- )
- delete rhs[i];
-}
-
-int Parser::done( )
-{
- Token *eof = new Token;
- eof->type = l__eof;
- eof->line = 0;
- eof->pos = 0;
- parseLangEl( eof );
- return finish();
-}
-
-#line 77 "tmp.gmr"
-
-
-#include <assert.h>
-#define MAX_TOKS 10000
-
-struct TokList
-{
- TokList() : numToks(0) { }
-
- void append( int type );
- int parse();
-
- Token *toks[MAX_TOKS];
- int numToks;
-};
-
-void TokList::append( int type )
-{
- assert( numToks < MAX_TOKS );
- toks[numToks] = new Token;
- toks[numToks]->type = type;
- numToks += 1;
-}
-
-int TokList::parse()
-{
- Parser parser;
- parser.init();
- for ( int i = 0; i < numToks; i++ )
- parser.parseLangEl( toks[i] );
- return parser.done();
-}
-
-void test0()
-{
- TokList tokList;
- tokList.append( tt_id );
- tokList.append( tt_equals );
- tokList.append( tt_id );
- tokList.append( tt_star );
- tokList.append( tt_minus );
- tokList.append( tt_andFSM );
- tokList.append( tt_dot );
- tokList.append( tt_id );
- tokList.append( tt_semi );
- tokList.append( tt_id );
- tokList.append( tt_equals );
- tokList.append( tt_id );
- tokList.append( tt_andFSM );
- tokList.append( tt_id );
- tokList.append( tt_semi );
- cout << tokList.parse() << endl;
-}
-
-void test1()
-{
- TokList tokList;
- tokList.append( tt_id );
- tokList.append( tt_equals );
- tokList.append( tt_open );
- tokList.append( tt_orFSM );
- tokList.append( tt_minus );
- tokList.append( tt_andFSM );
- tokList.append( tt_close );
- tokList.append( tt_star );
- tokList.append( tt_semi );
- cout << tokList.parse() << endl;
-}
-void test2()
-{
- TokList tokList;
- tokList.append( tt_id );
- tokList.append( tt_equals );
- tokList.append( tt_not );
- tokList.append( tt_open );
- tokList.append( tt_orFSM );
- tokList.append( tt_minus );
- tokList.append( tt_not );
- tokList.append( tt_andFSM );
- tokList.append( tt_close );
- tokList.append( tt_star );
- tokList.append( tt_semi );
- cout << tokList.parse() << endl;
-}
-void test3()
-{
- TokList tokList;
- tokList.append( tt_id );
- tokList.append( tt_equals );
- tokList.append( tt_id );
- tokList.append( tt_colon );
- tokList.append( tt_minus );
- tokList.append( tt_number );
- tokList.append( tt_id );
- tokList.append( tt_colon );
- tokList.append( tt_id );
- tokList.append( tt_id );
- tokList.append( tt_dollar );
- tokList.append( tt_plus );
- tokList.append( tt_number );
- tokList.append( tt_id );
- tokList.append( tt_percent );
- tokList.append( tt_minus );
- tokList.append( tt_number );
- tokList.append( tt_semi );
- cout << tokList.parse() << endl;
-}
-void test4()
-{
- TokList tokList;
- tokList.append( tt_id );
- tokList.append( tt_equals );
- tokList.append( tt_id );
- tokList.append( tt_pipe );
- tokList.append( tt_id );
- tokList.append( tt_amp );
- tokList.append( tt_id );
- tokList.append( tt_minus );
- tokList.append( tt_id );
- tokList.append( tt_semi );
- cout << tokList.parse() << endl;
-}
-
-int main()
-{
- test0();
- test1();
- test2();
- test3();
- test4();
-}
-
-##### OUTPUT #####
-F = tt_id;
-K = F tt_star;
-N = K;
-T = N;
-E = T;
-F = tt_andFSM;
-K = F;
-N = K;
-T = N;
-F = tt_id;
-K = F;
-N = K;
-T = T tt_dot N;
-E = E tt_minus T;
-A = tt_id tt_equals E tt_semi;
-M = A;
-F = tt_id;
-K = F;
-N = K;
-T = N;
-F = tt_andFSM;
-K = F;
-N = K;
-T = T N;
-F = tt_id;
-K = F;
-N = K;
-T = T N;
-E = T;
-A = tt_id tt_equals E tt_semi;
-M = M A;
-start = M;
-1
-F = tt_orFSM;
-K = F;
-N = K;
-T = N;
-E = T;
-F = tt_andFSM;
-K = F;
-N = K;
-T = N;
-E = E tt_minus T;
-F = tt_open E tt_close;
-K = F tt_star;
-N = K;
-T = N;
-E = T;
-A = tt_id tt_equals E tt_semi;
-M = A;
-start = M;
-1
-F = tt_orFSM;
-K = F;
-N = K;
-T = N;
-E = T;
-F = tt_andFSM;
-K = tt_not F;
-N = K;
-T = N;
-E = E tt_minus T;
-F = tt_open E tt_close;
-K = tt_not F tt_star;
-N = K;
-T = N;
-E = T;
-A = tt_id tt_equals E tt_semi;
-M = A;
-start = M;
-1
-F = tt_id;
-K = F;
-N = K;
-N = N tt_colon tt_minus tt_number;
-T = N;
-F = tt_id;
-K = F;
-N = K;
-N = N tt_colon tt_id;
-T = T N;
-F = tt_id;
-K = F;
-N = K;
-N = N tt_dollar tt_plus tt_number;
-T = T N;
-F = tt_id;
-K = F;
-N = K;
-N = N tt_percent tt_minus tt_number;
-T = T N;
-E = T;
-A = tt_id tt_equals E tt_semi;
-M = A;
-start = M;
-1
-F = tt_id;
-K = F;
-N = K;
-T = N;
-E = T;
-F = tt_id;
-K = F;
-N = K;
-T = N;
-E = E tt_pipe T;
-F = tt_id;
-K = F;
-N = K;
-T = N;
-E = E tt_amp T;
-F = tt_id;
-K = F;
-N = K;
-T = N;
-E = E tt_minus T;
-A = tt_id tt_equals E tt_semi;
-M = A;
-start = M;
-1
diff --git a/test/ragel.d/lmgoto.rl b/test/ragel.d/lmgoto.rl
deleted file mode 100644
index 53284f41..00000000
--- a/test/ragel.d/lmgoto.rl
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * @LANG: c++
- */
-
-#include <iostream>
-#include <string.h>
-using namespace std;
-
-#define TK_Dlit 192
-#define TK_Slit 193
-#define TK_Float 194
-#define TK_Id 195
-#define TK_NameSep 197
-#define TK_Arrow 211
-#define TK_PlusPlus 212
-#define TK_MinusMinus 213
-#define TK_ArrowStar 214
-#define TK_DotStar 215
-#define TK_ShiftLeft 216
-#define TK_ShiftRight 217
-#define TK_IntegerDecimal 218
-#define TK_IntegerOctal 219
-#define TK_IntegerHex 220
-#define TK_EqualsEquals 223
-#define TK_NotEquals 224
-#define TK_AndAnd 225
-#define TK_OrOr 226
-#define TK_MultAssign 227
-#define TK_DivAssign 228
-#define TK_PercentAssign 229
-#define TK_PlusAssign 230
-#define TK_MinusAssign 231
-#define TK_AmpAssign 232
-#define TK_CaretAssign 233
-#define TK_BarAssign 234
-#define TK_DotDotDot 240
-#define TK_Whitespace 241
-#define TK_Comment 242
-
-struct Scanner
-{
- int cs, act;
- const char *ts, *te;
- bool isCxx;
-
- void token( int tok );
- void run( const char *buf );
-};
-
-
-%%{
- machine Scanner;
-
- # Process all comments, relies on isCxx being set.
- comment := |*
- '*/' {
- if ( ! isCxx )
- fgoto main;
- else {
- cout << "comm char: " << ts[0] << endl;
- cout << "comm char: " << ts[1] << endl;
- }
- };
-
- '\n' {
- if ( isCxx )
- fgoto main;
- else
- cout << "comm char: " << ts[0] << endl;
- };
-
- any {
- cout << "comm char: " << ts[0] << endl;
- };
- *|;
-
- main := |*
-
- # Single and double literals.
- ( 'L'? "'" ( [^'\\\n] | /\\./ )* "'" ) { token( TK_Slit );};
- ( 'L'? '"' ( [^"\\\n] | /\\./ )* '"' ) { token( TK_Dlit );};
-
- # Identifiers
- ( [a-zA-Z_] [a-zA-Z0-9_]* ) { token( TK_Id ); };
-
- # Floating literals.
- fract_const = digit* '.' digit+ | digit+ '.';
- exponent = [eE] [+\-]? digit+;
- float_suffix = [flFL];
-
- ( fract_const exponent? float_suffix? |
- digit+ exponent float_suffix? ) { token( TK_Float );};
-
- # Integer decimal. Leading part buffered by float.
- ( ( '0' | [1-9] [0-9]* ) [ulUL]{0,3} ) { token( TK_IntegerDecimal );};
-
- # Integer octal. Leading part buffered by float.
- ( '0' [0-9]+ [ulUL]{0,2} ) { token( TK_IntegerOctal );};
-
- # Integer hex. Leading 0 buffered by float.
- ( '0' ( 'x' [0-9a-fA-F]+ [ulUL]{0,2} ) ) { token( TK_IntegerHex );};
-
- # Only buffer the second item, first buffered by symbol. */
- '::' {token( TK_NameSep );};
- '==' {token( TK_EqualsEquals );};
- '!=' {token( TK_NotEquals );};
- '&&' {token( TK_AndAnd );};
- '||' {token( TK_OrOr );};
- '*=' {token( TK_MultAssign );};
- '/=' {token( TK_DivAssign );};
- '%=' {token( TK_PercentAssign );};
- '+=' {token( TK_PlusAssign );};
- '-=' {token( TK_MinusAssign );};
- '&=' {token( TK_AmpAssign );};
- '^=' {token( TK_CaretAssign );};
- '|=' {token( TK_BarAssign );};
- '++' {token( TK_PlusPlus );};
- '--' {token( TK_MinusMinus );};
- '->' {token( TK_Arrow );};
- '->*' {token( TK_ArrowStar );};
- '.*' {token( TK_DotStar );};
-
- # Three char compounds, first item already buffered. */
- '...' { token( TK_DotDotDot );};
-
- # Single char symbols.
- ( punct - [_"'] ) { token( ts[0] );};
-
- # Comments and whitespace. Handle these outside of the machine so that se
- # don't end up buffering the comments.
- '/*' { isCxx = false; fgoto comment; };
- '//' { isCxx = true; fgoto comment; };
-
- ( any - 33..126 )+ { token( TK_Whitespace );};
-
- *|;
-}%%
-
-%% write data nofinal;
-
-void Scanner::token( int tok )
-{
- const char *data = ts;
- int len = te - ts;
- cout << "<" << tok << "> ";
- if ( data != 0 ) {
- for ( int i = 0; i < len; i++ )
- cout << data[i];
- }
- cout << '\n';
-}
-
-void Scanner::run( const char *buf )
-{
- int len = strlen( buf );
- %% write init;
- const char *p = buf;
- const char *pe = buf + len;
- const char *eof = pe;
- %% write exec;
-
- if ( cs == Scanner_error ) {
- /* Machine failed before finding a token. */
- cout << "PARSE ERROR" << endl;
- }
-}
-
-int main()
-{
- Scanner scanner;
- scanner.run(
- "//hello*/\n"
- "/*hi there*/ hello 0x88"
- );
- return 0;
-}
-
-##### OUTPUT #####
-comm char: h
-comm char: e
-comm char: l
-comm char: l
-comm char: o
-comm char: *
-comm char: /
-comm char: h
-comm char: i
-comm char:
-comm char: t
-comm char: h
-comm char: e
-comm char: r
-comm char: e
-<241>
-<195> hello
-<241>
-<220> 0x88
diff --git a/test/ragel.d/lmnfa1.rl b/test/ragel.d/lmnfa1.rl
deleted file mode 100644
index d5ec87ec..00000000
--- a/test/ragel.d/lmnfa1.rl
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * @LANG: indep
- * @NEEDS_EOF: yes
- */
-
-ptr ts;
-ptr te;
-%%{
- machine lmnfa1;
-
- main := :nfa |*
- "hello" %when {false} => { print_str "hello --fail\n"; };
- "hello" => { print_str "hello\n"; };
- [a-z]+ %when {false} => { print_str "other --fail\n"; };
- [a-z]+ => { print_str "other\n"; };
- ' ' => { print_str "<space>\n"; };
- *|;
-}%%
-
-##### INPUT #####
-"hello hellos hello"
-##### OUTPUT #####
-hello
-<space>
-other
-<space>
-hello
-ACCEPT
diff --git a/test/ragel.d/mailbox1.h b/test/ragel.d/mailbox1.h
deleted file mode 100644
index b6833569..00000000
--- a/test/ragel.d/mailbox1.h
+++ /dev/null
@@ -1,33 +0,0 @@
-#ifndef _MAILBOX1_H
-#define _MAILBOX1_H
-
-#include <stdio.h>
-#include <string.h>
-#include "buffer.h"
-
-struct MBox
-{
- int cs;
-
- Buffer headName;
- Buffer headContent;
-
- // Initialize the machine. Invokes any init statement blocks. Returns 0
- // if the machine begins in a non-accepting state and 1 if the machine
- // begins in an accepting state.
- void init( );
-
- // Execute the machine on a block of data. Returns -1 if after processing
- // the data, the machine is in the error state and can never accept, 0 if
- // the machine is in a non-accepting state and 1 if the machine is in an
- // accepting state.
- void execute( const char *data, int len );
-
- // Indicate that there is no more data. Returns -1 if the machine finishes
- // in the error state and does not accept, 0 if the machine finishes
- // in any other non-accepting state and 1 if the machine finishes in an
- // accepting state.
- int finish( );
-};
-
-#endif
diff --git a/test/ragel.d/mailbox1.rl b/test/ragel.d/mailbox1.rl
deleted file mode 100644
index 3b0a6de3..00000000
--- a/test/ragel.d/mailbox1.rl
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * @LANG: c++
- *
- * Test works with split code gen.
- */
-
-/*
- * Parses unix mail boxes into headers and bodies.
- */
-
-#include "mailbox1.h"
-
-#ifdef PERF_TEST
-
-/* Calibrated to 1s on yoho. */
-#define perf_iters ( 134408ll * S )
-
-int _perf_dummy = 0;
-#define perf_printf(...) ( _perf_dummy += 1 )
-#define perf_loop long _pi; for ( _pi = 0; _pi < perf_iters; _pi++ )
-
-#else
-
-#define perf_printf(...) printf( __VA_ARGS__ )
-#define perf_loop
-
-#endif
-
-%%{
- machine MBox;
-
- # Buffer the header names.
- action bufHeadName { headName.append(fc); }
-
- # Buffer the header content.
- action bufHeadContent { headContent.append(fc); }
-
- # Terminate a header. If it is an interesting header then prints it.
- action finBufHeadContent {
- /* Terminate the buffers. */
- headName.append(0);
- headContent.append(0);
-
- /* Print the header. Interesting headers. */
- perf_printf("%s:%s\n", headName.data, headContent.data);
-
- /* Clear for the next time we use them. */
- headName.clear();
- headContent.clear();
- }
-
- action msgstart{
- perf_printf("NEW MESSAGE\n");
- }
-
- # Prints a blank line after the end of the headers of each message.
- action blankLine {
- perf_printf("\n");
- }
-
- # Helpers we will use in matching the date section of the from line.
- day = /[A-Z][a-z][a-z]/;
- month = /[A-Z][a-z][a-z]/;
- year = /[0-9][0-9][0-9][0-9]/;
- time = /[0-9][0-9]:[0-9][0-9]/ . ( /:[0-9][0-9]/ | '' );
- letterZone = /[A-Z][A-Z][A-Z]/;
- numZone = /[+\-][0-9][0-9][0-9][0-9]/;
- zone = letterZone | numZone;
- dayNum = /[0-9 ][0-9]/;
-
- # These are the different formats of the date minus an obscure
- # type that has a funny string 'remote from xxx' on the end. Taken
- # from c-client in the imap-2000 distribution.
- date = day . ' ' . month . ' ' . dayNum . ' ' . time . ' ' .
- ( year | year . ' ' . zone | zone . ' ' . year );
-
- # Note the priority assignment on the end of the from line. While we
- # matching the body of a message we may enter into this machine. We will
- # not leave the body of the previous message until this entire from line is
- # matched.
- fromLine = 'From ' . /[^\n]/* . ' ' . date . '\n' @(new_msg,1) @msgstart;
-
- # The types of characters that can be used as a header name.
- hchar = print - [ :];
-
- header =
- # The name of the header.
- hchar+ $bufHeadName . ':'
- # The content of the header. Look out for continuations.
- . ( (extend - '\n') $bufHeadContent | '\n'. [ \t] @bufHeadContent )*
- # Buffer must end with a newline that does not continue.
- . '\n' %finBufHeadContent;
-
- messageLine = ( extend - '\n' )* . '\n' @(new_msg, 0);
-
- # When we get to the last newline we are still matching messageLine
- # so on the last newline it will think we are still in the message.
- # We need this because we can't assume that every newline means
- # the end of the current message, whereas at the same time we requre
- # that there be a newline before the fromLine of the next message.
- message = ( fromLine . header* . '\n' @blankLine . messageLine* . '\n' );
-
- # Its important that the priority in the fromLine gets bumped up
- # so that we are able to move to new messages. Otherwise we
- # will always stay in the message body of the first message.
- main := message*;
-}%%
-
-%% write data;
-
-void MBox::execute( const char *data, int len )
-{
- perf_loop
- {
- const char *p = data;
- const char *pe = data + len;
- %%{
- access this->;
- write init;
- write exec;
- }%%
- }
-}
-
-int MBox::finish( )
-{
- if ( cs == MBox_error )
- return -1;
- if ( cs >= MBox_first_final )
- return 1;
- return 0;
-}
-
-MBox mbox;
-
-void test( const char *buf )
-{
- int len = strlen( buf );
- mbox.execute( buf, len );
- if ( mbox.finish() > 0 ) {
- perf_printf("ACCEPT\n");
- }
- else {
- perf_printf("FAIL\n");
- }
-}
-
-
-int main()
-{
- test(
- "From email address goes here Wed Nov 28 13:30:05 2001 -0500\n"
- "Header1: this is the header contents\n"
- " there is more on the second line\n"
- " and more on the third line.\n"
- "Header2: slkdj\n"
- "\n"
- "This is the message data\n"
- "\n"
- "From email Wed Nov 28 13:30:05 2001 -0500\n"
- "Header: \n"
- "\n"
- "mail message\n"
- "\n"
- );
-
- test(
- "From user@host.dom Wed Nov 28 13:30:05 2001\n"
- "\n"
- "There are no headers. \n"
- "\n"
- "From email Wed Nov 28 13:30:05 EST 2000\n"
- "\n"
- "There are no headers.\n"
- "\n"
- );
-
- test(
- "From user@host.dom Wed Nov 28 13:30:05 2001\n"
- "Header:alsdj\n"
- "\n"
- "Header:\n"
- "salkfj\n"
- "\n"
- "There are no headers. \n"
- "\n"
- );
-
- test(
- "From user@host.dom Wed Nov 28 13:30:05 2001\n"
- "Header:alsdj\n"
- "\n"
- "Header:\n"
- "salkfj\n"
- "\n"
- "There are no headers. \n"
- "\n"
- ">From user@host.dom Wed Nov 28 13:30:05 2001\n"
- "\n"
- );
-
- test(
- "From user@host.dom Wed Nov 28 13:30:05 2001\n"
- "Header:alsdj\n"
- "\n"
- "Header:\n"
- "salkfj\n"
- "\n"
- "There are no headers. \n"
- "\n"
- "From user@host.dom Wed Nov 28 13:30:05 2001\n"
- "\n"
- );
-
- test(
- "From user@host.dom Wed Nov 28 13:30:05 2001\n"
- "Header:alsdj\n"
- "\n"
- "Header:\n"
- "salkfj\n"
- "\n"
- "There are no headers. \n"
- "\n"
- "From user@host.dom Wed Nov 28 13:30:05 2001\n"
- "\n"
- "\n"
- );
-
- return 0;
-}
-
-##### OUTPUT #####
-NEW MESSAGE
-Header1: this is the header contents there is more on the second line and more on the third line.
-Header2: slkdj
-
-NEW MESSAGE
-Header:
-
-ACCEPT
-NEW MESSAGE
-
-NEW MESSAGE
-
-ACCEPT
-NEW MESSAGE
-Header:alsdj
-
-ACCEPT
-NEW MESSAGE
-Header:alsdj
-
-ACCEPT
-NEW MESSAGE
-Header:alsdj
-
-NEW MESSAGE
-
-FAIL
-NEW MESSAGE
-Header:alsdj
-
-NEW MESSAGE
-
-ACCEPT
diff --git a/test/ragel.d/mailbox2.rl b/test/ragel.d/mailbox2.rl
deleted file mode 100644
index 6b9d7359..00000000
--- a/test/ragel.d/mailbox2.rl
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * @LANG: c++
- */
-
-#include <iostream>
-#include <string.h>
-
-using std::cin;
-using std::cout;
-using std::cerr;
-using std::endl;
-
-%%{
- machine mailbox;
-
- action prn_char { cout << *p; }
- action prn_space { cout << ' '; }
- action prn_word { cout.write(ws, p-ws); cout << ' '; }
- action prn_addr1 { cout << "| "; cout.write(ws+1, p-ws-2); }
- action prn_addr2 { cout << "| "; cout.write(ws, p-ws); }
- action prn_tab { cout << '\t'; }
- action prn_nl { cout << '\n'; }
- action prn_separator { cout << "------\n"; }
- action prn_from { cout << "FROM\n"; }
- action prn_to { cout << "TO\n"; }
- action prn_subj { cout << "SUBJECT\n"; }
-
- action start_word { ws = p; }
- action start_headers { }
- action end_headers { }
-
- day = upper lower{2};
- month = upper lower{2};
- year = digit{4};
- time = digit{2} ':' digit{2}
- ( ':' digit{2} )?;
- letterZone = upper{3};
- numZone = [+\-] digit{4};
- zone = letterZone | numZone;
- dayNum = ( digit | ' ' ) digit;
-
- date = day ' ' month ' '
- dayNum ' ' time ' '
- (
- year |
- year ' ' zone |
- zone ' ' year
- );
-
- fromLine = 'From ' [^\n]* ' '
- date '\n' @start_headers;
-
- headerChar = print - [ :];
- headersToPrint = 'From' |
- 'To' | 'Subject';
- headersToConsume =
- headerChar+ - headersToPrint;
-
- consumeHeader =
- headersToConsume ':'
- (
- [^\n] |
- ( '\n' [ \t] )
- )*
- '\n';
-
- addrWS = ( [ \t]+ | '\n' [ \t]+ );
- addrComment = '(' [^)]* ')';
- addrWord = [^"'@,<>() \t\n]+;
- addrAddr1 = '<' [^>]* '>';
- addrAddr2 = addrWord '@' addrWord;
- addrString =
- '"' [^"]* '"' |
- "'" [^']* "'";
-
- addrItem = (
- addrAddr1 %prn_addr1 |
- addrAddr2 %prn_addr2 |
- addrWord %prn_word |
- addrString %prn_word
- ) >start_word;
-
- address = (
- addrWS |
- addrComment |
- addrItem
- )** >prn_tab;
-
- addrHeader = (
- 'From' %prn_from |
- 'To' %prn_to
- ) ':'
- address ( ',' @prn_nl address )*
- '\n' %prn_nl;
-
- subjectHeader =
- 'Subject:' @prn_subj @prn_tab
- ' '* <:
- (
- [^\n] @prn_char |
- ( '\n' [ \t]+ ) %prn_space
- )**
- '\n' %prn_nl;
-
- header = consumeHeader |
- addrHeader | subjectHeader;
-
- messageLine =
- ( [^\n]* '\n' - fromLine );
-
- main := (
- fromLine %prn_separator
- header*
- '\n' @end_headers
- messageLine*
- )*;
- }%%
-
-%% write data;
-
-#define BUFSIZE 8192
-
-void test( const char *buf )
-{
- int cs, len = strlen( buf );
- const char *ws = 0;
-
- %% write init;
- const char *p = buf;
- const char *pe = p + len;
- %% write exec;
-
- if ( cs == mailbox_error )
- cerr << "ERROR" << endl;
-
- if ( cs < mailbox_first_final )
- cerr << "DID NOT FINISH IN A FINAL STATE" << endl;
-}
-
-int main()
-{
- test(
- "From user@host.com Wed Nov 28 13:30:05 2001\n"
- "From: \"Adrian D. Thurston\" <thurston@complang.org>\n"
- "Subject: the squirrel has landed\n"
- "\n"
- "Message goes here. \n"
- "From (trick from line).\n"
- "From: not really a header\n"
- "\n"
- "From user2@host2.com Wed Nov 28 13:30:05 2001\n"
- "To: Edgar Allen Poe <ep@net.com> (da man)\n"
- "Subject: (no subject) \n"
- "\n"
- "Message goes here. \n"
- "\n"
- );
- return 0;
-}
-
-##### OUTPUT #####
-------
-FROM
- "Adrian D. Thurston" | thurston@complang.org
-SUBJECT
- the squirrel has landed
-------
-TO
- Edgar Allen Poe | ep@net.com
-SUBJECT
- (no subject)
diff --git a/test/ragel.d/mailbox3.rl b/test/ragel.d/mailbox3.rl
deleted file mode 100644
index 892dc513..00000000
--- a/test/ragel.d/mailbox3.rl
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * @LANG: c++
- */
-
-#include <iostream>
-#include <string.h>
-
-using std::cin;
-using std::cout;
-using std::cerr;
-using std::endl;
-
-%%{
- machine mailbox;
-
- action prn_char { cout << *p; }
- action prn_space { cout << ' '; }
- action prn_word { cout.write(ws, p-ws); cout << ' '; }
- action prn_addr1 { cout << "| "; cout.write(ws+1, p-ws-2); }
- action prn_addr2 { cout << "| "; cout.write(ws, p-ws); }
- action prn_tab { cout << '\t'; }
- action prn_nl { cout << '\n'; }
- action prn_separator { cout << "------\n"; }
- action prn_from { cout << "FROM\n"; }
- action prn_to { cout << "TO\n"; }
- action prn_subj { cout << "SUBJECT\n"; }
-
- action start_word { ws = p; }
- action start_headers { /*preserve = p;*/ }
- action end_headers { /*preserve = 0;*/ }
-
- day = upper lower{2};
- month = upper lower{2};
- year = digit{4};
- time = digit{2} ':' digit{2}
- ( ':' digit{2} )?;
- letterZone = upper{3};
- numZone = [+\-] digit{4};
- zone = letterZone | numZone;
- dayNum = ( digit | ' ' ) digit;
-
- date = day ' ' month ' '
- dayNum ' ' time ' '
- (
- year |
- year ' ' zone |
- zone ' ' year
- );
-
- fromLine = 'From ' [^\n]* ' '
- date '\n' @start_headers;
-
- headerChar = print - [ :];
- headersToPrint = 'From' |
- 'To' | 'Subject';
- headersToConsume =
- headerChar+ - headersToPrint;
-
- action init_hlen {hlen = 0;}
- action hlen {hlen++ < 50}
-
- consumeHeaderBody =
- ':' @init_hlen
- (
- [^\n] |
- ( '\n' [ \t] )
- )* when hlen
- '\n';
-
- consumeHeader =
- headersToConsume consumeHeaderBody;
-
- addrWS = ( [ \t]+ | '\n' [ \t]+ );
- addrComment = '(' [^)]* ')';
- addrWord = [^"'@,<>() \t\n]+;
- addrAddr1 = '<' [^>]* '>';
- addrAddr2 = addrWord '@' addrWord;
- addrString =
- '"' [^"]* '"' |
- "'" [^']* "'";
-
- addrItem = (
- addrAddr1 %prn_addr1 |
- addrAddr2 %prn_addr2 |
- addrWord %prn_word |
- addrString %prn_word
- ) >start_word;
-
- address = (
- addrWS |
- addrComment |
- addrItem
- )** >prn_tab;
-
- addrHeader = (
- 'From' %prn_from |
- 'To' %prn_to
- ) ':' @init_hlen
- ( address ( ',' @prn_nl address )* ) when hlen
- '\n' %prn_nl;
-
- subjectHeader =
- 'Subject:' @prn_subj @prn_tab @init_hlen
- (
- ' '* <:
- (
- [^\n] @prn_char |
- ( '\n' [ \t]+ ) %prn_space
- )**
- ) when hlen
- '\n' %prn_nl;
-
- header = consumeHeader |
- addrHeader | subjectHeader;
-
- messageLine =
- ( [^\n]* when hlen '\n' @init_hlen ) - fromLine;
-
- main := (
- fromLine %prn_separator
- header*
- '\n' @end_headers @init_hlen
- messageLine*
- )*;
- }%%
-
-%% write data;
-
-#define BUFSIZE 8192
-
-void test( const char *buf )
-{
- int cs, len = strlen( buf );
- const char /**preserve = 0,*/ *ws = 0;
- int hlen = 0;
-
- %% write init;
- const char *p = buf;
- const char *pe = p + len;
- %% write exec;
-
- if ( cs < mailbox_first_final ) {
- cout << endl << endl;
- cout << "DID NOT FINISH IN A FINAL STATE" << endl;
- }
-}
-
-int main()
-{
- test(
- "From user@host.com Wed Nov 28 13:30:05 2001\n"
- "From: \"Adrian D. Thurston\" <thurston@complang.org>\n"
- "Subject: the squirrel has landed\n"
- "\n"
- "Message goes here. \n"
- "From (trick from line).\n"
- "From: not really a header\n"
- "\n"
- "From user2@host2.com Wed Nov 28 13:30:05 2001\n"
- "To: \"(kill 1)\" Edgar Allen Poe <ep@net.com> (da man)\n"
- "Subject: (no subject) this is a really long subject which should fail the length constraint \n"
- "Other: 0123456789\n"
- "\n"
- "Message goes here. \n"
- "\n"
- );
- test(
- "From user@host.com Wed Nov 28 13:30:05 2001\n"
- "To: \"(kill 2)\" some guy <sg@net.com>\n"
- "From: \"Adrian D. Thurston this name is far too long\" <thurston@complang.org>\n"
- "Subject: the squirrel has landed\n"
- "\n"
- "From user2@host2.com Wed Nov 28 13:30:05 2001\n"
- "To: Edgar Allen Poe <ep@net.com> (da man)\n"
- "Subject: (no subject) \n"
- "\n"
- );
- test(
- "From user@host.com Wed Nov 28 13:30:05 2001\n"
- "To: \"(kill 3)\" some guy <sg@net.com>\n"
- "From: \"Adrian D. Thurston This name is fore sure absolutely too long\" <t@cs.ca>\n"
- "Subject: the squirrel has landed\n"
- "\n"
- );
- test(
- "From user@host.com Wed Nov 28 13:30:05 2001\n"
- "From: \"Adrian D. Thurston \" <t@cs.ca>\n"
- "Subject: (kill 4) the squirrel has landed\n"
- "Other: This is another header field, not interpreted, that is too long\n"
- "\n"
- );
- test(
- "From user@host.com Wed Nov 28 13:30:05 2001\n"
- "From: \"Adrian D. Thurston \" <t@cs.ca>\n"
- "Subject: (kill 5)the squirrel has landed\n"
- "\n"
- "This message line is okay.\n"
- "But this message line is far too long and will cause an error.\n"
- );
- return 0;
-}
-
-##### OUTPUT #####
-------
-FROM
- "Adrian D. Thurston" | thurston@complang.org
-SUBJECT
- the squirrel has landed
-------
-TO
- "(kill 1)" Edgar Allen Poe | ep@net.com
-SUBJECT
- (no subject) this is a really long subject whic
-
-DID NOT FINISH IN A FINAL STATE
-------
-TO
- "(kill 2)" some guy | sg@net.com
-FROM
- "Adrian D. Thurston this name is far too long"
-
-DID NOT FINISH IN A FINAL STATE
-------
-TO
- "(kill 3)" some guy | sg@net.com
-FROM
-
-
-DID NOT FINISH IN A FINAL STATE
-------
-FROM
- "Adrian D. Thurston " | t@cs.ca
-SUBJECT
- (kill 4) the squirrel has landed
-
-
-DID NOT FINISH IN A FINAL STATE
-------
-FROM
- "Adrian D. Thurston " | t@cs.ca
-SUBJECT
- (kill 5)the squirrel has landed
-
-
-DID NOT FINISH IN A FINAL STATE
diff --git a/test/ragel.d/main.c b/test/ragel.d/main.c
deleted file mode 100644
index 7d3b0824..00000000
--- a/test/ragel.d/main.c
+++ /dev/null
@@ -1,16 +0,0 @@
-#include <colm/colm.h>
-
-extern struct colm_sections trans_object;
-
-int main( int argc, const char **argv )
-{
- struct colm_program *prg;
- int exit_status;
-
- prg = colm_new_program( &trans_object );
- colm_set_debug( prg, 0 );
- colm_run_program( prg, argc, argv );
- exit_status = colm_delete_program( prg );
- return exit_status;
-}
-
diff --git a/test/ragel.d/minimize1.rl b/test/ragel.d/minimize1.rl
deleted file mode 100644
index 0cb47368..00000000
--- a/test/ragel.d/minimize1.rl
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stdio.h>
-#include <string.h>
-
-struct min
-{
- int cs;
-};
-
-%%{
- machine min;
- variable cs fsm->cs;
-
- action a_or_b { printf("a or b\n"); }
-
- main := (
- ( 'a' . [ab]* @a_or_b ) |
- ( 'b' . [ab]* @a_or_b )
- ) . '\n';
-}%%
-
-%% write data;
-
-void min_init( struct min *fsm )
-{
- %% write init;
-}
-
-void min_execute( struct min *fsm, const char *_data, int _len )
-{
- const char *p = _data;
- const char *pe = _data+_len;
-
- %% write exec;
-}
-
-int min_finish( struct min *fsm )
-{
- if ( fsm->cs == min_error )
- return -1;
- if ( fsm->cs >= min_first_final )
- return 1;
- return 0;
-}
-
-struct min fsm;
-
-void test( char *buf )
-{
- int len = strlen( buf );
- min_init( &fsm );
- min_execute( &fsm, buf, len );
- if ( min_finish( &fsm ) > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
-}
-
-
-int main()
-{
- test( "aaaaaa\n" );
- test( "a\n" );
- test( "abc\n" );
- return 0;
-}
-
-##### OUTPUT #####
-a or b
-a or b
-a or b
-a or b
-a or b
-ACCEPT
-ACCEPT
-a or b
-FAIL
diff --git a/test/ragel.d/ncall1.rl b/test/ragel.d/ncall1.rl
deleted file mode 100644
index 9268ad31..00000000
--- a/test/ragel.d/ncall1.rl
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * @LANG: indep
- */
-
-int top;
-int stack[32];
-
-int target;
-
-%%{
- machine ncall1;
-
- unused := 'unused';
-
- one := 'one' @{
- print_str "one\n";
- fnret;
- };
-
- two := 'two' @{
- print_str "two\n";
- fnret;
- };
-
- main := (
- '1' @{ target = fentry(one); fncall *target; }
- | '2' @{ target = fentry(two); fncall *target; }
- | '\n'
- )*;
-}%%
-
-##### INPUT #####
-"1one2two1one\n"
-##### OUTPUT #####
-one
-two
-one
-ACCEPT
diff --git a/test/ragel.d/next1.rl b/test/ragel.d/next1.rl
deleted file mode 100644
index 6b53f510..00000000
--- a/test/ragel.d/next1.rl
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * @LANG: indep
- */
-
-int target;
-
-%%{
- machine next1;
-
- unused := 'unused';
-
- one := 'one' @{
- print_str "one\n";
- target = fentry(main);
- fnext *target;
- };
-
- two := 'two' @{
- print_str "two\n";
- target = fentry(main);
- fnext *target;
- };
-
- main :=
- '1' @{ target = fentry(one); fnext *target; }
- | '2' @{ target = fentry(two); fnext *target; }
- | '\n';
-}%%
-
-##### INPUT #####
-"1one2two1one\n"
-##### OUTPUT #####
-one
-two
-one
-ACCEPT
diff --git a/test/ragel.d/next2.rl b/test/ragel.d/next2.rl
deleted file mode 100644
index 9f8ffe2a..00000000
--- a/test/ragel.d/next2.rl
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * @LANG: indep
- */
-
-int target;
-int last;
-
-%%{
- machine next2;
-
- unused := 'unused';
-
- one := 'one' @{
- print_str "one\n";
- target = fentry(main);
- fnext *target;
- };
-
- two := 'two' @{
- print_str "two\n";
- target = fentry(main);
- fnext *target;
- };
-
- three := 'three' @{
- print_str "three\n";
- target = fentry(main);
- fnext *target;
- };
-
- main := (
- '1' @{
- target = fentry(one);
- fnext *target;
- last = 1;
- } |
-
- '2' @{
- target = fentry(two);
- fnext *target;
- last = 2;
- } |
-
- # This one is conditional based on the last.
- '3' @{
- if ( last == 2 ) {
- target = fentry(three);
- fnext *target;
- }
-
- last = 3;
- } 'x' |
-
- '\n'
- )*;
-}%%
-
-##### INPUT #####
-"1one3x2two3three\n"
-##### OUTPUT #####
-one
-two
-three
-ACCEPT
diff --git a/test/ragel.d/nfa1.rl b/test/ragel.d/nfa1.rl
deleted file mode 100644
index 284f1228..00000000
--- a/test/ragel.d/nfa1.rl
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * @LANG: c
- * @FILTER: LC_ALL=C sort
- */
-
-#include <string.h>
-#include <stdio.h>
-
-int neg ;
-long value ;
-
-struct nfa_bp_rec
-{
- long state;
- char *p;
- int pop;
-};
-
-struct nfa_bp_rec nfa_bp[1024];
-long nfa_len = 0;
-long nfa_count = 0;
-
-%%{
- machine atoi;
-
- action begin {neg = 0;
- value = 0;
- }
-
- action see_neg {
- neg = 1;
- }
-
- action add_digit {
- value = value * 10 + ( int ) ( fc - 48 );
- }
-
- action finish {
- if ( neg ) { value = -1 * value; }
- }
-
- action print1 {
- printf( "%ld", value );
- printf( "%s", "\n" );
- fnext *atoi_error;
- }
-
- action print2 {
- printf( "saw 80808080\n" );
- fnext *atoi_error;
- }
-
- atoi = (
- ('-'@see_neg | '+')? (digit @add_digit)+
- ) >begin %finish;
-
- main1 = atoi '\n' @print1;
- main2 = [0-9]* '00000000' [0-9]* '\n' @print2;
-
- main |= (5, 0) main1 | main2;
-}%%
-
-%% write data;
-int cs;
-int blen;
-char buffer[1024];
-
-void init()
-{
- value = 0;
- neg = 0;
- %% write init;
-}
-
-void exec( char *data, int len )
-{
- char *p = data;
- char *pe = data + len;
- char *eof = pe;
- %% write exec;
-}
-
-void finish( )
-{
- if ( cs >= atoi_first_final )
- printf( "-> accept\n\n" );
- else
- printf( "-> fail\n\n" );
-}
-
-char *inp[] = {
- "1\n",
- "12\n",
- "1002000000002\n",
- "222222\n",
- "+2123\n",
- "-12321\n",
- "-99\n",
- "213 3213\n",
- "--123\n",
- " -3000\n",
-};
-
-int inplen = 10;
-
-int main( )
-{
- int i;
- for ( i = 0; i < inplen; i++ ) {
- init();
- exec( inp[i], strlen(inp[i]) );
- finish();
- }
- return 0;
-}
-
-##### OUTPUT #####
-
-
-
-
-
-
-
-
-
-
--12321
--99
--> fail
--> fail
--> fail
--> fail
--> fail
--> fail
--> fail
--> fail
--> fail
--> fail
-1
-1002000000002
-12
-2123
-222222
-saw 80808080
diff --git a/test/ragel.d/nfa2.rl b/test/ragel.d/nfa2.rl
deleted file mode 100644
index b2da6542..00000000
--- a/test/ragel.d/nfa2.rl
+++ /dev/null
@@ -1,296 +0,0 @@
-#
-# @LANG: asm
-# @FILTER: LC_ALL=C sort
-#
-
-%%{
- machine AtoI;
-
- action begin {
- # neg = 0;
- # val = 0;
- movl $0, neg(%rip)
- movq $0, val(%rip)
- }
-
- action see_neg {
- # neg = 1;
- movl $1, neg(%rip)
- }
-
- action add_digit {
- # val = val * 10 + (fc - 48);
- movq val(%rip), %rax
- imul $10, %rax
- movsbq (%r12), %rcx
- subq $48, %rcx
- add %rcx, %rax
- movq %rax, val(%rip)
- }
-
- action finish {
- #if (neg)
- #{
- # val = - 1 * val;
- #}
-
- movl neg(%rip), %eax
- cmpl $0, %eax
- je .finish_L
- movq val(%rip), %rax
- negq %rax
- movq %rax, val(%rip)
- .finish_L:
- }
-
- action print1 {
- #printf ("%ld", val);
- #fputs ("\n", stdout);
- movl $.L_fmt_i_nl, %edi
- movq val(%rip), %rsi
- movl $0, %eax
- call printf
- }
-
- action print2 {
- movl $.L_saw, %edi
- call puts
- }
-
- atoi =
- (('-' @ see_neg | '+') ?
- (digit @ add_digit) +) > begin %finish;
-
- # Using the expectation of the second newline to trigger backtracking.
- main1 = atoi '\n' @print1 '\n';
- main2 = [0-9]* '00000000' [0-9]* '\n' @print2 'X';
-
- main |= (5, 0) main1 | main2;
-
-}%%
- .file "tmp.c"
- .comm neg,4,4
- .comm val,8,8
- .comm cs,4,4
- .section .rodata
-
-%% write data;
-
-.L_fmt_i_nl:
- .string "%ld\n"
-.L_marker:
- .string "marker\n"
-.L_saw:
- .string "saw 80808080"
-
- .text
- .globl init
- .type init, @function
-init:
-.LFB0:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- movq $0, val(%rip)
- movl $0, neg(%rip)
-
-%% write init;
-
- movq %r11, cs(%rip)
-
- popq %rbp
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE0:
- .size init, .-init
- .section .rodata
-.LC0:
- .string "%i"
- .text
- .globl exec
- .type exec, @function
-exec:
-.LFB1:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- subq $96, %rsp
-
- pushq %r12
- pushq %r13
-
- movq nfa_bp@GOTPCREL(%rip), %rax
- movq %rax, -80(%rbp)
- movq $0, -88(%rbp)
-
- movq cs(%rip), %r11
- movq %rdi, %r12
- movq %rsi, %r13
-
-%% write exec;
-
- movq %r11, cs(%rip)
-
- popq %r13
- popq %r12
-
-.LRET:
- leave
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE1:
- .size exec, .-exec
- .section .rodata
-.LC1:
- .string "-> ACCEPT"
-.LC2:
- .string "-> FAIL"
- .text
- .globl finish
- .type finish, @function
-finish:
-.LFB2:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- movq cs@GOTPCREL (%rip), %rdx
- movl (%rdx), %edx
- movl $4, %eax
- cmpl %eax, %edx
- jl .L36
- movl $.LC1, %edi
-# call puts
- jmp .L35
-.L36:
- movl $.LC2, %edi
- call puts
-.L35:
- popq %rbp
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE2:
- .size finish, .-finish
- .globl inp
-
- .section .rodata
-.LC3:
- .string "1\n\n"
-.LC4:
- .string "12\n\n"
-.LC45:
- .string "1002000000002\nX",
-.LC5:
- .string "222222\n\n"
-.LC6:
- .string "+2123\n\n"
-.LC7:
- .string "-99\n\n"
-.LC8:
- .string "-12321\n\n"
-.LC9:
- .string "213 3213\n\n"
-.LC10:
- .string "--123\n\n"
-.LC11:
- .string " -3000\n\n"
- .data
- .align 32
- .type inp, @object
- .size inp, 72
-inp:
- .quad .LC3
- .quad .LC4
- .quad .LC45
- .quad .LC5
- .quad .LC6
- .quad .LC7
- .quad .LC8
- .quad .LC9
- .quad .LC10
- .quad .LC11
- .globl inplen
- .align 4
- .type inplen, @object
- .size inplen, 4
-inplen:
- .long 10
- .text
- .globl main
- .type main, @function
-main:
-.LFB3:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- subq $16, %rsp
- movl $0, -4(%rbp)
- jmp .L39
-.L40:
- movl $0, %eax
- call init
- movl -4(%rbp), %eax
- cltq
- movq inp(,%rax,8), %rax
- movq %rax, %rdi
- call strlen
- movl %eax, %edx
- movl -4(%rbp), %eax
- cltq
- movq inp(,%rax,8), %rax
- movslq %edx, %rsi
- addq %rax, %rsi
- movq %rax, %rdi
- call exec
- movl $0, %eax
- call finish
- addl $1, -4(%rbp)
-.L39:
- movl inplen(%rip), %eax
- cmpl %eax, -4(%rbp)
- jl .L40
- movl $0, %eax
- leave
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE3:
- .size main, .-main
-
- .bss
- .align 16
- .type nfa_len, @object
- .size nfa_len, 8
-nfa_len:
- .zero 8
- .comm nfa_bp,16384,32
-
- .ident "GCC: (Ubuntu 4.8.2-19ubuntu1) 4.8.2"
- .section .note.GNU-stack,"",@progbits
-
-##### OUTPUT #####
--12321
--99
--> FAIL
--> FAIL
--> FAIL
-1
-1002000000002
-12
-2123
-222222
-saw 80808080
diff --git a/test/ragel.d/nfa3.rl b/test/ragel.d/nfa3.rl
deleted file mode 100644
index 597fba57..00000000
--- a/test/ragel.d/nfa3.rl
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stddef.h>
-#include <stdint.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-#include <stdio.h>
-
-const char s[4096];
-
-struct nfa_stack
-{
- void *data;
- unsigned long sz;
-};
-
-struct nfa_bp_rec
-{
- long state;
- const char *p;
- long popTrans;
- long q_2;
-};
-
-%%{
- machine atoi;
-
- action a {a}
- action b {b}
-
- action psh { nfa_bp[nfa_len].q_2 = q_2; }
- action pop { ({ q_2 = nfa_bp[nfa_len].q_2; 1; }) }
- action ini { ({ q_2 = 0; 1; }) }
- action stay { ({ 1; }) }
- action repeat { ({ ++q_2 < 2; }) }
- action exit { ({ ++q_2 >= 2; }) }
-
- main :=
- (
- ( 'a' %when a %when b)
- |
- ( 'a' %when a )
- )
-
- :nfa( ( '.' ), psh, pop, ini, stay, repeat, exit ):
-
- ';'
- @{ printf( " --> MATCH\n" ); };
-}%%
-
-%% write data;
-
-int test( const char *p, bool a, bool b )
-{
- int len = strlen( p ) + 1;
- const char *pe = p + len;
- const char *eof = pe;
- int cs;
-
- struct nfa_bp_rec *nfa_bp = (struct nfa_bp_rec*) s;
- long nfa_len = 0;
- long nfa_count = 0;
-
- long q_2 = 0;
-
- printf( "testing: %s %d %d\n", p, a, b );
-
- %%{
- write init;
- write exec;
- }%%
-
- return 0;
-}
-
-int main()
-{
- test( "a.;", 0, 0 );
- test( "a.;", 0, 1 );
- test( "a.;", 1, 0 );
- test( "a.;", 1, 1 );
- test( "a..;", 0, 0 );
- test( "a..;", 0, 1 );
- test( "a..;", 1, 0 );
- test( "a..;", 1, 1 );
- test( "a...;", 0, 0 );
- test( "a...;", 0, 1 );
- test( "a...;", 1, 0 );
- test( "a...;", 1, 1 );
- return 0;
-}
-
-##### OUTPUT #####
-testing: a.; 0 0
-testing: a.; 0 1
-testing: a.; 1 0
-testing: a.; 1 1
-testing: a..; 0 0
-testing: a..; 0 1
-testing: a..; 1 0
- --> MATCH
-testing: a..; 1 1
- --> MATCH
-testing: a...; 0 0
-testing: a...; 0 1
-testing: a...; 1 0
-testing: a...; 1 1
diff --git a/test/ragel.d/noignore.rl b/test/ragel.d/noignore.rl
deleted file mode 100644
index a25ae49a..00000000
--- a/test/ragel.d/noignore.rl
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * @LANG: c
- *
- * Tests the no-ignore property following ragel section close. Can't be
- * garbling up whitespace or ragel comments( C defines ).
- */
-
-#include <string.h>
-#include <stdio.h>
-
-%%{
- machine atoi;
-
- main := 'hello\n' @{ printf( "hello\n" ); };
-}%%
-
-#define DEF 1
-
-%% write data;
-
-int cs;
-int blen;
-char buffer[1024];
-
-void init()
-{
- %% write init;
-}
-
-void exec( char *data, int len )
-{
- char *p = data;
- char *pe = data + len;
- %% write exec;
-}
-
-void finish( )
-{
- if ( cs >= atoi_first_final )
- printf( "ACCEPT\n" );
- else
- printf( "FAIL\n" );
-}
-
-char *inp[] = {
- "hello\n",
-};
-
-int inplen = 1;
-
-int main( )
-{
-#ifndef DEF
- printf("DEF not defined -- noignore problem\n" );
-#else
- int i;
- for ( i = 0; i < inplen; i++ ) {
- init();
- exec( inp[i], strlen(inp[i]) );
- finish();
- }
-#endif
- return 0;
-}
-
-##### OUTPUT #####
-hello
-ACCEPT
diff --git a/test/ragel.d/patact.rl b/test/ragel.d/patact.rl
deleted file mode 100644
index a10ec3ad..00000000
--- a/test/ragel.d/patact.rl
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * @LANG: indep
- * @PROHIBIT_LANGUAGES: cv ruby ocaml rust crack
- * @NEEDS_EOF: yes
- */
-
-char comm;
-int top;
-int stack[32];
-ptr ts;
-ptr te;
-int act;
-int value;
-
-%%{
- machine patact;
-
- other := |*
- [a-z]+ => { print_str "word\n"; };
- [0-9]+ => { print_str "num\n"; };
- [\n ] => { print_str "space\n"; };
- *|;
-
- exec_test := |*
- [a-z]+ => { print_str "word (w/lbh)\n"; fexec te-1; fgoto other; };
- [a-z]+ ' foil' => { print_str "word (c/lbh)\n"; };
- [\n ] => { print_str "space\n"; };
- '22' => { print_str "num (w/switch)\n"; };
- [0-9]+ => { print_str "num (w/switch)\n"; fexec te-1; fgoto other;};
- [0-9]+ ' foil' => {print_str "num (c/switch)\n"; };
- '!';# => { print_str "immdiate\n"; fgoto exec_test; };
- *|;
-
- semi := |*
- ';' => { print_str "in semi\n"; fgoto main; };
- *|;
-
- main := |*
- [a-z]+ => { print_str "word (w/lbh)\n"; fhold; fgoto other; };
- [a-z]+ ' foil' => { print_str "word (c/lbh)\n"; };
- [\n ] => { print_str "space\n"; };
- '22' => { print_str "num (w/switch)\n"; };
- [0-9]+ => { print_str "num (w/switch)\n"; fhold; fgoto other;};
- [0-9]+ ' foil' => {print_str "num (c/switch)\n"; };
- ';' => { print_str "going to semi\n"; fhold; fgoto semi;};
- '!' => { print_str "immdiate\n"; fgoto exec_test; };
- *|;
-}%%
-
-##### INPUT #####
-"abcd foix\n"
-"abcd\nanother\n"
-"123 foix\n"
-"!abcd foix\n"
-"!abcd\nanother\n"
-"!123 foix\n"
-";"
-##### OUTPUT #####
-word (w/lbh)
-word
-space
-word
-space
-ACCEPT
-word (w/lbh)
-word
-space
-word
-space
-ACCEPT
-num (w/switch)
-num
-space
-word
-space
-ACCEPT
-immdiate
-word (w/lbh)
-word
-space
-word
-space
-ACCEPT
-immdiate
-word (w/lbh)
-word
-space
-word
-space
-ACCEPT
-immdiate
-num (w/switch)
-num
-space
-word
-space
-ACCEPT
-going to semi
-in semi
-ACCEPT
diff --git a/test/ragel.d/perftest b/test/ragel.d/perftest
deleted file mode 100644
index d782bb28..00000000
--- a/test/ragel.d/perftest
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/bash
-#
-
-set -e
-
-ragel1=$1
-ragel2=$2
-targ_time=$3
-shift 3
-
-cases="$@"
-if test -z "$cases"; then
- cases="mailbox1 strings1 strings2 rlscan cppscan1"
-fi
-
-CFLAGS="-O3 -Wall -Wno-unused-but-set-variable -Wno-unused-variable"
-
-tc()
-{
- ragel=$1
- compiler=$2
- seconds=$3
- root=$4
-
- $ragel -F1 -o $root.cpp $root.rl
- $compiler $CFLAGS -DPERF_TEST -I../aapl -DS=${seconds}ll -o $root.bin $root.cpp
- ( time ./$root.bin ) 2>&1 | \
- awk '/user/ { split( $2, a, "[ms]" ); printf( "%.3f\n", a[1] * 60 + a[2] ); }'
-}
-
-for c in $cases; do
- time1=`tc $ragel1 g++ $targ_time $c`
- time2=`tc $ragel2 g++ $targ_time $c`
- speedup=`awk "BEGIN { printf( \"%.5f\n\", $time1 / $time2 ); }"`
-
- echo -e "$c\t$time1 -> $time2\t$speedup" | expand -12,30
-done
-
diff --git a/test/ragel.d/range.rl b/test/ragel.d/range.rl
deleted file mode 100644
index 6c75b4c7..00000000
--- a/test/ragel.d/range.rl
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <stdio.h>
-#include <string.h>
-
-struct range
-{
- int cs;
-};
-
-%%{
- machine range;
- variable cs fsm->cs;
-
- main := ( 'a' .. 'c' | 'c' .. 'e' | 'm' .. 'n' | 'a' .. 'z' ) '\n';
-}%%
-
-%% write data;
-
-void range_init( struct range *fsm )
-{
- %% write init;
-}
-
-void range_execute( struct range *fsm, const char *_data, int _len )
-{
- const char *p = _data;
- const char *pe = _data+_len;
-
- %% write exec;
-}
-
-int range_finish( struct range *fsm )
-{
- if ( fsm->cs == range_error )
- return -1;
- if ( fsm->cs >= range_first_final )
- return 1;
- return 0;
-}
-
-struct range fsm;
-
-void test( char *buf )
-{
- int len = strlen( buf );
- range_init( &fsm );
- range_execute( &fsm, buf, len );
- if ( range_finish( &fsm ) > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
-}
-
-int main()
-{
- test( "a\n" );
- test( "z\n" );
- test( "g\n" );
- test( "no\n" );
- test( "1\n" );
-
- return 0;
-}
-
-##### OUTPUT #####
-ACCEPT
-ACCEPT
-ACCEPT
-FAIL
-FAIL
diff --git a/test/ragel.d/rangei.rl b/test/ragel.d/rangei.rl
deleted file mode 100644
index 1b523556..00000000
--- a/test/ragel.d/rangei.rl
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * @LANG: indep
- */
-%%{
- machine rangei;
-
- main :=
- 'a' ../i 'z' .
- 'A' ../i 'Z' .
- 60 ../i 93 .
- 94 ../i 125 .
- 86 ../i 101 .
- 60 ../i 125
- '';
-}%%
-
-##### INPUT #####
-"AaBbAa"
-"Aa`bAa"
-"AaB@Aa"
-"AaBbMa"
-"AaBbma"
-##### OUTPUT #####
-ACCEPT
-FAIL
-FAIL
-FAIL
-FAIL
diff --git a/test/ragel.d/recdescent1.rl b/test/ragel.d/recdescent1.rl
deleted file mode 100644
index ab8ccb10..00000000
--- a/test/ragel.d/recdescent1.rl
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * @LANG: c
- * @PROHIBIT_FLAGS: --var-backend
- *
- * Test growable stack.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-%%{
- machine recdescent;
-
- prepush {
- if ( top == stack_size ) {
- printf( "growing stack\n" );
- stack_size = top * 2;
- stack = (int*)realloc( stack, sizeof(int)*stack_size );
- }
- }
-
- postpop {
- if ( stack_size > (top * 4) ) {
- stack_size = top * 2;
- stack = (int*)realloc( stack, sizeof(int)*stack_size );
- printf( "shrinking stack\n" );
- }
- }
-
- action item_start { item = p; }
-
- action item_finish
- {
- printf( "item: " );
- fwrite( item, 1, p-item, stdout );
- printf( "\n" );
- }
-
- action call_main
- {
- printf( "calling main\n" );
- fcall main;
- }
-
- action return_main
- {
- if ( top == 0 ) {
- printf( "STRAY CLOSE\n" );
- fbreak;
- }
-
- printf( "returning from main\n" );
- fhold;
- fret;
- }
-
- id = [a-zA-Z_]+;
- number = [0-9]+;
- ws = [ \t\n]+;
-
- main := (
- ws |
- ( number | id ) >item_start %item_finish |
-
- '{' @call_main '}' |
-
- '}' @return_main
- )**;
-}%%
-
-%% write data;
-
-void test( char *buf )
-{
- int cs;
- int *stack;
- int top, stack_size;
- char *p, *pe, *eof, *item = 0;
-
- int len = strlen( buf );
-
- %% write init;
-
- stack_size = 1;
- stack = (int*)malloc( sizeof(int) * stack_size );
-
- p = buf;
- pe = buf + len;
- eof = pe;
-
- %% write exec;
-
- if ( cs == recdescent_error ) {
- /* Machine failed before finding a token. */
- printf( "PARSE ERROR\n" );
- }
-}
-
-int main()
-{
- test( "88 foo { 99 {{{{}}}}{ } }");
- test( "76 } sadf");
- return 0;
-}
-
-##### OUTPUT #####
-item: 88
-item: foo
-calling main
-item: 99
-calling main
-growing stack
-calling main
-growing stack
-calling main
-calling main
-growing stack
-returning from main
-returning from main
-returning from main
-returning from main
-shrinking stack
-calling main
-returning from main
-returning from main
-shrinking stack
-item: 76
-STRAY CLOSE
diff --git a/test/ragel.d/recdescent2.rl b/test/ragel.d/recdescent2.rl
deleted file mode 100644
index b27c81f1..00000000
--- a/test/ragel.d/recdescent2.rl
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * @LANG: java
- * @PROHIBIT_FLAGS: --var-backend
- */
-
-class recdescent2
-{
- %%{
- machine recdescent;
-
- prepush {
- if ( top == stack_size ) {
- System.out.print( "growing stack\n" );
- stack_size = top * 2;
- // Don't actually bother to resize here, but we do print messages.
- //stack = (int*)realloc( stack, sizeof(int)*stack_size );
- }
- }
-
- postpop {
- if ( stack_size > (top * 4) ) {
- stack_size = top * 2;
- // Don't actually bother to resize here, but we do print messages.
- //stack = (int*)realloc( stack, sizeof(int)*stack_size );
- System.out.print( "shrinking stack\n" );
- }
- }
-
- action item_start { item = p; }
-
- action item_finish
- {
- String item_data = new String ( data, item, p-item );
- System.out.print( "item: " );
- System.out.print( item_data );
- System.out.print( "\n" );
- }
-
- action call_main
- {
- System.out.print( "calling main\n" );
- fncall main;
- }
-
- action return_main
- {
- if ( top == 0 ) {
- System.out.print( "STRAY CLOSE\n" );
- fnbreak;
- }
- else {
- System.out.print( "returning from main\n" );
- fhold;
- fnret;
- }
- }
-
- id = [a-zA-Z_]+;
- number = [0-9]+;
- ws = [ \t\n]+;
-
- main := (
- ws |
- ( number | id ) >item_start %item_finish |
-
- '{' @call_main '}' |
-
- '}' @return_main
- )**;
- }%%
-
- %% write data;
-
- static void test( char data[] )
- {
- int cs, p = 0, pe = data.length, eof = data.length, item = 0;
- int stack[] = new int[1024];
- int stack_size = 1;
- int top = 0;
-
- %% write init;
- %% write exec;
-
- if ( cs == recdescent_error )
- System.out.println( "SCANNER ERROR" );
- }
-
- public static void main( String args[] )
- {
- test( "88 foo { 99 {{{{}}}}{ } }".toCharArray() );
- test( "76 } sadf".toCharArray() );
- }
-}
-
-##### OUTPUT #####
-item: 88
-item: foo
-calling main
-item: 99
-calling main
-growing stack
-calling main
-growing stack
-calling main
-calling main
-growing stack
-returning from main
-returning from main
-returning from main
-returning from main
-shrinking stack
-calling main
-returning from main
-returning from main
-shrinking stack
-item: 76
-STRAY CLOSE
diff --git a/test/ragel.d/recdescent4.rl b/test/ragel.d/recdescent4.rl
deleted file mode 100644
index 614053d8..00000000
--- a/test/ragel.d/recdescent4.rl
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * @LANG: c
- *
- * Test growable stack.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-%%{
- machine recdescent;
-
- prepush {
- if ( top == stack_size ) {
- printf( "growing stack\n" );
- stack_size = top * 2;
- stack = (int*)realloc( stack, sizeof(int)*stack_size );
- }
- }
-
- postpop {
- if ( stack_size > (top * 4) ) {
- stack_size = top * 2;
- stack = (int*)realloc( stack, sizeof(int)*stack_size );
- printf( "shrinking stack\n" );
- }
- }
-
- action item_start { item = p; }
-
- action item_finish
- {
- printf( "item: " );
- fwrite( item, 1, p-item, stdout );
- printf( "\n" );
- }
-
- action call_main
- {
- printf( "calling main\n" );
- fncall main;
- }
-
- action return_main
- {
- if ( top == 0 ) {
- printf( "STRAY CLOSE\n" );
- fnbreak;
- }
- else {
- printf( "returning from main\n" );
- fhold;
- fnret;
- }
- }
-
- id = [a-zA-Z_]+;
- number = [0-9]+;
- ws = [ \t\n]+;
-
- main := (
- ws |
- ( number | id ) >item_start %item_finish |
-
- '{' @call_main '}' |
-
- '}' @return_main
- )**;
-}%%
-
-%% write data;
-
-void test( char *buf )
-{
- int cs;
- int *stack;
- int top, stack_size;
- char *p, *pe, *eof, *item = 0;
-
- int len = strlen( buf );
-
- %% write init;
-
- stack_size = 1;
- stack = (int*)malloc( sizeof(int) * stack_size );
-
- p = buf;
- pe = buf + len;
- eof = pe;
-
- %% write exec;
-
- if ( cs == recdescent_error ) {
- /* Machine failed before finding a token. */
- printf( "PARSE ERROR\n" );
- }
-}
-
-int main()
-{
- test( "88 foo { 99 {{{{}}}}{ } }");
- test( "76 } sadf");
- return 0;
-}
-
-##### OUTPUT #####
-item: 88
-item: foo
-calling main
-item: 99
-calling main
-growing stack
-calling main
-growing stack
-calling main
-calling main
-growing stack
-returning from main
-returning from main
-returning from main
-returning from main
-shrinking stack
-calling main
-returning from main
-returning from main
-shrinking stack
-item: 76
-STRAY CLOSE
diff --git a/test/ragel.d/recdescent5.rl b/test/ragel.d/recdescent5.rl
deleted file mode 100644
index c6daa86c..00000000
--- a/test/ragel.d/recdescent5.rl
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * @LANG: java
- */
-
-class recdescent5
-{
- %%{
- machine recdescent;
-
- prepush {
- if ( top == stack_size ) {
- System.out.print( "growing stack\n" );
- stack_size = top * 2;
- // Don't actually bother to resize here, but we do print messages.
- //stack = (int*)realloc( stack, sizeof(int)*stack_size );
- }
- }
-
- postpop {
- if ( stack_size > (top * 4) ) {
- stack_size = top * 2;
- // Don't actually bother to resize here, but we do print messages.
- //stack = (int*)realloc( stack, sizeof(int)*stack_size );
- System.out.print( "shrinking stack\n" );
- }
- }
-
- action item_start { item = p; }
-
- action item_finish
- {
- String item_data = new String ( data, item, p-item );
- System.out.print( "item: " );
- System.out.print( item_data );
- System.out.print( "\n" );
- }
-
- action call_main
- {
- System.out.print( "calling main\n" );
- fncall main;
- }
-
- action return_main
- {
- if ( top == 0 ) {
- System.out.print( "STRAY CLOSE\n" );
- fnbreak;
- }
- else {
- System.out.print( "returning from main\n" );
- fhold;
- fnret;
- }
- }
-
- id = [a-zA-Z_]+;
- number = [0-9]+;
- ws = [ \t\n]+;
-
- main := (
- ws |
- ( number | id ) >item_start %item_finish |
-
- '{' @call_main '}' |
-
- '}' @return_main
- )**;
- }%%
-
- %% write data;
-
- static void test( char data[] )
- {
- int cs, p = 0, pe = data.length, eof = data.length, item = 0;
- int stack[] = new int[1024];
- int stack_size = 1;
- int top;
-
- %% write init;
- %% write exec;
-
- if ( cs == recdescent_error )
- System.out.println( "SCANNER ERROR" );
- }
-
- public static void main( String args[] )
- {
- test( "88 foo { 99 {{{{}}}}{ } }".toCharArray() );
- test( "76 } sadf".toCharArray() );
- }
-}
-
-##### OUTPUT #####
-item: 88
-item: foo
-calling main
-item: 99
-calling main
-growing stack
-calling main
-growing stack
-calling main
-calling main
-growing stack
-returning from main
-returning from main
-returning from main
-returning from main
-shrinking stack
-calling main
-returning from main
-returning from main
-shrinking stack
-item: 76
-STRAY CLOSE
diff --git a/test/ragel.d/repetition.rl b/test/ragel.d/repetition.rl
deleted file mode 100644
index 1734af24..00000000
--- a/test/ragel.d/repetition.rl
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * @LANG: c++
- */
-
-/* Test repeptition operators. */
-
-#include <iostream>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-using namespace std;
-
-struct Rep
-{
- int cs;
-
- int init( );
- int execute( const char *data, int len );
- int finish( );
-};
-
-%%{
- machine Rep;
-
- action begin { cout << "begin" << endl; }
- action in { cout << "in" << endl; }
- action end { cout << "end" << endl; }
-
- a = 'a' >begin @in %end;
- b = 'b' >begin @in %end;
- c = 'c' >begin @in %end;
- d = 'd' >begin @in %end;
-
- main :=
- ( a {5} '\n' )* '-\n'
- ( b {,5} '\n' )* '-\n'
- ( c {5,} '\n' )* '-\n'
- ( d {2,5} '\n' )*;
-}%%
-
-%% write data;
-
-int Rep::init( )
-{
- %% write init;
- return 1;
-}
-
-int Rep::execute( const char *_data, int _len )
-{
- const char *p = _data;
- const char *pe = _data+_len;
-
- %% write exec;
-
- if ( cs == Rep_error )
- return -1;
- if ( cs >= Rep_first_final )
- return 1;
- return 0;
-}
-
-int Rep::finish( )
-{
- if ( cs == Rep_error )
- return -1;
- if ( cs >= Rep_first_final )
- return 1;
- return 0;
-}
-
-void test( const char *buf )
-{
- Rep rep;
- int len = strlen( buf );
- rep.init();
- rep.execute( buf, len );
- if ( rep.finish() > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
-}
-
-int main()
-{
- test(
- "aaaaa\n"
- "-\n"
- "\n"
- "b\n"
- "bb\n"
- "bbb\n"
- "bbbb\n"
- "bbbbb\n"
- "-\n"
- "ccccc\n"
- "ccccccc\n"
- "cccccccccc\n"
- "-\n"
- "dd\n"
- "ddd\n"
- "dddd\n"
- "ddddd\n"
- );
-
- test(
- "a\n"
- "-\n"
- "b\n"
- "-\n"
- "c\n"
- "-\n"
- "d\n"
- );
-
- return 0;
-}
-
-##### OUTPUT #####
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-begin
-in
-end
-ACCEPT
-begin
-in
-FAIL
diff --git a/test/ragel.d/rlscan.rl b/test/ragel.d/rlscan.rl
deleted file mode 100644
index ff1f7abc..00000000
--- a/test/ragel.d/rlscan.rl
+++ /dev/null
@@ -1,353 +0,0 @@
-/*
- * Lexes Ragel input files.
- *
- * @LANG: c++
- * @PROHIBIT_FLAGS: --var-backend
- *
- * Test works with split code gen.
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#ifdef PERF_TEST
-
-/* Calibrated to 1s on yoho. */
-#define perf_iters ( 240984ll * S )
-
-int _perf_dummy = 0;
-#define perf_cout(...) ( _perf_dummy += 1 )
-#define perf_loop long _pi; for ( _pi = 0; _pi < perf_iters; _pi++ )
-
-#else
-
-#define perf_cout(...) __VA_ARGS__
-#define perf_loop
-
-#endif
-
-using namespace std;
-
-void escapeXML( const char *data )
-{
- while ( *data != 0 ) {
- switch ( *data ) {
- case '<': perf_cout( cout << "&lt;" ); break;
- case '>': perf_cout( cout << "&gt;" ); break;
- case '&': perf_cout( cout << "&amp;" ); break;
- default: perf_cout( cout << *data ); break;
- }
- data += 1;
- }
-}
-
-void escapeXML( char c )
-{
- switch ( c ) {
- case '<': perf_cout( cout << "&lt;" ); break;
- case '>': perf_cout( cout << "&gt;" ); break;
- case '&': perf_cout( cout << "&amp;" ); break;
- default: perf_cout( cout << c ); break;
- }
-}
-
-void escapeXML( const char *data, int len )
-{
- for ( const char *end = data + len; data != end; data++ ) {
- switch ( *data ) {
- case '<': perf_cout( cout << "&lt;" ); break;
- case '>': perf_cout( cout << "&gt;" ); break;
- case '&': perf_cout( cout << "&amp;" ); break;
- default: perf_cout( cout << *data ); break;
- }
- }
-}
-
-inline void write( const char *data )
-{
- perf_cout( cout << data );
-}
-
-inline void write( char c )
-{
- perf_cout( cout << c );
-}
-
-inline void write( const char *data, int len )
-{
- perf_cout( cout.write( data, len ) );
-}
-
-
-%%{
- machine RagelScan;
-
- word = [a-zA-Z_][a-zA-Z_0-9]*;
- integer = [0-9]+;
- hex = '0x' [0-9a-fA-F] [0-9a-fA-F]*;
-
- default = ^0;
- EOF = 0;
-
- # Handles comments in outside code and inline blocks.
- c_comment :=
- ( default* :>> '*/' )
- ${ escapeXML( fc ); }
- @{ fret; };
-
- action emit {
- escapeXML( ts, te-ts );
- }
-
- #
- # Inline action code
- #
-
- ilscan := |*
-
- "'" ( [^'\\] | /\\./ )* "'" => emit;
- '"' ( [^"\\] | /\\./ )* '"' => emit;
- '/*' {
- write( "/*" );
- fcall c_comment;
- };
- '//' [^\n]* '\n' => emit;
-
- '{' {
- write( '{' );
- inline_depth += 1;
- };
-
- '}' {
- write( '}' );
- /* If dropping down to the last } then return
- * to ragel code. */
- if ( --inline_depth == 0 ) {
- write( "</inline>\n" );
- fgoto rlscan;
- }
- };
-
- default => { escapeXML( *ts ); };
- *|;
-
- #
- # Ragel Tokens
- #
-
- rlscan := |*
- '}%%' {
- if ( !single_line ) {
- write( "</section>\n" );
- fgoto main;
- }
- };
-
- '\n' {
- if ( single_line ) {
- write( "</section>\n" );
- fgoto main;
- }
- };
-
- # Word
- word {
- write( "<word>" );
- write( ts, te-ts );
- write( "</word>\n" );
- };
-
- # Decimal integer.
- integer {
- write( "<int>" );
- write( ts, te-ts );
- write( "</int>\n" );
- };
-
- # Hexidecimal integer.
- hex {
- write( "<hex>" );
- write( ts, te-ts );
- write( "</hex>\n" );
- };
-
- # Consume comments.
- '#' [^\n]* '\n';
-
- # Single literal string.
- "'" ( [^'\\] | /\\./ )* "'" {
- write( "<single_lit>" );
- escapeXML( ts, te-ts );
- write( "</single_lit>\n" );
- };
-
- # Double literal string.
- '"' ( [^"\\] | /\\./ )* '"' {
- write( "<double_lit>" );
- escapeXML( ts, te-ts );
- write( "</double_lit>\n" );
- };
-
- # Or literal.
- '[' ( [^\]\\] | /\\./ )* ']' {
- write( "<or_lit>" );
- escapeXML( ts, te-ts );
- write( "</or_lit>\n" );
- };
-
- # Regex Literal.
- '/' ( [^/\\] | /\\./ ) * '/' {
- write( "<re_lit>" );
- escapeXML( ts, te-ts );
- write( "</re_lit>\n" );
- };
-
- # Open an inline block
- '{' {
- inline_depth = 1;
- write( "<inline>{" );
- fgoto ilscan;
- };
-
- punct {
- write( "<symbol>" );
- escapeXML( fc );
- write( "</symbol>\n" );
- };
-
- default;
- *|;
-
- #
- # Outside code.
- #
-
- main := |*
-
- "'" ( [^'\\] | /\\./ )* "'" => emit;
- '"' ( [^"\\] | /\\./ )* '"' => emit;
-
- '/*' {
- escapeXML( ts, te-ts );
- fcall c_comment;
- };
-
- '//' [^\n]* '\n' => emit;
-
- '%%{' {
- write( "<section>\n" );
- single_line = false;
- fgoto rlscan;
- };
-
- '%%' {
- write( "<section>\n" );
- single_line = true;
- fgoto rlscan;
- };
-
- default {
- escapeXML( *ts );
- };
-
- # EOF.
- EOF;
- *|;
-}%%
-
-%% write data nofinal;
-
-void test( const char *data )
-{
- std::ios::sync_with_stdio(false);
-
- int cs, act;
- perf_loop
- {
- int len = strlen( data );
- const char *ts, *te;
- int stack[1], top;
- memset( stack, 0, sizeof(stack) );
-
- bool single_line = false;
- int inline_depth = 0;
-
- %% write init;
-
- /* Read in a block. */
- const char *p = data;
- const char *pe = data + len;
- const char *eof = pe;
-
- %% write exec;
- }
-
- if ( cs == RagelScan_error ) {
- /* Machine failed before finding a token. */
- perf_cout( cerr << "PARSE ERROR" << endl );
- exit(1);
- }
-}
-
-#define BUFSIZE 2048
-
-int main()
-{
- std::ios::sync_with_stdio(false);
-
- test(
- "hi %%{ /'}%%'/ { /*{*/ {} } + '\\'' }%%there\n"
- "hi %%{ /'}%%'/ { /*{*/ {} } + '\\'' }%%there\n"
- "hi %%{ /'}%%'/ { /*{*/ {} } + '\\'' }%%there\n"
- "hi %%{ /'}%%'/ { /*{*/ {} } + '\\'' }%%there\n"
- "hi %%{ /'}%%'/ { /*{*/ {} } + '\\'' }%%there\n"
- "hi %%{ /'}%%'/ { /*{*/ {} } + '\\'' }%%there\n"
- );
-
- return 0;
-}
-##### OUTPUT #####
-hi <section>
-<re_lit>/'}%%'/</re_lit>
-<inline>{ /*{*/ {} }</inline>
-<symbol>+</symbol>
-<single_lit>'\''</single_lit>
-</section>
-there
-hi <section>
-<re_lit>/'}%%'/</re_lit>
-<inline>{ /*{*/ {} }</inline>
-<symbol>+</symbol>
-<single_lit>'\''</single_lit>
-</section>
-there
-hi <section>
-<re_lit>/'}%%'/</re_lit>
-<inline>{ /*{*/ {} }</inline>
-<symbol>+</symbol>
-<single_lit>'\''</single_lit>
-</section>
-there
-hi <section>
-<re_lit>/'}%%'/</re_lit>
-<inline>{ /*{*/ {} }</inline>
-<symbol>+</symbol>
-<single_lit>'\''</single_lit>
-</section>
-there
-hi <section>
-<re_lit>/'}%%'/</re_lit>
-<inline>{ /*{*/ {} }</inline>
-<symbol>+</symbol>
-<single_lit>'\''</single_lit>
-</section>
-there
-hi <section>
-<re_lit>/'}%%'/</re_lit>
-<inline>{ /*{*/ {} }</inline>
-<symbol>+</symbol>
-<single_lit>'\''</single_lit>
-</section>
-there
diff --git a/test/ragel.d/rpn1.rl b/test/ragel.d/rpn1.rl
deleted file mode 100644
index 4d63daa5..00000000
--- a/test/ragel.d/rpn1.rl
+++ /dev/null
@@ -1,110 +0,0 @@
-(*
- * @LANG: ocaml
- *)
-
-let id x = x
-let fail fmt = Printf.ksprintf failwith fmt
-let pr fmt = Printf.ksprintf print_endline fmt
-
-let failed fmt = Printf.ksprintf (fun s -> prerr_endline s; exit 1) fmt
-let test' show f x y = if f x <> y then failed "FAILED: test %S" (show x)
-let case = ref 0
-let test f x y = incr case; if f x <> y then failed "FAILED: case %d" !case
-let error f x = match try Some (f x) with _ -> None with Some _ -> failed "FAILED: fail %S" x | None -> ()
-
-(*
-// -*-go-*-
-//
-// Reverse Polish Notation Calculator
-// Copyright (c) 2010 J.A. Roberts Tunney
-// MIT License
-//
-// To compile:
-//
-// ragel -Z -G2 -o rpn.go rpn.rl
-// 6g -o rpn.6 rpn.go
-// 6l -o rpn rpn.6
-// ./rpn
-//
-// To show a diagram of your state machine:
-//
-// ragel -V -G2 -p -o rpn.dot rpn.rl
-// dot -Tpng -o rpn.png rpn.dot
-// chrome rpn.png
-//
-*)
-
-%% machine rpn;
-%% write data;
-
-let fail fmt = Printf.ksprintf failwith fmt
-
-let rpn data =
- let (cs, p, pe) = (ref 0, ref 0, ref (String.length data)) in
- let mark = ref 0 in
- let st = Stack.create () in
-
- %%{
- action mark { mark := !p }
- action push { Stack.push (int_of_string (String.sub data !mark (!p - !mark))) st }
- action add { let y = Stack.pop st in let x = Stack.pop st in Stack.push (x + y) st }
- action sub { let y = Stack.pop st in let x = Stack.pop st in Stack.push (x - y) st }
- action mul { let y = Stack.pop st in let x = Stack.pop st in Stack.push (x * y) st }
- action div { let y = Stack.pop st in let x = Stack.pop st in Stack.push (x / y) st }
- action abs { Stack.push (abs (Stack.pop st)) st }
- action abba { Stack.push 666 st }
-
- stuff = digit+ >mark %push
- | '+' @add
- | '-' @sub
- | '*' @mul
- | '/' @div
- | 'abs' %abs
- | 'add' %add
- | 'abba' %abba
- ;
-
- main := ( space | stuff space )* ;
-
- write init;
- write exec;
- }%%
-
- if !cs < rpn_first_final then
- begin
- if !p = !pe then
- fail "unexpected eof"
- else
- fail "error at position %d" !p
- end;
-
- if Stack.is_empty st then
- fail "rpn stack empty on result"
- else
- Stack.pop st
-
-(* ////////////////////////////////////////////////////////////////////// *)
-
-let rpnTests = [
- ("666\n", 666);
- ("666 111\n", 111);
- ("4 3 add\n", 7);
- ("4 3 +\n", 7);
- ("4 3 -\n", 1);
- ("4 3 *\n", 12);
- ("6 2 /\n", 3);
- ("0 3 -\n", -3);
- ("0 3 - abs\n", 3);
- (" 2 2 + 3 - \n", 1);
- ("10 7 3 2 * - +\n", 11);
- ("abba abba add\n", 1332);
-]
-
-let rpnFailTests = [
- ("\n")
-]
-
-let () =
- List.iter (fun (s,x) -> test rpn s x) rpnTests;
- List.iter (fun s -> error rpn s) rpnFailTests
-
diff --git a/test/ragel.d/ruby1.rl b/test/ragel.d/ruby1.rl
deleted file mode 100644
index 8c42cce5..00000000
--- a/test/ragel.d/ruby1.rl
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# @LANG: ruby
-#
-# Test the host language scanning for ruby.
-#
-
-# %%{
-a = 1
-b = /%%\{\}/;
-
-%%{
- machine ruby1;
-
- main := lower+ digit+ '\n' @{
-
- # }
- c = 1
- d = /\}/
- puts "NL"
- };
-}%%
-
-# %%{
-e = 1
-f = /%%\{\}/;
-
-%% write data;
-
-# %%{
-g = 1
-h = /%%\{\}/;
-
-def run_machine( data )
- p = 0;
- pe = data.length
- cs = 0
-
- %% write init;
- %% write exec;
- if cs >= ruby1_first_final
- puts "ACCEPT"
- else
- puts "FAIL"
- end
-end
-
-inp = [
- "abc1231\n",
-]
-
-inp.each { |str| run_machine(str) }
-
-##### OUTPUT #####
-NL
-ACCEPT
diff --git a/test/ragel.d/rust1.rl b/test/ragel.d/rust1.rl
deleted file mode 100644
index 5eac919b..00000000
--- a/test/ragel.d/rust1.rl
+++ /dev/null
@@ -1,39 +0,0 @@
-//
-// @LANG: rust
-//
-
-%%{
- machine atoi;
-
- main := '-'? [0-9]+ '.' @{
- println!( "match" );
- };
-}%%
-
-fn some_fn() -> &'static str { "foo" }
-
-%% write data;
-
-fn m( s: String )
-{
- let data: &[u8] = s.as_bytes();
- let mut p = 0;
- let mut pe = s.len();
- let mut cs: i32 = 0;
-
- %% write init;
- %% write exec;
-}
-
-fn main()
-{
- m( "-99.".to_string() );
- m( "100.".to_string() );
- m( "100x.".to_string() );
- m( "1000.".to_string() );
-}
-
-##### OUTPUT #####
-match
-match
-match
diff --git a/test/ragel.d/scan1.rl b/test/ragel.d/scan1.rl
deleted file mode 100644
index 32db0d8d..00000000
--- a/test/ragel.d/scan1.rl
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * @LANG: indep
- * @PROHIBIT_LANGUAGES: cv ruby ocaml rust crack
- * @NEEDS_EOF: yes
- */
-
-ptr ts;
-ptr te;
-int act;
-int token;
-
-%%{
- machine scanner;
-
- # Warning: changing the patterns or the input string will affect the
- # coverage of the scanner action types.
- main := |*
- 'a' => {
- print_str "on last ";
- if ( p+1 == te ) {
- print_str "yes";
- }
- print_str "\n";
- };
-
- 'b'+ => {
- print_str "on next ";
- if ( p+1 == te ) {
- print_str "yes";
- }
- print_str "\n";
- };
-
- 'c1' 'dxxx'? => {
- print_str "on lag ";
- if ( p+1 == te ) {
- print_str "yes";
- }
- print_str "\n";
- };
-
- 'd1' => {
- print_str "lm switch1 ";
- if ( p+1 == te ) {
- print_str "yes";
- }
- print_str "\n";
- };
- 'd2' => {
- print_str "lm switch2 ";
- if ( p+1 == te ) {
- print_str "yes";
- }
- print_str "\n";
- };
-
- [d0-9]+ '.';
-
- '\n';
- *|;
-}%%
-
-##### INPUT #####
-"abbc1d1d2\n"
-##### OUTPUT #####
-on last yes
-on next yes
-on lag yes
-lm switch1 yes
-lm switch2 yes
-ACCEPT
diff --git a/test/ragel.d/scan2.rl b/test/ragel.d/scan2.rl
deleted file mode 100644
index 167b2c8c..00000000
--- a/test/ragel.d/scan2.rl
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * @LANG: indep
- * @NEEDS_EOF: yes
- */
-ptr ts;
-ptr te;
-int act;
-int token;
-
-%%{
- machine scanner;
-
- # Warning: changing the patterns or the input string will affect the
- # coverage of the scanner action types.
- main := |*
- 'a' => {
- print_str "pat1\n";
- };
-
- [ab]+ . 'c' => {
- print_str "pat2\n";
- };
-
- any => {
- print_str "any\n";
- };
- *|;
-}%%
-
-##### INPUT #####
-"a"
-##### OUTPUT #####
-pat1
-ACCEPT
diff --git a/test/ragel.d/scan3.rl b/test/ragel.d/scan3.rl
deleted file mode 100644
index 80ab4815..00000000
--- a/test/ragel.d/scan3.rl
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * @LANG: indep
- * @NEEDS_EOF: yes
- */
-
-ptr ts;
-ptr te;
-int act;
-int token;
-
-%%{
- machine scanner;
-
- # Warning: changing the patterns or the input string will affect the
- # coverage of the scanner action types.
- main := |*
- 'a' => {
- print_str "pat1\n";
- };
- 'b' => {
- print_str "pat2\n";
- };
- [ab] any* => {
- print_str "pat3\n";
- };
- *|;
-}%%
-
-##### INPUT #####
-"ab89"
-##### OUTPUT #####
-pat3
-ACCEPT
diff --git a/test/ragel.d/scan4.rl b/test/ragel.d/scan4.rl
deleted file mode 100644
index 44f24b16..00000000
--- a/test/ragel.d/scan4.rl
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * @LANG: indep
- * @NEEDS_EOF: yes
- */
-
-ptr ts;
-ptr te;
-int act;
-int token;
-
-%%{
- machine scanner;
-
- # Warning: changing the patterns or the input string will affect the
- # coverage of the scanner action types.
- main := |*
- 'a' => {
- print_str "pat1\n";
- };
-
- [ab]+ . 'c' => {
- print_str "pat2\n";
- };
-
- any;
- *|;
-}%%
-
-##### INPUT #####
-"ba a"
-##### OUTPUT #####
-pat1
-pat1
-ACCEPT
diff --git a/test/ragel.d/scan5.rl b/test/ragel.d/scan5.rl
deleted file mode 100644
index d9abd36e..00000000
--- a/test/ragel.d/scan5.rl
+++ /dev/null
@@ -1,88 +0,0 @@
-(*
- * @LANG: ocaml
- *)
-
-let id x = x
-let fail fmt = Printf.ksprintf failwith fmt
-let pr fmt = Printf.ksprintf print_endline fmt
-
-let failed fmt = Printf.ksprintf (fun s -> prerr_endline s; exit 1) fmt
-let test' show f x y = if f x <> y then failed "FAILED: test %S" (show x)
-let case = ref 0
-let test f x y = incr case; if f x <> y then failed "FAILED: case %d" !case
-let error f x = match try Some (f x) with _ -> None with Some _ -> failed "FAILED: fail %S" x | None -> ()
-
-%%{
- machine scanner;
-
- # Warning: changing the patterns or the input string will affect the
- # coverage of the scanner action types.
- main := |*
- 'a' => {
- print_string "on last ";
- if !p+1 = !te then
- (on_last := !cnt; incr cnt; print_string "yes");
- print_string "\n";
- };
-
- 'b'+ => {
- print_string "on next ";
- if !p+1 = !te then
- ( on_next := !cnt; incr cnt; print_string "yes");
- print_string "\n";
- };
-
- 'c1' 'dxxx'? => {
- print_string "on lag ";
- if !p+1 = !te then
- ( on_lag := !cnt; incr cnt; print_string "yes");
- print_string "\n";
- };
-
- 'd1' => {
- print_string "lm switch1 ";
- if !p+1 = !te then
- (sw1 := !cnt; incr cnt; print_string "yes");
- print_string "\n";
- };
- 'd2' => {
- print_string "lm switch2 ";
- if !p+1 = !te then
- (sw2 := !cnt; incr cnt; print_string "yes");
- print_string "\n";
- };
-
- [d0-9]+ '.';
-
- '\n';
- *|;
-
- write data;
-}%%
-
-let () =
- let ts = ref 0 and te = ref 0 and act = ref 0 in
- let data = "abbc1d1d2\n" in
- let cs = ref 0 in
- let p = ref 0 and pe = ref (String.length data) in
- let eof = ref !pe in
- %% write init;
- let on_last = ref 0 and on_next = ref 0 and on_lag = ref 0 and
- sw1 = ref 0 and sw2 = ref 0 in
- let cnt = ref 1 in
- %% write exec;
- let t = test' (fun x -> string_of_int !x) (!) in
- t on_last 1;
- t on_next 2;
- t on_lag 3;
- t sw1 4;
- t sw2 5;
- t cnt 6;
- ()
-
-##### OUTPUT #####
-on last yes
-on next yes
-on lag yes
-lm switch1 yes
-lm switch2 yes
diff --git a/test/ragel.d/scan6.rl b/test/ragel.d/scan6.rl
deleted file mode 100644
index d841f110..00000000
--- a/test/ragel.d/scan6.rl
+++ /dev/null
@@ -1,62 +0,0 @@
-(*
- * @LANG: ocaml
- *)
-
-let id x = x
-let fail fmt = Printf.ksprintf failwith fmt
-let pr fmt = Printf.ksprintf print_endline fmt
-
-let failed fmt = Printf.ksprintf (fun s -> prerr_endline s; exit 1) fmt
-let test' show f x y = if f x <> y then failed "FAILED: test %S" (show x)
-let case = ref 0
-let test f x y = incr case; if f x <> y then failed "FAILED: case %d" !case
-let error f x = match try Some (f x) with _ -> None with Some _ -> failed "FAILED: fail %S" x | None -> ()
-
-%%{
- machine scanner;
-
- # Warning: changing the patterns or the input string will affect the
- # coverage of the scanner action types.
- main := |*
- 'a' => {
- got `Pat1;
- print_string "got pat1\n";
- };
-
- [ab]+ . 'c' => {
- got `Pat2;
- print_string "got pat2\n";
- };
-
- any => {
- got `Any;
- print_string "got any\n";
- };
- *|;
-
- write data;
-}%%
-
-let fail fmt = Printf.ksprintf failwith fmt
-
-let () =
- let expect = ref [`Pat1; `Any; `Pat2; `Any; `Any; `Any; ] in
- let got z = match !expect with
- | [] -> fail "nothing more expected"
- | x::xs -> expect := xs; if z <> x then fail "mismatch"
- in
- let ts = ref 0 and te = ref 0 and cs = ref 0 and act = ref 0 in
- let data = "araabccde" in
- let p = ref 0 and pe = ref (String.length data) in
- let eof = ref !pe in
- %% write init;
- %% write exec;
- ()
-
-##### OUTPUT #####
-got pat1
-got any
-got pat2
-got any
-got any
-got any
diff --git a/test/ragel.d/scan7.rl b/test/ragel.d/scan7.rl
deleted file mode 100644
index f8ed9a43..00000000
--- a/test/ragel.d/scan7.rl
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * @LANG: c
- */
-
-#include <string.h>
-#include <stdio.h>
-
-/*
- * DEMONSTRATS FAILURE TO CALL LEAVING ACTIONS
- * leave on lag not called
- * leave swith3a not called
- */
-
-char * ts ;
-char * te ;
-int act ;
-int token ;
-
-%%{
- machine scanner;
-
- # Warning: changing the patterns or the input string will affect the
- # coverage of the scanner action types.
- main := |*
- 'a' %{
- printf( "-> leave on last\n" );
- }
- => {
- printf( "%s", "on last " );
- if ( p + 1 == te )
- printf( "%s", "yes" );
- printf( "%s", "\n" );
- };
-
- 'b'+ %{
- printf( "-> leave on next\n" );
- }
- => {
- printf( "%s", "on next " );
- if ( p + 1 == te )
- printf( "%s", "yes" );
- printf( "%s", "\n" );
- };
-
- ( 'c1' 'dxxx'? ) %{
- printf( "-> leave on lag\n" );
- }
- => {
- printf( "%s", "on lag " );
- if ( p + 1 == te )
- printf( "%s", "yes" );
- printf( "%s", "\n" );
- };
-
- 'd1' %{
- printf( "-> leave lm switch1\n" );
- }
- => {
- printf( "%s", "lm switch1 " );
- if ( p + 1 == te )
- printf( "%s", "yes" );
- printf( "%s", "\n" );
- };
- 'd2' %{
- printf( "-> leave lm switch2\n" );
- }
- => {
- printf( "%s", "lm switch2 " );
- if ( p + 1 == te )
- printf( "%s", "yes" );
- printf( "%s", "\n" );
- };
-
- [d0-9]+ '.' @{printf("dot\n");} '+' => { printf( "fake out" ); };
-
- ( 'e1' '...'? ) %{printf("-> leave lm switch3a\n"); } => {printf("lm switch3a\n");};
- ( 'e2' '...'? ) %{printf("-> leave lm switch3b\n"); } => {printf("lm switch3b\n");};
- [e0-9]+ '...' => {printf("lm switch4\n");};
-
- '.' => { printf( ".\n" ); };
- '\n';
- *|;
-}%%
-
-%% write data;
-int cs;
-int blen;
-char buffer[1024];
-
-void init()
-{
- %% write init;
-}
-
-void exec( char *data, int len )
-{
- char *p = data;
- char *pe = data + len;
- char *eof = pe;
- %% write exec;
-}
-
-void finish( )
-{
- if ( cs >= scanner_first_final )
- printf( "ACCEPT\n" );
- else
- printf( "FAIL\n" );
-}
-
-char *inp[] = {
-"abbc1d1d2d1..d2..e1.e2....\n",
-};
-
-int inplen = 1;
-
-int main( )
-{
- int i;
- for ( i = 0; i < inplen; i++ ) {
- init();
- exec( inp[i], strlen(inp[i]) );
- finish();
- }
- return 0;
-}
-
-##### OUTPUT #####
--> leave on last
-on last yes
--> leave on next
-on next yes
-on lag yes
--> leave lm switch1
-dot
-lm switch1 yes
--> leave lm switch2
-dot
-lm switch2 yes
--> leave lm switch1
-dot
-lm switch1 yes
-.
-.
--> leave lm switch2
-dot
-lm switch2 yes
-.
-.
-lm switch3a
-.
--> leave lm switch3b
-lm switch3b
-.
-ACCEPT
diff --git a/test/ragel.d/stateact1.rl b/test/ragel.d/stateact1.rl
deleted file mode 100644
index e5878b7c..00000000
--- a/test/ragel.d/stateact1.rl
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * @LANG: indep
- *
- * Test in and out state actions.
- */
-
-%%{
- machine state_act;
-
- action a1 { print_str "a1\n"; }
- action a2 { print_str "a2\n"; }
- action b1 { print_str "b1\n"; }
- action b2 { print_str "b2\n"; }
- action c1 { print_str "c1\n"; }
- action c2 { print_str "c2\n"; }
- action next_again {fnext again;}
-
- hi = 'hi';
- line = again:
- hi
- >to b1
- >from b2
- '\n'
- >to c1
- >from c2
- @next_again;
-
- main := line*
- >to a1
- >from a2;
-}%%
-
-##### INPUT #####
-
-"hi\nhi\n"
-
-##### OUTPUT #####
-a2
-b2
-c1
-c2
-b1
-b2
-c1
-c2
-b1
-FAIL
diff --git a/test/ragel.d/statechart1.rl b/test/ragel.d/statechart1.rl
deleted file mode 100644
index 1d6c2d27..00000000
--- a/test/ragel.d/statechart1.rl
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * @LANG: c
- */
-
-/*
- * Test in and out state actions.
- */
-
-#include <stdio.h>
-#include <string.h>
-
-struct state_chart
-{
- int cs;
-};
-
-%%{
- machine state_chart;
- variable cs fsm->cs;
-
- action a { printf("a"); }
- action b { printf("b"); }
- action hexa { printf("a"); }
- action hexb { printf("b"); }
-
- hex_a = '0x' '0'* '61' @hexa;
- hex_b = '0x' '0'* '62' @hexb;
-
- a = 'a' @a | hex_a;
- b = 'b' @b | hex_b;
- ws = ' '+;
-
- mach =
- start: (
- a -> st1 |
- b -> st2 |
- zlen -> final
- ),
- st1: (
- a -> st1 |
- ws -> start |
- zlen -> final
- ),
- st2: (
- b -> st2 |
- ws -> start |
- zlen -> final
- );
-
- main := ( mach '\n' )*;
-}%%
-
-%% write data;
-
-void state_chart_init( struct state_chart *fsm )
-{
- %% write init;
-}
-
-void state_chart_execute( struct state_chart *fsm, const char *_data, int _len )
-{
- const char *p = _data;
- const char *pe = _data+_len;
-
- %% write exec;
-}
-
-int state_chart_finish( struct state_chart *fsm )
-{
- if ( fsm->cs == state_chart_error )
- return -1;
- if ( fsm->cs >= state_chart_first_final )
- return 1;
- return 0;
-}
-
-struct state_chart sc;
-
-void test( char *buf )
-{
- int len = strlen( buf );
- state_chart_init( &sc );
- state_chart_execute( &sc, buf, len );
- state_chart_finish( &sc );
- printf("\n");
-}
-
-int main()
-{
- test(
- "aa0x0061aa b\n"
- "bbb0x62b 0x61 0x000062\n"
- );
-
- return 0;
-}
-
-##### OUTPUT #####
-aaaaabbbbbbab
diff --git a/test/ragel.d/strings1.rl b/test/ragel.d/strings1.rl
deleted file mode 100644
index 97b57d34..00000000
--- a/test/ragel.d/strings1.rl
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * @LANG: c
- * @PROHIBIT_FLAGS: -G0 -G1 -G2
- */
-
-#include <string.h>
-#include <stdio.h>
-
-#ifdef PERF_TEST
-
-/* Calibrated to 1s on yoho. */
-#define perf_iters ( 3448275ll * S )
-
-int _perf_dummy = 0;
-#define perf_printf(...) ( _perf_dummy += 1 )
-#define perf_loop long _pi; for ( _pi = 0; _pi < perf_iters; _pi++ )
-
-#else
-
-#define perf_printf(...) printf( __VA_ARGS__ )
-#define perf_loop
-
-#endif
-
-struct strs
-{
- int cs;
-};
-
-%%{
- machine strs;
-
- main :=
- "__gmon_start__\n" |
- "cerr\n" |
- "__cp_push_exception\n" |
- "_DYNAMIC\n" |
- "__rtti_user\n" |
- "__rtti_si\n" |
- "_init\n" |
- "__throw\n" |
- "__deregister_frame_info\n" |
- "terminate__Fv\n" |
- "__builtin_vec_new\n" |
- "_fini\n" |
- "__builtin_vec_delete\n" |
- "_GLOBAL_OFFSET_TABLE_\n" |
- "__nw__FUiPv\n" |
- "__builtin_delete\n" |
- "__builtin_new\n" |
- "cout\n" |
- "__register_frame_info\n" |
- "__eh_alloc\n" |
- "strcpy\n" |
- "stdout\n" |
- "memmove\n" |
- "memcpy\n" |
- "malloc\n" |
- "isatty\n" |
- "strtoul\n" |
- "fprintf\n" |
- "stdin\n" |
- "ferror\n" |
- "strncpy\n" |
- "unlink\n" |
- "strcasecmp\n" |
- "realloc\n" |
- "_IO_getc\n" |
- "fread\n" |
- "memset\n" |
- "__assert_fail\n" |
- "strcmp\n" |
- "stderr\n" |
- "fwrite\n" |
- "exit\n" |
- "fopen\n" |
- "atoi\n" |
- "fileno\n" |
- "_IO_stdin_used\n" |
- "__libc_start_main\n" |
- "strlen\n" |
- "free\n" |
- "_edata\n" |
- "__bss_start\n" |
- "_end\n" |
- "QVhl\n" |
- "BPPh\n" |
- "PHRV\n" |
- "PHRj\n" |
- "PHRj\n" |
- "jphy\n" |
- "jqhy\n" |
- "PHRj\n" |
- "PHRj\n" |
- "LWVS\n" |
- "LWVS\n" |
- "bad_alloc\n" |
- "main\n" |
- "false\n" |
- "help\n" |
- "bad_alloc\n" |
- "bad_alloc\n" |
- "bad_alloc\n" |
- "ascii\n" |
- "extend\n" |
- "alnum\n" |
- "alpha\n" |
- "cntrl\n" |
- "digit\n" |
- "graph\n" |
- "lower\n" |
- "print\n" |
- "punct\n" |
- "space\n" |
- "upper\n" |
- "xdigit\n" |
- "false\n" |
- "bad_alloc\n" |
- "bad_alloc\n" |
- "bad_alloc\n" |
- "TransStruct\n" |
- "StateStruct\n" |
- "Struct\n" |
- "Init\n" |
- "bad_alloc\n" |
- "TransStruct\n" |
- "StateStruct\n" |
- "Struct\n" |
- "Init\n" |
- "Accept\n" |
- "Finish\n" |
- "bad_alloc\n" |
- "Struct\n" |
- "Init\n" |
- "Finish\n" |
- "Accept\n" |
- "bad_alloc\n" |
- "Struct\n" |
- "Init\n" |
- "bad_alloc\n" |
- "Struct\n" |
- "Init\n" |
- "Finish\n" |
- "Accept\n" |
- "bad_alloc\n" |
- "Struct\n" |
- "Init\n" |
- "Finish\n" |
- "Accept";
-}%%
-
-%% write data;
-
-void strs_run( const char *_data, int _len )
-{
- perf_loop
- {
- struct strs fsm;
- const char *p = _data;
- const char *pe = _data + _len;
-
- %% variable cs fsm.cs;
- %% write init;
- %% write exec;
-
- if ( fsm.cs >= strs_first_final ) {
- perf_printf("ACCEPT\n");
- }
- else {
- perf_printf("FAIL\n");
- }
- }
-}
-
-void test( const char *buf )
-{
- int len = strlen( buf );
- strs_run( buf, len );
-}
-
-
-int main()
-{
- test( "stdin\n" );
- test( "bad_alloc\n" );
- test( "_GLOBAL_OFFSET_TABLE_\n" );
- test( "not in\n" );
- test(
- "isatty\n"
- "junk on end.\n"
- );
-
- return 0;
-}
-
-##### OUTPUT #####
-ACCEPT
-ACCEPT
-ACCEPT
-FAIL
-FAIL
diff --git a/test/ragel.d/strings2.h b/test/ragel.d/strings2.h
deleted file mode 100644
index 1cf0ce9a..00000000
--- a/test/ragel.d/strings2.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef _STRINGS1_H
-#define _STRINGS1_H
-
-struct strs
-{
- int cs;
-};
-
-#endif
diff --git a/test/ragel.d/strings2.rl b/test/ragel.d/strings2.rl
deleted file mode 100644
index 97b334e0..00000000
--- a/test/ragel.d/strings2.rl
+++ /dev/null
@@ -1,1369 +0,0 @@
-/*
- * @LANG: c
- * @PROHIBIT_FLAGS: -e -G0 -G1 -G2
- *
- * Test works with split code gen.
- */
-
-#include <string.h>
-#include <stdio.h>
-
-#include "strings2.h"
-
-#ifdef PERF_TEST
-
-/* Calibrated to 1s on yoho. */
-#define perf_iters ( 4081632ll * S )
-
-int _perf_dummy = 0;
-#define perf_printf(...) ( _perf_dummy += 1 )
-#define perf_loop long _pi; for ( _pi = 0; _pi < perf_iters; _pi++ )
-
-#else
-
-#define perf_printf(...) printf( __VA_ARGS__ )
-#define perf_loop
-
-#endif
-
-
-%%{
- machine strs;
- variable cs fsm->cs;
-
- main :=
- "/lib/ld-linux.so.2\n" |
- "libstdc++-libc6.2-2.so.3\n" |
- "cerr\n" |
- "__cp_push_exception\n" |
- "_DYNAMIC\n" |
- "endl__FR7ostream\n" |
- "__ls__7ostreamc\n" |
- "_._9exception\n" |
- "__vt_9bad_alloc\n" |
- "__rtti_user\n" |
- "__ls__7ostreamPFR7ostream_R7ostream\n" |
- "__rtti_si\n" |
- "_init\n" |
- "bad__C3ios\n" |
- "__throw\n" |
- "__ls__7ostreamPCc\n" |
- "__deregister_frame_info\n" |
- "terminate__Fv\n" |
- "__ls__7ostreamb\n" |
- "__ls__7ostreami\n" |
- "__8ofstreamiPCcii\n" |
- "__builtin_vec_new\n" |
- "_fini\n" |
- "__9exception\n" |
- "__builtin_vec_delete\n" |
- "_GLOBAL_OFFSET_TABLE_\n" |
- "__vt_9exception\n" |
- "__nw__FUiPv\n" |
- "_._9bad_alloc\n" |
- "__builtin_delete\n" |
- "__builtin_new\n" |
- "cout\n" |
- "__register_frame_info\n" |
- "__eh_alloc\n" |
- "__gmon_start__\n" |
- "libm.so.6\n" |
- "libc.so.6\n" |
- "strcpy\n" |
- "stdout\n" |
- "memmove\n" |
- "memcpy\n" |
- "malloc\n" |
- "strtoul\n" |
- "fprintf\n" |
- "stdin\n" |
- "ferror\n" |
- "strncpy\n" |
- "strcasecmp\n" |
- "realloc\n" |
- "_IO_getc\n" |
- "fread\n" |
- "memset\n" |
- "clearerr\n" |
- "__assert_fail\n" |
- "strcmp\n" |
- "stderr\n" |
- "fwrite\n" |
- "__errno_location\n" |
- "exit\n" |
- "fopen\n" |
- "atoi\n" |
- "_IO_stdin_used\n" |
- "__libc_start_main\n" |
- "strlen\n" |
- "free\n" |
- "_edata\n" |
- "__bss_start\n" |
- "_end\n" |
- "GLIBC_2.1\n" |
- "GLIBC_2.0\n" |
- "PTRh\n" |
- "QVhL\n" |
- "<WVS\n" |
- "LWVS\n" |
- "PHRW\n" |
- "<WVS\n" |
- "\WVS\n" |
- ",WVS\n" |
- "@Phl\n" |
- "<WVS\n" |
- "jZjA\n" |
- "jzja\n" |
- "j9j0\n" |
- "j9j0\n" |
- "jZjA\n" |
- "jzja\n" |
- "jzja\n" |
- "jZjA\n" |
- "j~j!\n" |
- "j~j \n" |
- "j/j!\n" |
- "j@j:\n" |
- "j`j[\n" |
- "j~j{\n" |
- "j9j0\n" |
- "jFjA\n" |
- "jfja\n" |
- ",WVS\n" |
- ",WVS\n" |
- ";C<|\n" |
- "<WVS\n" |
- "C ;C\n" |
- "C$;C\n" |
- "C$;C\n" |
- "C ;C\n" |
- ",WVS\n" |
- ";E uF\n" |
- "P ;U\n" |
- "P ;U\n" |
- "E$fP\n" |
- "E$fP\n" |
- "E$fP\n" |
- "E$fP\n" |
- "E$fP\n" |
- "E$fP\n" |
- "E$fP\n" |
- "E$fP\n" |
- "u!h@\n" |
- "PHRj\n" |
- "PHRj\n" |
- "P\ U\n" |
- "j]hY\n" |
- "johY\n" |
- "PHRj\n" |
- "PHRj\n" |
- "E fPj\n" |
- "E fP\n" |
- "E fP\n" |
- "E fP\n" |
- "E fP\n" |
- "E fP\n" |
- "E fPj\n" |
- "t$h`\n" |
- "F ;C } \n" |
- "F ;C ~ \n" |
- "@X:BXt)\n" |
- "\WVS\n" |
- "\WVS\n" |
- "PPRS\n" |
- "F ;C } \n" |
- "F ;C ~ \n" |
- "@X:BXt)\n" |
- ";H(}:\n" |
- "@ fP\n" |
- ";P |\n" |
- "<WVS\n" |
- ";P |\n" |
- "bad_alloc\n" |
- "usage: ragel [options] file\n" |
- "general:\n" |
- " -h, -H, -? Disply this usage.\n" |
- " -o <file> Write output to <file>.\n" |
- " -s Print stats on the compiled fsm.\n" |
- " -f Dump the final fsm.\n" |
- "fsm minimization:\n" |
- " -n No minimization (default).\n" |
- " -m Find the minimal fsm accepting the language.\n" |
- "generated code language:\n" |
- " -c Generate c code (default).\n" |
- " -C Generate c++ code.\n" |
- "generated code style:\n" |
- " -T0 Generate a table driven fsm (default).\n" |
- " -T1 Generate a faster table driven fsm.\n" |
- " -S0 Generate a switch driven fsm.\n" |
- " -G0 Generate a goto driven fsm.\n" |
- " -G1 Generate a faster goto driven fsm.\n" |
- " -G2 Generate a really fast goto driven fsm.\n" |
- "char * FileNameFromStem(char *, char *)\n" |
- "main.cpp\n" |
- "len > 0\n" |
- "main\n" |
- "ragel: main graph not defined\n" |
- "graph states: \n" |
- "graph transitions: \n" |
- "machine states: \n" |
- "machine functions: \n" |
- "function array: \n" |
- "T:S:G:Cco:senmabjkfhH?-:\n" |
- "ragel: zero length output file name given\n" |
- "ragel: output file already given\n" |
- "ragel: invalid param specified (try -h for a list of options)\n" |
- "help\n" |
- "ragel: zero length input file name given\n" |
- "ragel: input file already given\n" |
- "ragel: warning: -e given but minimization is not enabled\n" |
- "ragel: no input file (try -h for a list of options)\n" |
- " for reading\n" |
- "ragel: could not open \n" |
- " for writing\n" |
- "ragel: error opening \n" |
- " * Parts of this file are copied from Ragel source covered by the GNU\n" |
- " * GPL. As a special exception, you may use the parts of this file copied\n" |
- " * from Ragel source without restriction. The remainder is derived from\n" |
- "bad_alloc\n" |
- "%s:%i: unterminated literal\n" |
- "%s:%i: unterminated comment\n" |
- "%s:%i: bad character in literal\n" |
- "fatal flex scanner internal error--no action found\n" |
- "fatal flex scanner internal error--end of buffer missed\n" |
- "fatal error - scanner input buffer overflow\n" |
- "input in flex scanner failed\n" |
- "out of dynamic memory in yy_create_buffer()\n" |
- "out of dynamic memory in yy_scan_buffer()\n" |
- "out of dynamic memory in yy_scan_bytes()\n" |
- "bad buffer in yy_scan_bytes()\n" |
- "bad_alloc\n" |
- "%s:%i: warning: range gives null fsm\n" |
- "%s:%i: warning: literal used in range is not of length 1, using 0x%x\n" |
- "%s:%i: warning: overflow in byte constant\n" |
- "parse error\n" |
- "parser stack overflow\n" |
- "%s:%i: %s\n" |
- "bad_alloc\n" |
- "extend\n" |
- "ascii\n" |
- "alpha\n" |
- "digit\n" |
- "alnum\n" |
- "lower\n" |
- "upper\n" |
- "cntrl\n" |
- "graph\n" |
- "print\n" |
- "punct\n" |
- "space\n" |
- "xdigit\n" |
- "struct Fsm * FactorWithAugNode::Walk()\n" |
- "parsetree.cpp\n" |
- "false\n" |
- "bad_alloc\n" |
- "xx []()\n" |
- " df \n" |
- "StartState: \n" |
- "Final States:\n" |
- "void FsmGraph<State,int,Trans>::AttachStates(State *, State *, Trans *, FsmKeyType, int)\n" |
- "rlfsm/fsmattach.cpp\n" |
- "trans->toState == __null\n" |
- "trans->fromState == __null\n" |
- "void FsmGraph<State,int,Trans>::DetachStates(State *, State *, Trans *, FsmKeyType, int)\n" |
- "trans->toState == to\n" |
- "trans->fromState == from\n" |
- "inTel != __null\n" |
- "void Vector<BstMapEl<int,int>,ResizeExpn>::setAs(const Vector<BstMapEl<int,int>,ResizeExpn> &)\n" |
- "aapl/vectcommon.h\n" |
- "&v != this\n" |
- "void FsmGraph<State,int,Trans>::ChangeRangeLowerKey(Trans *, int, int)\n" |
- "inRangeEl != __null\n" |
- "void FsmGraph<State,int,Trans>::IsolateStartState()\n" |
- "rlfsm/fsmgraph.cpp\n" |
- "md.stateDict.nodeCount == 0\n" |
- "md.stfil.listLength == 0\n" |
- "struct State * FsmGraph<State,int,Trans>::DetachState(State *)\n" |
- "fromTel != __null\n" |
- "struct Trans * FsmGraph<State,int,Trans>::AttachStates(State *, State *, FsmKeyType, int, int)\n" |
- "outTel != __null\n" |
- "outTel1 != __null\n" |
- "from->defOutTrans == __null\n" |
- "void FsmGraph<State,int,Trans>::VerifyOutFuncs()\n" |
- "state->outTransFuncTable.tableLength == 0\n" |
- "!state->isOutPriorSet\n" |
- "state->outPriority == 0\n" |
- "void FsmGraph<State,int,Trans>::VerifyIntegrity()\n" |
- "rlfsm/fsmbase.cpp\n" |
- "outIt.trans->fromState == state\n" |
- "inIt.trans->toState == state\n" |
- "static int FsmTrans<State,Trans,int,CmpOrd<int> >::ComparePartPtr(FsmTrans<State,Trans,int,CmpOrd<int> > *, FsmTrans<State,Trans,int,CmpOrd<int> > *)\n" |
- "rlfsm/fsmstate.cpp\n" |
- "false\n" |
- "void FsmGraph<State,int,Trans>::InTransMove(State *, State *)\n" |
- "dest != src\n" |
- "static bool FsmTrans<State,Trans,int,CmpOrd<int> >::ShouldMarkPtr(MarkIndex<State> &, FsmTrans<State,Trans,int,CmpOrd<int> > *, FsmTrans<State,Trans,int,CmpOrd<int> > *)\n" |
- "bad_alloc\n" |
- "10FsmCodeGen\n" |
- "bad_alloc\n" |
- " case \n" |
- "break;}\n" |
- "unsigned char\n" |
- "unsigned short\n" |
- "unsigned int\n" |
- "{0, \n" |
- "/* Forward dec state for the transition structure. */\n" |
- "struct \n" |
- "StateStruct;\n" |
- "/* A single transition. */\n" |
- "struct \n" |
- "TransStruct\n" |
- " struct \n" |
- "StateStruct *toState;\n" |
- " int *funcs;\n" |
- "typedef struct \n" |
- "TransStruct \n" |
- "Trans;\n" |
- "/* A single state. */\n" |
- "struct \n" |
- "StateStruct\n" |
- " int lowIndex;\n" |
- " int highIndex;\n" |
- " void *transIndex;\n" |
- " unsigned int dflIndex;\n" |
- " int *outFuncs;\n" |
- " int isFinState;\n" |
- "typedef struct \n" |
- "StateStruct \n" |
- "State;\n" |
- "/* Only non-static data: current state. */\n" |
- "struct \n" |
- "Struct\n" |
- "State *curState;\n" |
- " int accept;\n" |
- "typedef struct \n" |
- "Struct \n" |
- "/* Init the fsm. */\n" |
- "void \n" |
- "Init( \n" |
- " *fsm );\n" |
- "/* Execute some chunk of data. */\n" |
- "void \n" |
- "Execute( \n" |
- " *fsm, char *data, int dlen );\n" |
- "/* Indicate to the fsm tha there is no more data. */\n" |
- "void \n" |
- "Finish( \n" |
- " *fsm );\n" |
- "/* Did the machine accept? */\n" |
- "int \n" |
- "Accept( \n" |
- " *fsm );\n" |
- "#define f \n" |
- "#define s \n" |
- "#define i \n" |
- "#define t \n" |
- "/* The array of functions. */\n" |
- "#if \n" |
- "static int \n" |
- "_f[] = {\n" |
- "#endif\n" |
- "/* The array of indices into the transition array. */\n" |
- "#if \n" |
- "static \n" |
- "_i[] = {\n" |
- "#endif\n" |
- "/* The aray of states. */\n" |
- "static \n" |
- "State \n" |
- "_s[] = {\n" |
- "/* The array of transitions. */\n" |
- "static \n" |
- "Trans \n" |
- "_t[] = {\n" |
- "/* The start state. */\n" |
- "static \n" |
- "State *\n" |
- "_startState = s+\n" |
- "#undef f\n" |
- "#undef s\n" |
- "#undef i\n" |
- "#undef t\n" |
- "* Execute functions pointed to by funcs until the null function is found. \n" |
- "inline static void \n" |
- "ExecFuncs( \n" |
- " *fsm, int *funcs, char *p )\n" |
- " int len = *funcs++;\n" |
- " while ( len-- > 0 ) {\n" |
- " switch ( *funcs++ ) {\n" |
- " * Init the fsm to a runnable state.\n" |
- "void \n" |
- " *fsm )\n" |
- " fsm->curState = \n" |
- "_startState;\n" |
- " fsm->accept = 0;\n" |
- " * Did the fsm accept? \n" |
- "int \n" |
- " *fsm )\n" |
- " return fsm->accept;\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- " *fsm, char *data, int dlen )\n" |
- " char *p = data;\n" |
- " int len = dlen;\n" |
- "State *cs = fsm->curState;\n" |
- " for ( ; len > 0; p++, len-- ) {\n" |
- " int c = (unsigned char) *p;\n" |
- "Trans *trans;\n" |
- " if ( cs == 0 )\n" |
- " goto finished;\n" |
- " /* If the character is within the index bounds then get the\n" |
- " * transition for it. If it is out of the transition bounds\n" |
- " * we will use the default transition. */\n" |
- " if ( cs->lowIndex <= c && c < cs->highIndex ) {\n" |
- " /* Use the index to look into the transition array. */\n" |
- " trans = \n" |
- "_t + \n" |
- " ((\n" |
- "*)cs->transIndex)[c - cs->lowIndex];\n" |
- " else {\n" |
- " /* Use the default index as the char is out of range. */\n" |
- " trans = \n" |
- "_t + cs->dflIndex;\n" |
- " /* If there are functions for this transition then execute them. */\n" |
- " if ( trans->funcs != 0 )\n" |
- "ExecFuncs( fsm, trans->funcs, p );\n" |
- " /* Move to the new state. */\n" |
- " cs = trans->toState;\n" |
- "finished:\n" |
- " fsm->curState = cs;\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- " *fsm )\n" |
- "State *cs = fsm->curState;\n" |
- " if ( cs != 0 && cs->isFinState ) {\n" |
- " /* If finishing in a final state then execute the\n" |
- " * out functions for it. (if any). */\n" |
- " if ( cs->outFuncs != 0 )\n" |
- "ExecFuncs( fsm, cs->outFuncs, 0 );\n" |
- " fsm->accept = 1;\n" |
- " else {\n" |
- " /* If we are not in a final state then this\n" |
- " * is an error. Move to the error state. */\n" |
- " fsm->curState = 0;\n" |
- "class \n" |
- "public:\n" |
- " /* Forward dec state for the transition structure. */\n" |
- " struct State;\n" |
- " /* A single transition. */\n" |
- " struct Trans\n" |
- " State *toState;\n" |
- " int *funcs;\n" |
- " /* A single state. */\n" |
- " struct State\n" |
- " int lowIndex;\n" |
- " int highIndex;\n" |
- " void *transIndex;\n" |
- " unsigned int dflIndex;\n" |
- " int *outFuncs;\n" |
- " int isFinState;\n" |
- " /* Constructor. */\n" |
- " void Init( );\n" |
- " /* Execute some chunk of data. */\n" |
- " void Execute( char *data, int dlen );\n" |
- " /* Indicate to the fsm tha there is no more data. */\n" |
- " void Finish( );\n" |
- " /* Did the machine accept? */\n" |
- " int Accept( );\n" |
- " State *curState;\n" |
- " int accept;\n" |
- " inline void ExecFuncs( int *funcs, char *p );\n" |
- "/* The array of functions. */\n" |
- "#if \n" |
- "::State \n" |
- "/* The array of trainsitions. */\n" |
- "static \n" |
- "::Trans \n" |
- "/* The start state. */\n" |
- "static \n" |
- "::State *\n" |
- " * Execute functions pointed to by funcs until the null function is found. \n" |
- "inline void \n" |
- "::ExecFuncs( int *funcs, char *p )\n" |
- " int len = *funcs++;\n" |
- " while ( len-- > 0 ) {\n" |
- " switch ( *funcs++ ) {\n" |
- " * Constructor\n" |
- " Init();\n" |
- "Init\n" |
- "void \n" |
- "::Init( )\n" |
- " curState = \n" |
- "_startState;\n" |
- " accept = 0;\n" |
- "::Accept( )\n" |
- " return accept;\n" |
- "::Execute( char *data, int dlen )\n" |
- " char *p = data;\n" |
- " int len = dlen;\n" |
- " State *cs = curState;\n" |
- " for ( ; len > 0; p++, len-- ) {\n" |
- " int c = (unsigned char)*p;\n" |
- " Trans *trans;\n" |
- " if ( cs == 0 )\n" |
- " goto finished;\n" |
- " /* If the character is within the index bounds then get the\n" |
- " * transition for it. If it is out of the transition bounds\n" |
- " * we will use the default transition. */\n" |
- " if ( cs->lowIndex <= c && c < cs->highIndex ) {\n" |
- " /* Use the index to look into the transition array. */\n" |
- " trans = \n" |
- "_t + cs->dflIndex;\n" |
- " /* If there are functions for this transition then execute them. */\n" |
- " if ( trans->funcs != 0 )\n" |
- " ExecFuncs( trans->funcs, p );\n" |
- " /* Move to the new state. */\n" |
- " cs = trans->toState;\n" |
- "finished:\n" |
- " curState = cs;\n" |
- "::Finish( )\n" |
- " State *cs = curState;\n" |
- " if ( cs != 0 && cs->isFinState ) {\n" |
- " /* If finishing in a final state then execute the\n" |
- " * out functions for it. (if any). */\n" |
- " if ( cs->outFuncs != 0 )\n" |
- " ExecFuncs( cs->outFuncs, 0 );\n" |
- " accept = 1;\n" |
- " else {\n" |
- " /* If we are not in a final state then this\n" |
- " * is an error. Move to the error state. */\n" |
- " curState = 0;\n" |
- "10TabCodeGen\n" |
- "11CTabCodeGen\n" |
- "12CCTabCodeGen\n" |
- "10FsmCodeGen\n" |
- "bad_alloc\n" |
- " case \n" |
- " break;\n" |
- "/* Forward dec state for the transition structure. */\n" |
- "struct \n" |
- "StateStruct;\n" |
- "/* A single transition. */\n" |
- "struct \n" |
- "TransStruct\n" |
- " struct \n" |
- "StateStruct *toState;\n" |
- " int funcs;\n" |
- "typedef struct \n" |
- "TransStruct \n" |
- "Trans;\n" |
- "/* A single state. */\n" |
- "struct \n" |
- "StateStruct\n" |
- " int lowIndex;\n" |
- " int highIndex;\n" |
- " void *transIndex;\n" |
- " int dflIndex;\n" |
- " int outFuncs;\n" |
- " int isFinState;\n" |
- "typedef struct \n" |
- "StateStruct \n" |
- "State;\n" |
- "/* Only non-static data: current state. */\n" |
- "struct \n" |
- "Struct\n" |
- "State *curState;\n" |
- " int accept;\n" |
- "typedef struct \n" |
- "Struct \n" |
- "/* Init the fsm. */\n" |
- "void \n" |
- "Init( \n" |
- " *fsm );\n" |
- "/* Execute some chunk of data. */\n" |
- "void \n" |
- "Execute( \n" |
- " *fsm, char *data, int dlen );\n" |
- "/* Indicate to the fsm tha there is no more data. */\n" |
- "void \n" |
- "Finish( \n" |
- " *fsm );\n" |
- "/* Did the machine accept? */\n" |
- "int \n" |
- "Accept( \n" |
- " *fsm );\n" |
- "#define s \n" |
- "#define i \n" |
- "#define t \n" |
- "/* The array of indices into the transition array. */\n" |
- "#if \n" |
- "static \n" |
- "_i[] = {\n" |
- "#endif\n" |
- "/* The aray of states. */\n" |
- "static \n" |
- "State \n" |
- "_s[] = {\n" |
- "/* The array of trainsitions. */\n" |
- "static \n" |
- "Trans \n" |
- "_t[] = {\n" |
- "/* The start state. */\n" |
- "static \n" |
- "State *\n" |
- "_startState = s+\n" |
- "#undef f\n" |
- "#undef s\n" |
- "#undef i\n" |
- "#undef t\n" |
- "/***************************************************************************\n" |
- " * Execute functions pointed to by funcs until the null function is found. \n" |
- "inline static void \n" |
- "ExecFuncs( \n" |
- " *fsm, int funcs, char *p )\n" |
- " switch ( funcs ) {\n" |
- "/****************************************\n" |
- "Init\n" |
- "void \n" |
- " *fsm )\n" |
- " fsm->curState = \n" |
- "_startState;\n" |
- " fsm->accept = 0;\n" |
- "/****************************************\n" |
- "Accept\n" |
- " * Did the fsm accept? \n" |
- "int \n" |
- " *fsm )\n" |
- " return fsm->accept;\n" |
- "/**********************************************************************\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- " *fsm, char *data, int dlen )\n" |
- " char *p = data;\n" |
- " int len = dlen;\n" |
- "State *cs = fsm->curState;\n" |
- " for ( ; len > 0; p++, len-- ) {\n" |
- " int c = (unsigned char)*p;\n" |
- "Trans *trans;\n" |
- " if ( cs == 0 )\n" |
- " goto finished;\n" |
- " /* If the character is within the index bounds then get the\n" |
- " * transition for it. If it is out of the transition bounds\n" |
- " * we will use the default transition. */\n" |
- " if ( cs->lowIndex <= c && c < cs->highIndex ) {\n" |
- " /* Use the index to look into the transition array. */\n" |
- " trans = \n" |
- "_t + \n" |
- " ((\n" |
- "*)cs->transIndex)[c - cs->lowIndex];\n" |
- " else {\n" |
- " /* Use the default index as the char is out of range. */\n" |
- " trans = \n" |
- "_t + cs->dflIndex;\n" |
- " /* If there are functions for this transition then execute them. */\n" |
- " if ( trans->funcs >= 0 )\n" |
- "ExecFuncs( fsm, trans->funcs, p );\n" |
- " /* Move to the new state. */\n" |
- " cs = trans->toState;\n" |
- "finished:\n" |
- " fsm->curState = cs;\n" |
- "/**********************************************************************\n" |
- "Finish\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- " *fsm )\n" |
- "State *cs = fsm->curState;\n" |
- " if ( cs != 0 && cs->isFinState ) {\n" |
- " /* If finishing in a final state then execute the\n" |
- " * out functions for it. (if any). */\n" |
- " if ( cs->outFuncs != 0 )\n" |
- "ExecFuncs( fsm, cs->outFuncs, 0 );\n" |
- " fsm->accept = 1;\n" |
- " else {\n" |
- " /* If we are not in a final state then this\n" |
- " * is an error. Move to the error state. */\n" |
- " fsm->curState = 0;\n" |
- "class \n" |
- "public:\n" |
- " /* Function and index type. */\n" |
- " typedef int Func;\n" |
- " /* Forward dec state for the transition structure. */\n" |
- " struct State;\n" |
- " /* A single transition. */\n" |
- " struct Trans\n" |
- " State *toState;\n" |
- " int funcs;\n" |
- " /* A single state. */\n" |
- " struct State\n" |
- " int lowIndex;\n" |
- " int highIndex;\n" |
- " void *transIndex;\n" |
- " int dflIndex;\n" |
- " int outFuncs;\n" |
- " int isFinState;\n" |
- " /* Constructor. */\n" |
- " void Init( );\n" |
- " /* Execute some chunk of data. */\n" |
- " void Execute( char *data, int dlen );\n" |
- " /* Indicate to the fsm tha there is no more data. */\n" |
- " void Finish( );\n" |
- " /* Did the machine accept? */\n" |
- " int Accept( );\n" |
- " State *curState;\n" |
- " int accept;\n" |
- " inline void ExecFuncs( int funcs, char *p );\n" |
- "::State \n" |
- "::Trans \n" |
- "::State *\n" |
- "/***************************************************************************\n" |
- " * Execute functions pointed to by funcs until the null function is found. \n" |
- "inline void \n" |
- "::ExecFuncs( int funcs, char *p )\n" |
- " switch ( funcs ) {\n" |
- "/****************************************\n" |
- " * Constructor\n" |
- " Init();\n" |
- "/****************************************\n" |
- "::Init( )\n" |
- " curState = \n" |
- "_startState;\n" |
- " accept = 0;\n" |
- "/****************************************\n" |
- " * Did the fsm accept? \n" |
- "int \n" |
- "::Accept( )\n" |
- " return accept;\n" |
- "/**********************************************************************\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- "::Execute( char *data, int dlen )\n" |
- " char *p = data;\n" |
- " int len = dlen;\n" |
- " State *cs = curState;\n" |
- " for ( ; len > 0; p++, len-- ) {\n" |
- " int c = (unsigned char)*p;\n" |
- " Trans *trans;\n" |
- " if ( cs == 0 )\n" |
- " goto finished;\n" |
- " /* If the character is within the index bounds then get the\n" |
- " * transition for it. If it is out of the transition bounds\n" |
- " * we will use the default transition. */\n" |
- " if ( cs->lowIndex <= c && c < cs->highIndex ) {\n" |
- " /* Use the index to look into the transition array. */\n" |
- " trans = \n" |
- "_t + cs->dflIndex;\n" |
- " /* If there are functions for this transition then execute them. */\n" |
- " if ( trans->funcs != 0 )\n" |
- " ExecFuncs( trans->funcs, p );\n" |
- " /* Move to the new state. */\n" |
- " cs = trans->toState;\n" |
- "finished:\n" |
- " curState = cs;\n" |
- "/**********************************************************************\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- "::Finish( )\n" |
- " State *cs = curState;\n" |
- " if ( cs != 0 && cs->isFinState ) {\n" |
- " /* If finishing in a final state then execute the\n" |
- " * out functions for it. (if any). */\n" |
- " if ( cs->outFuncs != 0 )\n" |
- " ExecFuncs( cs->outFuncs, 0 );\n" |
- " accept = 1;\n" |
- " else {\n" |
- " /* If we are not in a final state then this\n" |
- " * is an error. Move to the error state. */\n" |
- " curState = 0;\n" |
- "11FTabCodeGen\n" |
- "12CFTabCodeGen\n" |
- "13CCFTabCodeGen\n" |
- "bad_alloc\n" |
- "cs = -1; \n" |
- "cs = \n" |
- "break;\n" |
- " switch( cs ) {\n" |
- " case \n" |
- " switch ( c ) {\n" |
- "case \n" |
- "default: \n" |
- " }\n" |
- " break;\n" |
- " switch( cs ) {\n" |
- "accept = 1; \n" |
- "/* Only non-static data: current state. */\n" |
- "struct \n" |
- "Struct\n" |
- " int curState;\n" |
- " int accept;\n" |
- "typedef struct \n" |
- "Struct \n" |
- "/* Init the fsm. */\n" |
- "void \n" |
- "Init( \n" |
- " *fsm );\n" |
- "/* Execute some chunk of data. */\n" |
- "void \n" |
- "Execute( \n" |
- " *fsm, char *data, int dlen );\n" |
- "/* Indicate to the fsm tha there is no more data. */\n" |
- "void \n" |
- "Finish( \n" |
- " *fsm );\n" |
- "/* Did the machine accept? */\n" |
- "int \n" |
- "Accept( \n" |
- " *fsm );\n" |
- "/* The start state. */\n" |
- "static int \n" |
- "_startState = \n" |
- "/****************************************\n" |
- "Init\n" |
- "void \n" |
- " *fsm )\n" |
- " fsm->curState = \n" |
- "_startState;\n" |
- " fsm->accept = 0;\n" |
- "/**********************************************************************\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- " *fsm, char *data, int dlen )\n" |
- " char *p = data;\n" |
- " int len = dlen;\n" |
- " int cs = fsm->curState;\n" |
- " for ( ; len > 0; p++, len-- ) {\n" |
- " unsigned char c = (unsigned char)*p;\n" |
- " fsm->curState = cs;\n" |
- "/**********************************************************************\n" |
- "Finish\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- " *fsm )\n" |
- " int cs = fsm->curState;\n" |
- " int accept = 0;\n" |
- " fsm->accept = accept;\n" |
- "/*******************************************************\n" |
- "Accept\n" |
- " * Did the machine accept?\n" |
- "int \n" |
- " *fsm )\n" |
- " return fsm->accept;\n" |
- "/* Only non-static data: current state. */\n" |
- "class \n" |
- "public:\n" |
- " /* Init the fsm. */\n" |
- " void Init( );\n" |
- " /* Execute some chunk of data. */\n" |
- " void Execute( char *data, int dlen );\n" |
- " /* Indicate to the fsm tha there is no more data. */\n" |
- " void Finish( );\n" |
- " /* Did the machine accept? */\n" |
- " int Accept( );\n" |
- " int curState;\n" |
- " int accept;\n" |
- " /* The start state. */\n" |
- " static int startState;\n" |
- "/* The start state. */\n" |
- "int \n" |
- "::startState = \n" |
- " Init();\n" |
- "/****************************************\n" |
- "::Init\n" |
- "void \n" |
- "::Init( )\n" |
- " curState = startState;\n" |
- " accept = 0;\n" |
- "::Execute( char *data, int dlen )\n" |
- " char *p = data;\n" |
- " int len = dlen;\n" |
- " int cs = curState;\n" |
- " for ( ; len > 0; p++, len-- ) {\n" |
- " unsigned char c = (unsigned char)*p;\n" |
- " curState = cs;\n" |
- "/**********************************************************************\n" |
- "::Finish\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- "::Finish( )\n" |
- " int cs = curState;\n" |
- " int accept = 0;\n" |
- " this->accept = accept;\n" |
- "/*******************************************************\n" |
- "::Accept\n" |
- " * Did the machine accept?\n" |
- "int \n" |
- "::Accept( )\n" |
- " return accept;\n" |
- "10SelCodeGen\n" |
- "11CSelCodeGen\n" |
- "12CCSelCodeGen\n" |
- "10FsmCodeGen\n" |
- "bad_alloc\n" |
- "goto tr\n" |
- "goto st\n" |
- "goto err;\n" |
- " case \n" |
- "break;}\n" |
- ": goto st\n" |
- " case \n" |
- " default: return;\n" |
- " goto st\n" |
- " if ( --len == 0 )\n" |
- " goto out\n" |
- " switch( (alph) *++p ) {\n" |
- "case \n" |
- " default: \n" |
- " return;\n" |
- "curState = \n" |
- " switch( cs ) {\n" |
- "accept = 1; \n" |
- "break;\n" |
- "err:\n" |
- "curState = -1;\n" |
- ", p );\n" |
- "ExecFuncs( fsm, f+\n" |
- "fsm->\n" |
- "/* Only non-static data: current state. */\n" |
- "struct \n" |
- "Struct\n" |
- " int curState;\n" |
- " int accept;\n" |
- "typedef struct \n" |
- "Struct \n" |
- "/* Init the fsm. */\n" |
- "void \n" |
- "Init( \n" |
- " *fsm );\n" |
- "/* Execute some chunk of data. */\n" |
- "void \n" |
- "Execute( \n" |
- " *fsm, char *data, int dlen );\n" |
- "/* Indicate to the fsm tha there is no more data. */\n" |
- "void \n" |
- "Finish( \n" |
- " *fsm );\n" |
- "/* Did the machine accept? */\n" |
- "int \n" |
- "Accept( \n" |
- " *fsm );\n" |
- "/* The start state. */\n" |
- "static int \n" |
- "_startState = \n" |
- "#define f \n" |
- "#define alph unsigned char\n" |
- "/* The array of functions. */\n" |
- "#if \n" |
- "static int \n" |
- "_f[] = {\n" |
- "#endif\n" |
- "/****************************************\n" |
- "Init\n" |
- "void \n" |
- " *fsm )\n" |
- " fsm->curState = \n" |
- "_startState;\n" |
- " fsm->accept = 0;\n" |
- "/***************************************************************************\n" |
- " * Function exection. We do not inline this as in tab\n" |
- " * code gen because if we did, we might as well just expand \n" |
- " * the function as in the faster goto code generator.\n" |
- "static void \n" |
- "ExecFuncs( \n" |
- " *fsm, int *funcs, char *p )\n" |
- " int len = *funcs++;\n" |
- " while ( len-- > 0 ) {\n" |
- " switch ( *funcs++ ) {\n" |
- "/**********************************************************************\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- " *fsm, char *data, int dlen )\n" |
- " /* Prime these to one back to simulate entering the \n" |
- " * machine on a transition. */ \n" |
- " register char *p = data - 1;\n" |
- " register int len = dlen + 1;\n" |
- " /* Switch statment to enter the machine. */\n" |
- " switch ( \n" |
- "curState ) {\n" |
- "/**********************************************************************\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- " *fsm )\n" |
- " int cs = fsm->curState;\n" |
- " int accept = 0;\n" |
- " fsm->accept = accept;\n" |
- "/*******************************************************\n" |
- " * Did the machine accept?\n" |
- "int \n" |
- " *fsm )\n" |
- " return fsm->accept;\n" |
- "#undef f\n" |
- "#undef alph\n" |
- " ExecFuncs( f+\n" |
- "/* Only non-static data: current state. */\n" |
- "class \n" |
- "public:\n" |
- " /* Init the fsm. */\n" |
- " void Init( );\n" |
- " /* Execute some chunk of data. */\n" |
- " void Execute( char *data, int dlen );\n" |
- " /* Indicate to the fsm tha there is no more data. */\n" |
- " void Finish( );\n" |
- " /* Did the machine accept? */\n" |
- " int Accept( );\n" |
- " int curState;\n" |
- " int accept;\n" |
- " /* The start state. */\n" |
- " static int startState;\n" |
- " /* Function exection. We do not inline this as in tab code gen\n" |
- " * because if we did, we might as well just expand the function \n" |
- " * as in the faster goto code generator. */\n" |
- " void ExecFuncs( int *funcs, char * );\n" |
- "/* The start state. */\n" |
- "int \n" |
- "::startState = \n" |
- "/* some defines to lessen the code size. */\n" |
- "#define f \n" |
- "#endif\n" |
- "/****************************************\n" |
- " * Make sure the fsm is initted.\n" |
- " Init();\n" |
- "/****************************************\n" |
- " * Initialize the fsm.\n" |
- "void \n" |
- "::Init( )\n" |
- " curState = startState;\n" |
- " accept = 0;\n" |
- "/***************************************************************************\n" |
- " * Execute functions pointed to by funcs until the null function is found. \n" |
- "void \n" |
- "::ExecFuncs( int *funcs, char *p )\n" |
- " int len = *funcs++;\n" |
- " while ( len-- > 0 ) {\n" |
- " switch ( *funcs++ ) {\n" |
- "/**********************************************************************\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- "::Execute( char *data, int dlen )\n" |
- " /* Prime these to one back to simulate entering the \n" |
- " * machine on a transition. */ \n" |
- " register char *p = data - 1;\n" |
- " register int len = dlen + 1;\n" |
- " /* Switch statment to enter the machine. */\n" |
- " switch ( curState ) {\n" |
- "/**********************************************************************\n" |
- "::Finish\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- "::Finish( )\n" |
- " int cs = curState;\n" |
- " int accept = 0;\n" |
- " this->accept = accept;\n" |
- "/*******************************************************\n" |
- "::Accept\n" |
- " * Did the machine accept?\n" |
- "int \n" |
- "::Accept( )\n" |
- " return accept;\n" |
- "#undef f\n" |
- "#undef alph\n" |
- "11GotoCodeGen\n" |
- "12CGotoCodeGen\n" |
- "13CCGotoCodeGen\n" |
- "10FsmCodeGen\n" |
- "bad_alloc\n" |
- " case \n" |
- " break;\n" |
- ", p );\n" |
- "ExecFuncs( fsm, \n" |
- "fsm->\n" |
- "/* Only non-static data: current state. */\n" |
- "struct \n" |
- "Struct\n" |
- " int curState;\n" |
- " int accept;\n" |
- "typedef struct \n" |
- "Struct \n" |
- "/* Init the fsm. */\n" |
- "void \n" |
- "Init( \n" |
- " *fsm );\n" |
- "/* Execute some chunk of data. */\n" |
- "void \n" |
- "Execute( \n" |
- " *fsm, char *data, int dlen );\n" |
- "/* Indicate to the fsm tha there is no more data. */\n" |
- "void \n" |
- "Finish( \n" |
- " *fsm );\n" |
- "/* Did the machine accept? */\n" |
- "int \n" |
- "Accept( \n" |
- " *fsm );\n" |
- "/* The start state. */\n" |
- "static int \n" |
- "_startState = \n" |
- "/****************************************\n" |
- "Init\n" |
- "void \n" |
- " *fsm )\n" |
- " fsm->curState = \n" |
- "_startState;\n" |
- " fsm->accept = 0;\n" |
- "/***************************************************************************\n" |
- " * Function exection. We do not inline this as in tab\n" |
- " * code gen because if we did, we might as well just expand \n" |
- " * the function as in the faster goto code generator.\n" |
- "static void \n" |
- "ExecFuncs( \n" |
- " *fsm, int func, char *p )\n" |
- " switch ( func ) {\n" |
- "#define alph unsigned char\n" |
- "/**********************************************************************\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- " *fsm, char *data, int dlen )\n" |
- " /* Prime these to one back to simulate entering the \n" |
- " * machine on a transition. */ \n" |
- " register char *p = data-1;\n" |
- " register int len = dlen+1;\n" |
- " /* Switch statment to enter the machine. */\n" |
- " switch ( \n" |
- "curState ) {\n" |
- "/**********************************************************************\n" |
- "Finish\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- " *fsm )\n" |
- " int cs = fsm->curState;\n" |
- " int accept = 0;\n" |
- " fsm->accept = accept;\n" |
- "/*******************************************************\n" |
- "Accept\n" |
- " * Did the machine accept?\n" |
- "int \n" |
- " *fsm )\n" |
- " return fsm->accept;\n" |
- "#undef alph\n" |
- " ExecFuncs( \n" |
- "/* Only non-static data: current state. */\n" |
- "class \n" |
- "public:\n" |
- " /* Init the fsm. */\n" |
- " void Init( );\n" |
- " /* Execute some chunk of data. */\n" |
- " void Execute( char *data, int dlen );\n" |
- " /* Indicate to the fsm tha there is no more data. */\n" |
- " void Finish( );\n" |
- " /* Did the machine accept? */\n" |
- " int Accept( );\n" |
- " int curState;\n" |
- " int accept;\n" |
- " /* The start state. */\n" |
- " static int startState;\n" |
- " /* Function exection. We do not inline this as in tab code gen\n" |
- " * because if we did, we might as well just expand the function \n" |
- " * as in the faster goto code generator. */\n" |
- " void ExecFuncs( int func, char *p );\n" |
- "/* The start state. */\n" |
- "int \n" |
- "::startState = \n" |
- " Init();\n" |
- "/****************************************\n" |
- "::Init\n" |
- "void \n" |
- "::Init( )\n" |
- " curState = startState;\n" |
- " accept = 0;\n" |
- "/***************************************************************************\n" |
- " * Execute functions pointed to by funcs until the null function is found. \n" |
- "void \n" |
- "::ExecFuncs( int func, char *p )\n" |
- " switch ( func ) {\n" |
- "::Execute( char *data, int dlen )\n" |
- " /* Prime these to one back to simulate entering the \n" |
- " * machine on a transition. */ \n" |
- " register char *p = data-1;\n" |
- " register int len = dlen+1;\n" |
- " /* Switch statment to enter the machine. */\n" |
- " switch ( curState ) {\n" |
- "::Finish\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- "::Finish( )\n" |
- " int cs = curState;\n" |
- " int accept = 0;\n" |
- " this->accept = accept;\n" |
- "/*******************************************************\n" |
- "::Accept\n" |
- " * Did the machine accept?\n" |
- "int \n" |
- "::Accept( )\n" |
- " return accept;\n" |
- "#undef alph\n" |
- "12FGotoCodeGen\n" |
- "13CFGotoCodeGen\n" |
- "14CCFGotoCodeGen\n" |
- "11GotoCodeGen\n" |
- "10FsmCodeGen\n" |
- "bad_alloc\n" |
- "fsm->\n" |
- "/* Only non-static data: current state. */\n" |
- "struct \n" |
- "Struct\n" |
- " int curState;\n" |
- " int accept;\n" |
- "typedef struct \n" |
- "Struct \n" |
- "/* Init the fsm. */\n" |
- "void \n" |
- "Init( \n" |
- " *fsm );\n" |
- "/* Execute some chunk of data. */\n" |
- "void \n" |
- "Execute( \n" |
- " *fsm, char *data, int dlen );\n" |
- "/* Indicate to the fsm tha there is no more data. */\n" |
- "void \n" |
- "Finish( \n" |
- " *fsm );\n" |
- "/* Did the machine accept? */\n" |
- "int \n" |
- "Accept( \n" |
- " *fsm );\n" |
- "/* The start state. */\n" |
- "static int \n" |
- "_startState = \n" |
- "/****************************************\n" |
- "Init\n" |
- "void \n" |
- " *fsm )\n" |
- " fsm->curState = \n" |
- "_startState;\n" |
- " fsm->accept = 0;\n" |
- "#define alph unsigned char\n" |
- "/**********************************************************************\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- " *fsm, char *data, int dlen )\n" |
- " /* Prime these to one back to simulate entering the \n" |
- " * machine on a transition. */ \n" |
- " register char *p = data-1;\n" |
- " register int len = dlen+1;\n" |
- " /* Switch statment to enter the machine. */\n" |
- " switch ( \n" |
- "curState ) {\n" |
- "/**********************************************************************\n" |
- "Finish\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- " *fsm )\n" |
- " int cs = fsm->curState;\n" |
- " int accept = 0;\n" |
- " fsm->accept = accept;\n" |
- "/*******************************************************\n" |
- "Accept\n" |
- " * Did the machine accept?\n" |
- "int \n" |
- " *fsm )\n" |
- " return fsm->accept;\n" |
- "#undef alph\n" |
- "/* Only non-static data: current state. */\n" |
- "class \n" |
- "public:\n" |
- " /* Init the fsm. */\n" |
- " void Init( );\n" |
- " /* Execute some chunk of data. */\n" |
- " void Execute( char *data, int dlen );\n" |
- " /* Indicate to the fsm tha there is no more data. */\n" |
- " void Finish( );\n" |
- " /* Did the machine accept? */\n" |
- " int Accept( );\n" |
- " int curState;\n" |
- " int accept;\n" |
- " /* The start state. */\n" |
- " static int startState;\n" |
- "/* The start state. */\n" |
- "int \n" |
- "::startState = \n" |
- " Init();\n" |
- "/****************************************\n" |
- "::Init\n" |
- "void \n" |
- "::Init( )\n" |
- " curState = startState;\n" |
- " accept = 0;\n" |
- "#define alph unsigned char\n" |
- "/**********************************************************************\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- "::Execute( char *data, int dlen )\n" |
- " /* Prime these to one back to simulate entering the \n" |
- " * machine on a transition. */ \n" |
- " register char *p = data-1;\n" |
- " register int len = dlen+1;\n" |
- " /* Switch statment to enter the machine. */\n" |
- " switch ( curState ) {\n" |
- "::Finish\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- "::Finish( )\n" |
- " int cs = curState;\n" |
- " int accept = 0;\n" |
- " this->accept = accept;\n" |
- "/*******************************************************\n" |
- "::Accept\n" |
- " * Did the machine accept?\n" |
- "int \n" |
- "::Accept( )\n" |
- " return accept;\n" |
- "#undef alph\n" |
- "13IpGotoCodeGen\n" |
- "14CIpGotoCodeGen\n" |
- "15CCIpGotoCodeGen\n" |
- "11GotoCodeGen\n" |
- "10FsmCodeGen\n";
-}%%
-
-%% write data;
-struct strs the_fsm;
-
-void test( const char *buf )
-{
- int len = strlen( buf );
- struct strs *fsm = &the_fsm;
-
- perf_loop
- {
- const char *p = buf;
- const char *pe = buf + len;
-
- %% write init;
- %% write exec;
- }
-
- if ( fsm->cs >= strs_first_final )
- perf_printf("ACCEPT\n");
- else
- perf_printf("FAIL\n");
-}
-
-
-int main()
-{
- test( "stdin\n" );
- test( "bad_alloc\n" );
- test( "_GLOBAL_OFFSET_TABLE_\n" );
- test( "not in\n" );
- test(
- "isatty\n"
- "junk on end.\n"
- );
-
- return 0;
-}
-
-##### OUTPUT #####
-ACCEPT
-ACCEPT
-ACCEPT
-FAIL
-FAIL
diff --git a/test/ragel.d/strings3.rl b/test/ragel.d/strings3.rl
deleted file mode 100644
index 3889be7b..00000000
--- a/test/ragel.d/strings3.rl
+++ /dev/null
@@ -1,1434 +0,0 @@
-#
-# @LANG: asm
-#
-
-%%{
- machine strs;
-
- main :=
- "/lib/ld-linux.so.2\n" |
- "libstdc++-libc6.2-2.so.3\n" |
- "cerr\n" |
- "__cp_push_exception\n" |
- "_DYNAMIC\n" |
- "endl__FR7ostream\n" |
- "__ls__7ostreamc\n" |
- "_._9exception\n" |
- "__vt_9bad_alloc\n" |
- "__rtti_user\n" |
- "__ls__7ostreamPFR7ostream_R7ostream\n" |
- "__rtti_si\n" |
- "_init\n" |
- "bad__C3ios\n" |
- "__throw\n" |
- "__ls__7ostreamPCc\n" |
- "__deregister_frame_info\n" |
- "terminate__Fv\n" |
- "__ls__7ostreamb\n" |
- "__ls__7ostreami\n" |
- "__8ofstreamiPCcii\n" |
- "__builtin_vec_new\n" |
- "_fini\n" |
- "__9exception\n" |
- "__builtin_vec_delete\n" |
- "_GLOBAL_OFFSET_TABLE_\n" |
- "__vt_9exception\n" |
- "__nw__FUiPv\n" |
- "_._9bad_alloc\n" |
- "__builtin_delete\n" |
- "__builtin_new\n" |
- "cout\n" |
- "__register_frame_info\n" |
- "__eh_alloc\n" |
- "__gmon_start__\n" |
- "libm.so.6\n" |
- "libc.so.6\n" |
- "strcpy\n" |
- "stdout\n" |
- "memmove\n" |
- "memcpy\n" |
- "malloc\n" |
- "strtoul\n" |
- "fprintf\n" |
- "stdin\n" |
- "ferror\n" |
- "strncpy\n" |
- "strcasecmp\n" |
- "realloc\n" |
- "_IO_getc\n" |
- "fread\n" |
- "memset\n" |
- "clearerr\n" |
- "__assert_fail\n" |
- "strcmp\n" |
- "stderr\n" |
- "fwrite\n" |
- "__errno_location\n" |
- "exit\n" |
- "fopen\n" |
- "atoi\n" |
- "_IO_stdin_used\n" |
- "__libc_start_main\n" |
- "strlen\n" |
- "free\n" |
- "_edata\n" |
- "__bss_start\n" |
- "_end\n" |
- "GLIBC_2.1\n" |
- "GLIBC_2.0\n" |
- "PTRh\n" |
- "QVhL\n" |
- "<WVS\n" |
- "LWVS\n" |
- "PHRW\n" |
- "<WVS\n" |
- "\WVS\n" |
- ",WVS\n" |
- "@Phl\n" |
- "<WVS\n" |
- "jZjA\n" |
- "jzja\n" |
- "j9j0\n" |
- "j9j0\n" |
- "jZjA\n" |
- "jzja\n" |
- "jzja\n" |
- "jZjA\n" |
- "j~j!\n" |
- "j~j \n" |
- "j/j!\n" |
- "j@j:\n" |
- "j`j[\n" |
- "j~j{\n" |
- "j9j0\n" |
- "jFjA\n" |
- "jfja\n" |
- ",WVS\n" |
- ",WVS\n" |
- ";C<|\n" |
- "<WVS\n" |
- "C ;C\n" |
- "C$;C\n" |
- "C$;C\n" |
- "C ;C\n" |
- ",WVS\n" |
- ";E uF\n" |
- "P ;U\n" |
- "P ;U\n" |
- "E$fP\n" |
- "E$fP\n" |
- "E$fP\n" |
- "E$fP\n" |
- "E$fP\n" |
- "E$fP\n" |
- "E$fP\n" |
- "E$fP\n" |
- "u!h@\n" |
- "PHRj\n" |
- "PHRj\n" |
- "P\ U\n" |
- "j]hY\n" |
- "johY\n" |
- "PHRj\n" |
- "PHRj\n" |
- "E fPj\n" |
- "E fP\n" |
- "E fP\n" |
- "E fP\n" |
- "E fP\n" |
- "E fP\n" |
- "E fPj\n" |
- "t$h`\n" |
- "F ;C } \n" |
- "F ;C ~ \n" |
- "@X:BXt)\n" |
- "\WVS\n" |
- "\WVS\n" |
- "PPRS\n" |
- "F ;C } \n" |
- "F ;C ~ \n" |
- "@X:BXt)\n" |
- ";H(}:\n" |
- "@ fP\n" |
- ";P |\n" |
- "<WVS\n" |
- ";P |\n" |
- "bad_alloc\n" |
- "usage: ragel [options] file\n" |
- "general:\n" |
- " -h, -H, -? Disply this usage.\n" |
- " -o <file> Write output to <file>.\n" |
- " -s Print stats on the compiled fsm.\n" |
- " -f Dump the final fsm.\n" |
- "fsm minimization:\n" |
- " -n No minimization (default).\n" |
- " -m Find the minimal fsm accepting the language.\n" |
- "generated code language:\n" |
- " -c Generate c code (default).\n" |
- " -C Generate c++ code.\n" |
- "generated code style:\n" |
- " -T0 Generate a table driven fsm (default).\n" |
- " -T1 Generate a faster table driven fsm.\n" |
- " -S0 Generate a switch driven fsm.\n" |
- " -G0 Generate a goto driven fsm.\n" |
- " -G1 Generate a faster goto driven fsm.\n" |
- " -G2 Generate a really fast goto driven fsm.\n" |
- "char * FileNameFromStem(char *, char *)\n" |
- "main.cpp\n" |
- "len > 0\n" |
- "main\n" |
- "ragel: main graph not defined\n" |
- "graph states: \n" |
- "graph transitions: \n" |
- "machine states: \n" |
- "machine functions: \n" |
- "function array: \n" |
- "T:S:G:Cco:senmabjkfhH?-:\n" |
- "ragel: zero length output file name given\n" |
- "ragel: output file already given\n" |
- "ragel: invalid param specified (try -h for a list of options)\n" |
- "help\n" |
- "ragel: zero length input file name given\n" |
- "ragel: input file already given\n" |
- "ragel: warning: -e given but minimization is not enabled\n" |
- "ragel: no input file (try -h for a list of options)\n" |
- " for reading\n" |
- "ragel: could not open \n" |
- " for writing\n" |
- "ragel: error opening \n" |
- " * Parts of this file are copied from Ragel source covered by the GNU\n" |
- " * GPL. As a special exception, you may use the parts of this file copied\n" |
- " * from Ragel source without restriction. The remainder is derived from\n" |
- "bad_alloc\n" |
- "%s:%i: unterminated literal\n" |
- "%s:%i: unterminated comment\n" |
- "%s:%i: bad character in literal\n" |
- "fatal flex scanner internal error--no action found\n" |
- "fatal flex scanner internal error--end of buffer missed\n" |
- "fatal error - scanner input buffer overflow\n" |
- "input in flex scanner failed\n" |
- "out of dynamic memory in yy_create_buffer()\n" |
- "out of dynamic memory in yy_scan_buffer()\n" |
- "out of dynamic memory in yy_scan_bytes()\n" |
- "bad buffer in yy_scan_bytes()\n" |
- "bad_alloc\n" |
- "%s:%i: warning: range gives null fsm\n" |
- "%s:%i: warning: literal used in range is not of length 1, using 0x%x\n" |
- "%s:%i: warning: overflow in byte constant\n" |
- "parse error\n" |
- "parser stack overflow\n" |
- "%s:%i: %s\n" |
- "bad_alloc\n" |
- "extend\n" |
- "ascii\n" |
- "alpha\n" |
- "digit\n" |
- "alnum\n" |
- "lower\n" |
- "upper\n" |
- "cntrl\n" |
- "graph\n" |
- "print\n" |
- "punct\n" |
- "space\n" |
- "xdigit\n" |
- "struct Fsm * FactorWithAugNode::Walk()\n" |
- "parsetree.cpp\n" |
- "false\n" |
- "bad_alloc\n" |
- "xx []()\n" |
- " df \n" |
- "StartState: \n" |
- "Final States:\n" |
- "void FsmGraph<State,int,Trans>::AttachStates(State *, State *, Trans *, FsmKeyType, int)\n" |
- "rlfsm/fsmattach.cpp\n" |
- "trans->toState == __null\n" |
- "trans->fromState == __null\n" |
- "void FsmGraph<State,int,Trans>::DetachStates(State *, State *, Trans *, FsmKeyType, int)\n" |
- "trans->toState == to\n" |
- "trans->fromState == from\n" |
- "inTel != __null\n" |
- "void Vector<BstMapEl<int,int>,ResizeExpn>::setAs(const Vector<BstMapEl<int,int>,ResizeExpn> &)\n" |
- "aapl/vectcommon.h\n" |
- "&v != this\n" |
- "void FsmGraph<State,int,Trans>::ChangeRangeLowerKey(Trans *, int, int)\n" |
- "inRangeEl != __null\n" |
- "void FsmGraph<State,int,Trans>::IsolateStartState()\n" |
- "rlfsm/fsmgraph.cpp\n" |
- "md.stateDict.nodeCount == 0\n" |
- "md.stfil.listLength == 0\n" |
- "struct State * FsmGraph<State,int,Trans>::DetachState(State *)\n" |
- "fromTel != __null\n" |
- "struct Trans * FsmGraph<State,int,Trans>::AttachStates(State *, State *, FsmKeyType, int, int)\n" |
- "outTel != __null\n" |
- "outTel1 != __null\n" |
- "from->defOutTrans == __null\n" |
- "void FsmGraph<State,int,Trans>::VerifyOutFuncs()\n" |
- "state->outTransFuncTable.tableLength == 0\n" |
- "!state->isOutPriorSet\n" |
- "state->outPriority == 0\n" |
- "void FsmGraph<State,int,Trans>::VerifyIntegrity()\n" |
- "rlfsm/fsmbase.cpp\n" |
- "outIt.trans->fromState == state\n" |
- "inIt.trans->toState == state\n" |
- "static int FsmTrans<State,Trans,int,CmpOrd<int> >::ComparePartPtr(FsmTrans<State,Trans,int,CmpOrd<int> > *, FsmTrans<State,Trans,int,CmpOrd<int> > *)\n" |
- "rlfsm/fsmstate.cpp\n" |
- "false\n" |
- "void FsmGraph<State,int,Trans>::InTransMove(State *, State *)\n" |
- "dest != src\n" |
- "static bool FsmTrans<State,Trans,int,CmpOrd<int> >::ShouldMarkPtr(MarkIndex<State> &, FsmTrans<State,Trans,int,CmpOrd<int> > *, FsmTrans<State,Trans,int,CmpOrd<int> > *)\n" |
- "bad_alloc\n" |
- "10FsmCodeGen\n" |
- "bad_alloc\n" |
- " case \n" |
- "break;}\n" |
- "unsigned char\n" |
- "unsigned short\n" |
- "unsigned int\n" |
- "{0, \n" |
- "/* Forward dec state for the transition structure. */\n" |
- "struct \n" |
- "StateStruct;\n" |
- "/* A single transition. */\n" |
- "struct \n" |
- "TransStruct\n" |
- " struct \n" |
- "StateStruct *toState;\n" |
- " int *funcs;\n" |
- "typedef struct \n" |
- "TransStruct \n" |
- "Trans;\n" |
- "/* A single state. */\n" |
- "struct \n" |
- "StateStruct\n" |
- " int lowIndex;\n" |
- " int highIndex;\n" |
- " void *transIndex;\n" |
- " unsigned int dflIndex;\n" |
- " int *outFuncs;\n" |
- " int isFinState;\n" |
- "typedef struct \n" |
- "StateStruct \n" |
- "State;\n" |
- "/* Only non-static data: current state. */\n" |
- "struct \n" |
- "Struct\n" |
- "State *curState;\n" |
- " int accept;\n" |
- "typedef struct \n" |
- "Struct \n" |
- "/* Init the fsm. */\n" |
- "void \n" |
- "Init( \n" |
- " *fsm );\n" |
- "/* Execute some chunk of data. */\n" |
- "void \n" |
- "Execute( \n" |
- " *fsm, char *data, int dlen );\n" |
- "/* Indicate to the fsm tha there is no more data. */\n" |
- "void \n" |
- "Finish( \n" |
- " *fsm );\n" |
- "/* Did the machine accept? */\n" |
- "int \n" |
- "Accept( \n" |
- " *fsm );\n" |
- "#define f \n" |
- "#define s \n" |
- "#define i \n" |
- "#define t \n" |
- "/* The array of functions. */\n" |
- "#if \n" |
- "static int \n" |
- "_f[] = {\n" |
- "#endif\n" |
- "/* The array of indices into the transition array. */\n" |
- "#if \n" |
- "static \n" |
- "_i[] = {\n" |
- "#endif\n" |
- "/* The aray of states. */\n" |
- "static \n" |
- "State \n" |
- "_s[] = {\n" |
- "/* The array of transitions. */\n" |
- "static \n" |
- "Trans \n" |
- "_t[] = {\n" |
- "/* The start state. */\n" |
- "static \n" |
- "State *\n" |
- "_startState = s+\n" |
- "#undef f\n" |
- "#undef s\n" |
- "#undef i\n" |
- "#undef t\n" |
- "* Execute functions pointed to by funcs until the null function is found. \n" |
- "inline static void \n" |
- "ExecFuncs( \n" |
- " *fsm, int *funcs, char *p )\n" |
- " int len = *funcs++;\n" |
- " while ( len-- > 0 ) {\n" |
- " switch ( *funcs++ ) {\n" |
- " * Init the fsm to a runnable state.\n" |
- "void \n" |
- " *fsm )\n" |
- " fsm->curState = \n" |
- "_startState;\n" |
- " fsm->accept = 0;\n" |
- " * Did the fsm accept? \n" |
- "int \n" |
- " *fsm )\n" |
- " return fsm->accept;\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- " *fsm, char *data, int dlen )\n" |
- " char *p = data;\n" |
- " int len = dlen;\n" |
- "State *cs = fsm->curState;\n" |
- " for ( ; len > 0; p++, len-- ) {\n" |
- " int c = (unsigned char) *p;\n" |
- "Trans *trans;\n" |
- " if ( cs == 0 )\n" |
- " goto finished;\n" |
- " /* If the character is within the index bounds then get the\n" |
- " * transition for it. If it is out of the transition bounds\n" |
- " * we will use the default transition. */\n" |
- " if ( cs->lowIndex <= c && c < cs->highIndex ) {\n" |
- " /* Use the index to look into the transition array. */\n" |
- " trans = \n" |
- "_t + \n" |
- " ((\n" |
- "*)cs->transIndex)[c - cs->lowIndex];\n" |
- " else {\n" |
- " /* Use the default index as the char is out of range. */\n" |
- " trans = \n" |
- "_t + cs->dflIndex;\n" |
- " /* If there are functions for this transition then execute them. */\n" |
- " if ( trans->funcs != 0 )\n" |
- "ExecFuncs( fsm, trans->funcs, p );\n" |
- " /* Move to the new state. */\n" |
- " cs = trans->toState;\n" |
- "finished:\n" |
- " fsm->curState = cs;\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- " *fsm )\n" |
- "State *cs = fsm->curState;\n" |
- " if ( cs != 0 && cs->isFinState ) {\n" |
- " /* If finishing in a final state then execute the\n" |
- " * out functions for it. (if any). */\n" |
- " if ( cs->outFuncs != 0 )\n" |
- "ExecFuncs( fsm, cs->outFuncs, 0 );\n" |
- " fsm->accept = 1;\n" |
- " else {\n" |
- " /* If we are not in a final state then this\n" |
- " * is an error. Move to the error state. */\n" |
- " fsm->curState = 0;\n" |
- "class \n" |
- "public:\n" |
- " /* Forward dec state for the transition structure. */\n" |
- " struct State;\n" |
- " /* A single transition. */\n" |
- " struct Trans\n" |
- " State *toState;\n" |
- " int *funcs;\n" |
- " /* A single state. */\n" |
- " struct State\n" |
- " int lowIndex;\n" |
- " int highIndex;\n" |
- " void *transIndex;\n" |
- " unsigned int dflIndex;\n" |
- " int *outFuncs;\n" |
- " int isFinState;\n" |
- " /* Constructor. */\n" |
- " void Init( );\n" |
- " /* Execute some chunk of data. */\n" |
- " void Execute( char *data, int dlen );\n" |
- " /* Indicate to the fsm tha there is no more data. */\n" |
- " void Finish( );\n" |
- " /* Did the machine accept? */\n" |
- " int Accept( );\n" |
- " State *curState;\n" |
- " int accept;\n" |
- " inline void ExecFuncs( int *funcs, char *p );\n" |
- "/* The array of functions. */\n" |
- "#if \n" |
- "::State \n" |
- "/* The array of trainsitions. */\n" |
- "static \n" |
- "::Trans \n" |
- "/* The start state. */\n" |
- "static \n" |
- "::State *\n" |
- " * Execute functions pointed to by funcs until the null function is found. \n" |
- "inline void \n" |
- "::ExecFuncs( int *funcs, char *p )\n" |
- " int len = *funcs++;\n" |
- " while ( len-- > 0 ) {\n" |
- " switch ( *funcs++ ) {\n" |
- " * Constructor\n" |
- " Init();\n" |
- "Init\n" |
- "void \n" |
- "::Init( )\n" |
- " curState = \n" |
- "_startState;\n" |
- " accept = 0;\n" |
- "::Accept( )\n" |
- " return accept;\n" |
- "::Execute( char *data, int dlen )\n" |
- " char *p = data;\n" |
- " int len = dlen;\n" |
- " State *cs = curState;\n" |
- " for ( ; len > 0; p++, len-- ) {\n" |
- " int c = (unsigned char)*p;\n" |
- " Trans *trans;\n" |
- " if ( cs == 0 )\n" |
- " goto finished;\n" |
- " /* If the character is within the index bounds then get the\n" |
- " * transition for it. If it is out of the transition bounds\n" |
- " * we will use the default transition. */\n" |
- " if ( cs->lowIndex <= c && c < cs->highIndex ) {\n" |
- " /* Use the index to look into the transition array. */\n" |
- " trans = \n" |
- "_t + cs->dflIndex;\n" |
- " /* If there are functions for this transition then execute them. */\n" |
- " if ( trans->funcs != 0 )\n" |
- " ExecFuncs( trans->funcs, p );\n" |
- " /* Move to the new state. */\n" |
- " cs = trans->toState;\n" |
- "finished:\n" |
- " curState = cs;\n" |
- "::Finish( )\n" |
- " State *cs = curState;\n" |
- " if ( cs != 0 && cs->isFinState ) {\n" |
- " /* If finishing in a final state then execute the\n" |
- " * out functions for it. (if any). */\n" |
- " if ( cs->outFuncs != 0 )\n" |
- " ExecFuncs( cs->outFuncs, 0 );\n" |
- " accept = 1;\n" |
- " else {\n" |
- " /* If we are not in a final state then this\n" |
- " * is an error. Move to the error state. */\n" |
- " curState = 0;\n" |
- "10TabCodeGen\n" |
- "11CTabCodeGen\n" |
- "12CCTabCodeGen\n" |
- "10FsmCodeGen\n" |
- "bad_alloc\n" |
- " case \n" |
- " break;\n" |
- "/* Forward dec state for the transition structure. */\n" |
- "struct \n" |
- "StateStruct;\n" |
- "/* A single transition. */\n" |
- "struct \n" |
- "TransStruct\n" |
- " struct \n" |
- "StateStruct *toState;\n" |
- " int funcs;\n" |
- "typedef struct \n" |
- "TransStruct \n" |
- "Trans;\n" |
- "/* A single state. */\n" |
- "struct \n" |
- "StateStruct\n" |
- " int lowIndex;\n" |
- " int highIndex;\n" |
- " void *transIndex;\n" |
- " int dflIndex;\n" |
- " int outFuncs;\n" |
- " int isFinState;\n" |
- "typedef struct \n" |
- "StateStruct \n" |
- "State;\n" |
- "/* Only non-static data: current state. */\n" |
- "struct \n" |
- "Struct\n" |
- "State *curState;\n" |
- " int accept;\n" |
- "typedef struct \n" |
- "Struct \n" |
- "/* Init the fsm. */\n" |
- "void \n" |
- "Init( \n" |
- " *fsm );\n" |
- "/* Execute some chunk of data. */\n" |
- "void \n" |
- "Execute( \n" |
- " *fsm, char *data, int dlen );\n" |
- "/* Indicate to the fsm tha there is no more data. */\n" |
- "void \n" |
- "Finish( \n" |
- " *fsm );\n" |
- "/* Did the machine accept? */\n" |
- "int \n" |
- "Accept( \n" |
- " *fsm );\n" |
- "#define s \n" |
- "#define i \n" |
- "#define t \n" |
- "/* The array of indices into the transition array. */\n" |
- "#if \n" |
- "static \n" |
- "_i[] = {\n" |
- "#endif\n" |
- "/* The aray of states. */\n" |
- "static \n" |
- "State \n" |
- "_s[] = {\n" |
- "/* The array of trainsitions. */\n" |
- "static \n" |
- "Trans \n" |
- "_t[] = {\n" |
- "/* The start state. */\n" |
- "static \n" |
- "State *\n" |
- "_startState = s+\n" |
- "#undef f\n" |
- "#undef s\n" |
- "#undef i\n" |
- "#undef t\n" |
- "/***************************************************************************\n" |
- " * Execute functions pointed to by funcs until the null function is found. \n" |
- "inline static void \n" |
- "ExecFuncs( \n" |
- " *fsm, int funcs, char *p )\n" |
- " switch ( funcs ) {\n" |
- "/****************************************\n" |
- "Init\n" |
- "void \n" |
- " *fsm )\n" |
- " fsm->curState = \n" |
- "_startState;\n" |
- " fsm->accept = 0;\n" |
- "/****************************************\n" |
- "Accept\n" |
- " * Did the fsm accept? \n" |
- "int \n" |
- " *fsm )\n" |
- " return fsm->accept;\n" |
- "/**********************************************************************\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- " *fsm, char *data, int dlen )\n" |
- " char *p = data;\n" |
- " int len = dlen;\n" |
- "State *cs = fsm->curState;\n" |
- " for ( ; len > 0; p++, len-- ) {\n" |
- " int c = (unsigned char)*p;\n" |
- "Trans *trans;\n" |
- " if ( cs == 0 )\n" |
- " goto finished;\n" |
- " /* If the character is within the index bounds then get the\n" |
- " * transition for it. If it is out of the transition bounds\n" |
- " * we will use the default transition. */\n" |
- " if ( cs->lowIndex <= c && c < cs->highIndex ) {\n" |
- " /* Use the index to look into the transition array. */\n" |
- " trans = \n" |
- "_t + \n" |
- " ((\n" |
- "*)cs->transIndex)[c - cs->lowIndex];\n" |
- " else {\n" |
- " /* Use the default index as the char is out of range. */\n" |
- " trans = \n" |
- "_t + cs->dflIndex;\n" |
- " /* If there are functions for this transition then execute them. */\n" |
- " if ( trans->funcs >= 0 )\n" |
- "ExecFuncs( fsm, trans->funcs, p );\n" |
- " /* Move to the new state. */\n" |
- " cs = trans->toState;\n" |
- "finished:\n" |
- " fsm->curState = cs;\n" |
- "/**********************************************************************\n" |
- "Finish\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- " *fsm )\n" |
- "State *cs = fsm->curState;\n" |
- " if ( cs != 0 && cs->isFinState ) {\n" |
- " /* If finishing in a final state then execute the\n" |
- " * out functions for it. (if any). */\n" |
- " if ( cs->outFuncs != 0 )\n" |
- "ExecFuncs( fsm, cs->outFuncs, 0 );\n" |
- " fsm->accept = 1;\n" |
- " else {\n" |
- " /* If we are not in a final state then this\n" |
- " * is an error. Move to the error state. */\n" |
- " fsm->curState = 0;\n" |
- "class \n" |
- "public:\n" |
- " /* Function and index type. */\n" |
- " typedef int Func;\n" |
- " /* Forward dec state for the transition structure. */\n" |
- " struct State;\n" |
- " /* A single transition. */\n" |
- " struct Trans\n" |
- " State *toState;\n" |
- " int funcs;\n" |
- " /* A single state. */\n" |
- " struct State\n" |
- " int lowIndex;\n" |
- " int highIndex;\n" |
- " void *transIndex;\n" |
- " int dflIndex;\n" |
- " int outFuncs;\n" |
- " int isFinState;\n" |
- " /* Constructor. */\n" |
- " void Init( );\n" |
- " /* Execute some chunk of data. */\n" |
- " void Execute( char *data, int dlen );\n" |
- " /* Indicate to the fsm tha there is no more data. */\n" |
- " void Finish( );\n" |
- " /* Did the machine accept? */\n" |
- " int Accept( );\n" |
- " State *curState;\n" |
- " int accept;\n" |
- " inline void ExecFuncs( int funcs, char *p );\n" |
- "::State \n" |
- "::Trans \n" |
- "::State *\n" |
- "/***************************************************************************\n" |
- " * Execute functions pointed to by funcs until the null function is found. \n" |
- "inline void \n" |
- "::ExecFuncs( int funcs, char *p )\n" |
- " switch ( funcs ) {\n" |
- "/****************************************\n" |
- " * Constructor\n" |
- " Init();\n" |
- "/****************************************\n" |
- "::Init( )\n" |
- " curState = \n" |
- "_startState;\n" |
- " accept = 0;\n" |
- "/****************************************\n" |
- " * Did the fsm accept? \n" |
- "int \n" |
- "::Accept( )\n" |
- " return accept;\n" |
- "/**********************************************************************\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- "::Execute( char *data, int dlen )\n" |
- " char *p = data;\n" |
- " int len = dlen;\n" |
- " State *cs = curState;\n" |
- " for ( ; len > 0; p++, len-- ) {\n" |
- " int c = (unsigned char)*p;\n" |
- " Trans *trans;\n" |
- " if ( cs == 0 )\n" |
- " goto finished;\n" |
- " /* If the character is within the index bounds then get the\n" |
- " * transition for it. If it is out of the transition bounds\n" |
- " * we will use the default transition. */\n" |
- " if ( cs->lowIndex <= c && c < cs->highIndex ) {\n" |
- " /* Use the index to look into the transition array. */\n" |
- " trans = \n" |
- "_t + cs->dflIndex;\n" |
- " /* If there are functions for this transition then execute them. */\n" |
- " if ( trans->funcs != 0 )\n" |
- " ExecFuncs( trans->funcs, p );\n" |
- " /* Move to the new state. */\n" |
- " cs = trans->toState;\n" |
- "finished:\n" |
- " curState = cs;\n" |
- "/**********************************************************************\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- "::Finish( )\n" |
- " State *cs = curState;\n" |
- " if ( cs != 0 && cs->isFinState ) {\n" |
- " /* If finishing in a final state then execute the\n" |
- " * out functions for it. (if any). */\n" |
- " if ( cs->outFuncs != 0 )\n" |
- " ExecFuncs( cs->outFuncs, 0 );\n" |
- " accept = 1;\n" |
- " else {\n" |
- " /* If we are not in a final state then this\n" |
- " * is an error. Move to the error state. */\n" |
- " curState = 0;\n" |
- "11FTabCodeGen\n" |
- "12CFTabCodeGen\n" |
- "13CCFTabCodeGen\n" |
- "bad_alloc\n" |
- "cs = -1; \n" |
- "cs = \n" |
- "break;\n" |
- " switch( cs ) {\n" |
- " case \n" |
- " switch ( c ) {\n" |
- "case \n" |
- "default: \n" |
- " }\n" |
- " break;\n" |
- " switch( cs ) {\n" |
- "accept = 1; \n" |
- "/* Only non-static data: current state. */\n" |
- "struct \n" |
- "Struct\n" |
- " int curState;\n" |
- " int accept;\n" |
- "typedef struct \n" |
- "Struct \n" |
- "/* Init the fsm. */\n" |
- "void \n" |
- "Init( \n" |
- " *fsm );\n" |
- "/* Execute some chunk of data. */\n" |
- "void \n" |
- "Execute( \n" |
- " *fsm, char *data, int dlen );\n" |
- "/* Indicate to the fsm tha there is no more data. */\n" |
- "void \n" |
- "Finish( \n" |
- " *fsm );\n" |
- "/* Did the machine accept? */\n" |
- "int \n" |
- "Accept( \n" |
- " *fsm );\n" |
- "/* The start state. */\n" |
- "static int \n" |
- "_startState = \n" |
- "/****************************************\n" |
- "Init\n" |
- "void \n" |
- " *fsm )\n" |
- " fsm->curState = \n" |
- "_startState;\n" |
- " fsm->accept = 0;\n" |
- "/**********************************************************************\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- " *fsm, char *data, int dlen )\n" |
- " char *p = data;\n" |
- " int len = dlen;\n" |
- " int cs = fsm->curState;\n" |
- " for ( ; len > 0; p++, len-- ) {\n" |
- " unsigned char c = (unsigned char)*p;\n" |
- " fsm->curState = cs;\n" |
- "/**********************************************************************\n" |
- "Finish\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- " *fsm )\n" |
- " int cs = fsm->curState;\n" |
- " int accept = 0;\n" |
- " fsm->accept = accept;\n" |
- "/*******************************************************\n" |
- "Accept\n" |
- " * Did the machine accept?\n" |
- "int \n" |
- " *fsm )\n" |
- " return fsm->accept;\n" |
- "/* Only non-static data: current state. */\n" |
- "class \n" |
- "public:\n" |
- " /* Init the fsm. */\n" |
- " void Init( );\n" |
- " /* Execute some chunk of data. */\n" |
- " void Execute( char *data, int dlen );\n" |
- " /* Indicate to the fsm tha there is no more data. */\n" |
- " void Finish( );\n" |
- " /* Did the machine accept? */\n" |
- " int Accept( );\n" |
- " int curState;\n" |
- " int accept;\n" |
- " /* The start state. */\n" |
- " static int startState;\n" |
- "/* The start state. */\n" |
- "int \n" |
- "::startState = \n" |
- " Init();\n" |
- "/****************************************\n" |
- "::Init\n" |
- "void \n" |
- "::Init( )\n" |
- " curState = startState;\n" |
- " accept = 0;\n" |
- "::Execute( char *data, int dlen )\n" |
- " char *p = data;\n" |
- " int len = dlen;\n" |
- " int cs = curState;\n" |
- " for ( ; len > 0; p++, len-- ) {\n" |
- " unsigned char c = (unsigned char)*p;\n" |
- " curState = cs;\n" |
- "/**********************************************************************\n" |
- "::Finish\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- "::Finish( )\n" |
- " int cs = curState;\n" |
- " int accept = 0;\n" |
- " this->accept = accept;\n" |
- "/*******************************************************\n" |
- "::Accept\n" |
- " * Did the machine accept?\n" |
- "int \n" |
- "::Accept( )\n" |
- " return accept;\n" |
- "10SelCodeGen\n" |
- "11CSelCodeGen\n" |
- "12CCSelCodeGen\n" |
- "10FsmCodeGen\n" |
- "bad_alloc\n" |
- "goto tr\n" |
- "goto st\n" |
- "goto err;\n" |
- " case \n" |
- "break;}\n" |
- ": goto st\n" |
- " case \n" |
- " default: return;\n" |
- " goto st\n" |
- " if ( --len == 0 )\n" |
- " goto out\n" |
- " switch( (alph) *++p ) {\n" |
- "case \n" |
- " default: \n" |
- " return;\n" |
- "curState = \n" |
- " switch( cs ) {\n" |
- "accept = 1; \n" |
- "break;\n" |
- "err:\n" |
- "curState = -1;\n" |
- ", p );\n" |
- "ExecFuncs( fsm, f+\n" |
- "fsm->\n" |
- "/* Only non-static data: current state. */\n" |
- "struct \n" |
- "Struct\n" |
- " int curState;\n" |
- " int accept;\n" |
- "typedef struct \n" |
- "Struct \n" |
- "/* Init the fsm. */\n" |
- "void \n" |
- "Init( \n" |
- " *fsm );\n" |
- "/* Execute some chunk of data. */\n" |
- "void \n" |
- "Execute( \n" |
- " *fsm, char *data, int dlen );\n" |
- "/* Indicate to the fsm tha there is no more data. */\n" |
- "void \n" |
- "Finish( \n" |
- " *fsm );\n" |
- "/* Did the machine accept? */\n" |
- "int \n" |
- "Accept( \n" |
- " *fsm );\n" |
- "/* The start state. */\n" |
- "static int \n" |
- "_startState = \n" |
- "#define f \n" |
- "#define alph unsigned char\n" |
- "/* The array of functions. */\n" |
- "#if \n" |
- "static int \n" |
- "_f[] = {\n" |
- "#endif\n" |
- "/****************************************\n" |
- "Init\n" |
- "void \n" |
- " *fsm )\n" |
- " fsm->curState = \n" |
- "_startState;\n" |
- " fsm->accept = 0;\n" |
- "/***************************************************************************\n" |
- " * Function exection. We do not inline this as in tab\n" |
- " * code gen because if we did, we might as well just expand \n" |
- " * the function as in the faster goto code generator.\n" |
- "static void \n" |
- "ExecFuncs( \n" |
- " *fsm, int *funcs, char *p )\n" |
- " int len = *funcs++;\n" |
- " while ( len-- > 0 ) {\n" |
- " switch ( *funcs++ ) {\n" |
- "/**********************************************************************\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- " *fsm, char *data, int dlen )\n" |
- " /* Prime these to one back to simulate entering the \n" |
- " * machine on a transition. */ \n" |
- " register char *p = data - 1;\n" |
- " register int len = dlen + 1;\n" |
- " /* Switch statment to enter the machine. */\n" |
- " switch ( \n" |
- "curState ) {\n" |
- "/**********************************************************************\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- " *fsm )\n" |
- " int cs = fsm->curState;\n" |
- " int accept = 0;\n" |
- " fsm->accept = accept;\n" |
- "/*******************************************************\n" |
- " * Did the machine accept?\n" |
- "int \n" |
- " *fsm )\n" |
- " return fsm->accept;\n" |
- "#undef f\n" |
- "#undef alph\n" |
- " ExecFuncs( f+\n" |
- "/* Only non-static data: current state. */\n" |
- "class \n" |
- "public:\n" |
- " /* Init the fsm. */\n" |
- " void Init( );\n" |
- " /* Execute some chunk of data. */\n" |
- " void Execute( char *data, int dlen );\n" |
- " /* Indicate to the fsm tha there is no more data. */\n" |
- " void Finish( );\n" |
- " /* Did the machine accept? */\n" |
- " int Accept( );\n" |
- " int curState;\n" |
- " int accept;\n" |
- " /* The start state. */\n" |
- " static int startState;\n" |
- " /* Function exection. We do not inline this as in tab code gen\n" |
- " * because if we did, we might as well just expand the function \n" |
- " * as in the faster goto code generator. */\n" |
- " void ExecFuncs( int *funcs, char * );\n" |
- "/* The start state. */\n" |
- "int \n" |
- "::startState = \n" |
- "/* some defines to lessen the code size. */\n" |
- "#define f \n" |
- "#endif\n" |
- "/****************************************\n" |
- " * Make sure the fsm is initted.\n" |
- " Init();\n" |
- "/****************************************\n" |
- " * Initialize the fsm.\n" |
- "void \n" |
- "::Init( )\n" |
- " curState = startState;\n" |
- " accept = 0;\n" |
- "/***************************************************************************\n" |
- " * Execute functions pointed to by funcs until the null function is found. \n" |
- "void \n" |
- "::ExecFuncs( int *funcs, char *p )\n" |
- " int len = *funcs++;\n" |
- " while ( len-- > 0 ) {\n" |
- " switch ( *funcs++ ) {\n" |
- "/**********************************************************************\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- "::Execute( char *data, int dlen )\n" |
- " /* Prime these to one back to simulate entering the \n" |
- " * machine on a transition. */ \n" |
- " register char *p = data - 1;\n" |
- " register int len = dlen + 1;\n" |
- " /* Switch statment to enter the machine. */\n" |
- " switch ( curState ) {\n" |
- "/**********************************************************************\n" |
- "::Finish\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- "::Finish( )\n" |
- " int cs = curState;\n" |
- " int accept = 0;\n" |
- " this->accept = accept;\n" |
- "/*******************************************************\n" |
- "::Accept\n" |
- " * Did the machine accept?\n" |
- "int \n" |
- "::Accept( )\n" |
- " return accept;\n" |
- "#undef f\n" |
- "#undef alph\n" |
- "11GotoCodeGen\n" |
- "12CGotoCodeGen\n" |
- "13CCGotoCodeGen\n" |
- "10FsmCodeGen\n" |
- "bad_alloc\n" |
- " case \n" |
- " break;\n" |
- ", p );\n" |
- "ExecFuncs( fsm, \n" |
- "fsm->\n" |
- "/* Only non-static data: current state. */\n" |
- "struct \n" |
- "Struct\n" |
- " int curState;\n" |
- " int accept;\n" |
- "typedef struct \n" |
- "Struct \n" |
- "/* Init the fsm. */\n" |
- "void \n" |
- "Init( \n" |
- " *fsm );\n" |
- "/* Execute some chunk of data. */\n" |
- "void \n" |
- "Execute( \n" |
- " *fsm, char *data, int dlen );\n" |
- "/* Indicate to the fsm tha there is no more data. */\n" |
- "void \n" |
- "Finish( \n" |
- " *fsm );\n" |
- "/* Did the machine accept? */\n" |
- "int \n" |
- "Accept( \n" |
- " *fsm );\n" |
- "/* The start state. */\n" |
- "static int \n" |
- "_startState = \n" |
- "/****************************************\n" |
- "Init\n" |
- "void \n" |
- " *fsm )\n" |
- " fsm->curState = \n" |
- "_startState;\n" |
- " fsm->accept = 0;\n" |
- "/***************************************************************************\n" |
- " * Function exection. We do not inline this as in tab\n" |
- " * code gen because if we did, we might as well just expand \n" |
- " * the function as in the faster goto code generator.\n" |
- "static void \n" |
- "ExecFuncs( \n" |
- " *fsm, int func, char *p )\n" |
- " switch ( func ) {\n" |
- "#define alph unsigned char\n" |
- "/**********************************************************************\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- " *fsm, char *data, int dlen )\n" |
- " /* Prime these to one back to simulate entering the \n" |
- " * machine on a transition. */ \n" |
- " register char *p = data-1;\n" |
- " register int len = dlen+1;\n" |
- " /* Switch statment to enter the machine. */\n" |
- " switch ( \n" |
- "curState ) {\n" |
- "/**********************************************************************\n" |
- "Finish\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- " *fsm )\n" |
- " int cs = fsm->curState;\n" |
- " int accept = 0;\n" |
- " fsm->accept = accept;\n" |
- "/*******************************************************\n" |
- "Accept\n" |
- " * Did the machine accept?\n" |
- "int \n" |
- " *fsm )\n" |
- " return fsm->accept;\n" |
- "#undef alph\n" |
- " ExecFuncs( \n" |
- "/* Only non-static data: current state. */\n" |
- "class \n" |
- "public:\n" |
- " /* Init the fsm. */\n" |
- " void Init( );\n" |
- " /* Execute some chunk of data. */\n" |
- " void Execute( char *data, int dlen );\n" |
- " /* Indicate to the fsm tha there is no more data. */\n" |
- " void Finish( );\n" |
- " /* Did the machine accept? */\n" |
- " int Accept( );\n" |
- " int curState;\n" |
- " int accept;\n" |
- " /* The start state. */\n" |
- " static int startState;\n" |
- " /* Function exection. We do not inline this as in tab code gen\n" |
- " * because if we did, we might as well just expand the function \n" |
- " * as in the faster goto code generator. */\n" |
- " void ExecFuncs( int func, char *p );\n" |
- "/* The start state. */\n" |
- "int \n" |
- "::startState = \n" |
- " Init();\n" |
- "/****************************************\n" |
- "::Init\n" |
- "void \n" |
- "::Init( )\n" |
- " curState = startState;\n" |
- " accept = 0;\n" |
- "/***************************************************************************\n" |
- " * Execute functions pointed to by funcs until the null function is found. \n" |
- "void \n" |
- "::ExecFuncs( int func, char *p )\n" |
- " switch ( func ) {\n" |
- "::Execute( char *data, int dlen )\n" |
- " /* Prime these to one back to simulate entering the \n" |
- " * machine on a transition. */ \n" |
- " register char *p = data-1;\n" |
- " register int len = dlen+1;\n" |
- " /* Switch statment to enter the machine. */\n" |
- " switch ( curState ) {\n" |
- "::Finish\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- "::Finish( )\n" |
- " int cs = curState;\n" |
- " int accept = 0;\n" |
- " this->accept = accept;\n" |
- "/*******************************************************\n" |
- "::Accept\n" |
- " * Did the machine accept?\n" |
- "int \n" |
- "::Accept( )\n" |
- " return accept;\n" |
- "#undef alph\n" |
- "12FGotoCodeGen\n" |
- "13CFGotoCodeGen\n" |
- "14CCFGotoCodeGen\n" |
- "11GotoCodeGen\n" |
- "10FsmCodeGen\n" |
- "bad_alloc\n" |
- "fsm->\n" |
- "/* Only non-static data: current state. */\n" |
- "struct \n" |
- "Struct\n" |
- " int curState;\n" |
- " int accept;\n" |
- "typedef struct \n" |
- "Struct \n" |
- "/* Init the fsm. */\n" |
- "void \n" |
- "Init( \n" |
- " *fsm );\n" |
- "/* Execute some chunk of data. */\n" |
- "void \n" |
- "Execute( \n" |
- " *fsm, char *data, int dlen );\n" |
- "/* Indicate to the fsm tha there is no more data. */\n" |
- "void \n" |
- "Finish( \n" |
- " *fsm );\n" |
- "/* Did the machine accept? */\n" |
- "int \n" |
- "Accept( \n" |
- " *fsm );\n" |
- "/* The start state. */\n" |
- "static int \n" |
- "_startState = \n" |
- "/****************************************\n" |
- "Init\n" |
- "void \n" |
- " *fsm )\n" |
- " fsm->curState = \n" |
- "_startState;\n" |
- " fsm->accept = 0;\n" |
- "#define alph unsigned char\n" |
- "/**********************************************************************\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- " *fsm, char *data, int dlen )\n" |
- " /* Prime these to one back to simulate entering the \n" |
- " * machine on a transition. */ \n" |
- " register char *p = data-1;\n" |
- " register int len = dlen+1;\n" |
- " /* Switch statment to enter the machine. */\n" |
- " switch ( \n" |
- "curState ) {\n" |
- "/**********************************************************************\n" |
- "Finish\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- " *fsm )\n" |
- " int cs = fsm->curState;\n" |
- " int accept = 0;\n" |
- " fsm->accept = accept;\n" |
- "/*******************************************************\n" |
- "Accept\n" |
- " * Did the machine accept?\n" |
- "int \n" |
- " *fsm )\n" |
- " return fsm->accept;\n" |
- "#undef alph\n" |
- "/* Only non-static data: current state. */\n" |
- "class \n" |
- "public:\n" |
- " /* Init the fsm. */\n" |
- " void Init( );\n" |
- " /* Execute some chunk of data. */\n" |
- " void Execute( char *data, int dlen );\n" |
- " /* Indicate to the fsm tha there is no more data. */\n" |
- " void Finish( );\n" |
- " /* Did the machine accept? */\n" |
- " int Accept( );\n" |
- " int curState;\n" |
- " int accept;\n" |
- " /* The start state. */\n" |
- " static int startState;\n" |
- "/* The start state. */\n" |
- "int \n" |
- "::startState = \n" |
- " Init();\n" |
- "/****************************************\n" |
- "::Init\n" |
- "void \n" |
- "::Init( )\n" |
- " curState = startState;\n" |
- " accept = 0;\n" |
- "#define alph unsigned char\n" |
- "/**********************************************************************\n" |
- " * Execute the fsm on some chunk of data. \n" |
- "void \n" |
- "::Execute( char *data, int dlen )\n" |
- " /* Prime these to one back to simulate entering the \n" |
- " * machine on a transition. */ \n" |
- " register char *p = data-1;\n" |
- " register int len = dlen+1;\n" |
- " /* Switch statment to enter the machine. */\n" |
- " switch ( curState ) {\n" |
- "::Finish\n" |
- " * Indicate to the fsm that the input is done. Does cleanup tasks.\n" |
- "void \n" |
- "::Finish( )\n" |
- " int cs = curState;\n" |
- " int accept = 0;\n" |
- " this->accept = accept;\n" |
- "/*******************************************************\n" |
- "::Accept\n" |
- " * Did the machine accept?\n" |
- "int \n" |
- "::Accept( )\n" |
- " return accept;\n" |
- "#undef alph\n" |
- "13IpGotoCodeGen\n" |
- "14CIpGotoCodeGen\n" |
- "15CCIpGotoCodeGen\n" |
- "11GotoCodeGen\n" |
- "10FsmCodeGen\n";
-}%%
-
- .file "strings1.c"
- .section .rodata
-
-%% write data;
-
- .comm cs,4,4
- .text
- .globl exec
- .type exec, @function
-exec:
-.LFB0:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- subq $96, %rsp
-
- push %r12
- push %r13
-
- movq cs(%rip), %r11
- movq %rdi, %r12
- movq %rsi, %r13
-
-%% write exec;
-
- movq %r11, cs(%rip)
-
- pop %r13
- pop %r12
-
- leave
- ret
- .cfi_endproc
-.LFE0:
- .size exec, .-exec
- .section .rodata
-.LC0:
- .string "ACCEPT"
-.LC1:
- .string "FAIL"
- .text
- .globl test
- .type test, @function
-test:
-.LFB1:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- subq $16, %rsp
- movq %rdi, -8(%rbp)
-
-%% write init;
-
- movq %r11, cs(%rip)
-
- movq -8(%rbp), %rax
- movq %rax, %rdi
- call strlen
- movl %eax, %edx
- movq -8(%rbp), %rax
- movslq %edx, %rsi
- addq %rax, %rsi
- movq %rax, %rdi
- call exec
- movl cs(%rip), %edx
- movl strs_first_final, %eax
- cmpl %eax, %edx
- jl .L27938
- movl $.LC0, %edi
- call puts
- jmp .L27937
-.L27938:
- movl $.LC1, %edi
- call puts
-.L27937:
- leave
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE1:
- .size test, .-test
- .section .rodata
-.LC2:
- .string "stdin\n"
-.LC3:
- .string "bad_alloc\n"
-.LC4:
- .string "_GLOBAL_OFFSET_TABLE_\n"
-.LC5:
- .string "not in\n"
-.LC6:
- .string "isatty\njunk on end.\n"
- .text
- .globl main
- .type main, @function
-main:
-.LFB2:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- movl $.LC2, %edi
- call test
- movl $.LC3, %edi
- call test
- movl $.LC4, %edi
- call test
- movl $.LC5, %edi
- call test
- movl $.LC6, %edi
- call test
- movl $0, %eax
- popq %rbp
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE2:
- .size main, .-main
- .ident "GCC: (Ubuntu 4.8.2-19ubuntu1) 4.8.2"
- .section .note.GNU-stack,"",@progbits
-
-##### OUTPUT #####
-ACCEPT
-ACCEPT
-ACCEPT
-FAIL
-FAIL
diff --git a/test/ragel.d/targs1.rl b/test/ragel.d/targs1.rl
deleted file mode 100644
index b97a550e..00000000
--- a/test/ragel.d/targs1.rl
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * @LANG: indep
- */
-
-int return_to;
-
-%%{
- machine targs1;
-
- unused := 'unused';
-
- one := 'one' @{
- print_str "one\n";
- fnext *return_to;
- };
-
- two := 'two' @{
- print_str "two\n";
- fnext *return_to;
- };
-
- main := (
- '1' @{ return_to = ftargs; fnext one; }
- | '2' @{ return_to = ftargs; fnext two; }
- | '\n'
- )*;
-}%%
-
-##### INPUT #####
-"1one2two1one\n"
-##### OUTPUT #####
-one
-two
-one
-ACCEPT
diff --git a/test/ragel.d/tofrom1.rl b/test/ragel.d/tofrom1.rl
deleted file mode 100644
index 74472ecf..00000000
--- a/test/ragel.d/tofrom1.rl
+++ /dev/null
@@ -1,351 +0,0 @@
-#
-# @LANG: asm
-#
-# Tests to/from actions in ASM code. Based on atoi.
-#
-
-%%{
- machine AtoI;
-
- action begin {
- # neg = 0;
- # val = 0;
- movl $0, neg(%rip)
- movl $0, val(%rip)
- }
-
- action see_neg {
- # neg = 1;
- movl $1, neg(%rip)
- }
-
- action add_digit {
- # val = val * 10 + (fc - 48);
- movl val(%rip), %eax
- imul $10, %eax
- movsbl (%r12), %ecx
- subl $48, %ecx
- add %ecx, %eax
- movl %eax, val(%rip)
- }
-
- action finish {
- #if (neg)
- #{
- # val = - 1 * val;
- #}
-
- movl neg(%rip), %eax
- cmpl $0, %eax
- je .finish_L
- movl val(%rip), %eax
- negl %eax
- movl %eax, val(%rip)
- .finish_L:
- }
-
- action print {
- movl $.L_fmt_i_nl, %edi
- movl val(%rip), %esi
- movl $0, %eax
- call printf
- }
-
- action tos {
- movl $.L_tos, %edi
- movsbl (%r12), %esi
- movl $0, %eax
- call printf
- }
-
- action froms {
- movl $.L_froms, %edi
- movsbl (%r12), %esi
- movl $0, %eax
- call printf
- }
-
- atoi =
- (('-' @ see_neg | '+') ?
- (digit @ add_digit) +) > begin %finish;
-
- main := ( atoi '\n' @ print )
- $to(tos) $from(froms);
-
-}%%
- .file "tmp.c"
- .comm neg,4,4
- .comm val,4,4
- .comm cs,4,4
- .section .rodata
-
-%% write data;
-
-.L_fmt_i_nl:
- .string "%i\n"
-.L_tos:
- .string "to on %d\n"
-.L_froms:
- .string "from on %d\n"
-
- .text
- .globl init
- .type init, @function
-init:
-.LFB0:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- movl $0, val(%rip)
- movl $0, neg(%rip)
-
-%% write init;
-
- movq %r11, cs(%rip)
-
- popq %rbp
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE0:
- .size init, .-init
- .section .rodata
-.LC0:
- .string "%i"
- .text
- .globl exec
- .type exec, @function
-exec:
-.LFB1:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- subq $96, %rsp
-
- push %r12
- push %r13
-
- movq cs(%rip), %r11
- movq %rdi, %r12
- movq %rsi, %r13
-
-%% write exec;
-
- movq %r11, cs(%rip)
-
- pop %r13
- pop %r12
-
-.LRET:
- leave
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE1:
- .size exec, .-exec
- .section .rodata
-.LC1:
- .string "-> ACCEPT"
-.LC2:
- .string "-> FAIL"
- .text
- .globl finish
- .type finish, @function
-finish:
-.LFB2:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- movl cs(%rip), %edx
- movl $4, %eax
- cmpl %eax, %edx
- jl .L36
- movl $.LC1, %edi
-# call puts
- jmp .L35
-.L36:
- movl $.LC2, %edi
- call puts
-.L35:
- popq %rbp
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE2:
- .size finish, .-finish
- .globl inp
-
- .section .rodata
-.LC3:
- .string "1\n"
-.LC4:
- .string "12\n"
-.LC5:
- .string "222222\n"
-.LC6:
- .string "+2123\n"
-.LC7:
- .string "-99\n"
-.LC8:
- .string "-12321\n"
-.LC9:
- .string "213 3213\n"
-.LC10:
- .string "--123\n"
-.LC11:
- .string " -3000\n"
- .data
- .align 32
- .type inp, @object
- .size inp, 72
-inp:
- .quad .LC3
- .quad .LC4
- .quad .LC5
- .quad .LC6
- .quad .LC7
- .quad .LC8
- .quad .LC9
- .quad .LC10
- .quad .LC11
- .globl inplen
- .align 4
- .type inplen, @object
- .size inplen, 4
-inplen:
- .long 9
- .text
- .globl main
- .type main, @function
-main:
-.LFB3:
- .cfi_startproc
- pushq %rbp
- .cfi_def_cfa_offset 16
- .cfi_offset 6, -16
- movq %rsp, %rbp
- .cfi_def_cfa_register 6
- subq $16, %rsp
- movl $0, -4(%rbp)
- jmp .L39
-.L40:
- movl $0, %eax
- call init
- movl -4(%rbp), %eax
- cltq
- movq inp(,%rax,8), %rax
- movq %rax, %rdi
- call strlen
- movl %eax, %edx
- movl -4(%rbp), %eax
- cltq
- movq inp(,%rax,8), %rax
- movslq %edx, %rsi
- addq %rax, %rsi
- movq %rax, %rdi
- call exec
- movl $0, %eax
- call finish
- addl $1, -4(%rbp)
-.L39:
- movl inplen(%rip), %eax
- cmpl %eax, -4(%rbp)
- jl .L40
- movl $0, %eax
- leave
- .cfi_def_cfa 7, 8
- ret
- .cfi_endproc
-.LFE3:
- .size main, .-main
- .ident "GCC: (Ubuntu 4.8.2-19ubuntu1) 4.8.2"
- .section .note.GNU-stack,"",@progbits
-
-##### OUTPUT #####
-from on 49
-to on 49
-from on 10
-1
-to on 10
-from on 49
-to on 49
-from on 50
-to on 50
-from on 10
-12
-to on 10
-from on 50
-to on 50
-from on 50
-to on 50
-from on 50
-to on 50
-from on 50
-to on 50
-from on 50
-to on 50
-from on 50
-to on 50
-from on 10
-222222
-to on 10
-from on 43
-to on 43
-from on 50
-to on 50
-from on 49
-to on 49
-from on 50
-to on 50
-from on 51
-to on 51
-from on 10
-2123
-to on 10
-from on 45
-to on 45
-from on 57
-to on 57
-from on 57
-to on 57
-from on 10
--99
-to on 10
-from on 45
-to on 45
-from on 49
-to on 49
-from on 50
-to on 50
-from on 51
-to on 51
-from on 50
-to on 50
-from on 49
-to on 49
-from on 10
--12321
-to on 10
-from on 50
-to on 50
-from on 49
-to on 49
-from on 51
-to on 51
-from on 32
--> FAIL
-from on 45
-to on 45
-from on 45
--> FAIL
-from on 32
--> FAIL
diff --git a/test/ragel.d/tofrom2.rl b/test/ragel.d/tofrom2.rl
deleted file mode 100644
index 3c201e73..00000000
--- a/test/ragel.d/tofrom2.rl
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * @LANG: c
- *
- * Tests to/from state actions, for comparison against ASM version.
- */
-
-#include <string.h>
-#include <stdio.h>
-
-int neg ;
-int value ;
-
-%%{
- machine atoi;
-
- action begin {neg = 0;
- value = 0;
- }
- action see_neg {neg = 1;
- }
- action add_digit {value = value * 10 + ( int ) ( fc - 48 )
- ;
- }
- action finish {
- if ( neg != 0 ) {
- value = -1 * value;
- }
- }
-
- action print {
- printf( "%d", value );
- printf( "%s", "\n" );
- }
-
- action tos {
- printf( "to on %d\n", (int)*p );
- }
-
- action froms {
- printf( "from on %d\n", (int)*p );
- }
-
- atoi = (
- ('-'@see_neg | '+')? (digit @add_digit)+
- ) >begin %finish;
-
- main := ( atoi '\n' @print)
- $to(tos) $from(froms);
-}%%
-
-
-%% write data;
-int cs;
-
-void init()
-{
- value = 0;
- neg = 0;
- %% write init;
-}
-
-void exec( char *data, int len )
-{
- char *p = data;
- char *pe = data + len;
- %% write exec;
-}
-
-void finish( )
-{
- if ( cs < atoi_first_final )
- printf( "-> FAIL\n" );
-}
-
-char *inp[] = {
- "1\n",
- "12\n",
- "222222\n",
- "+2123\n",
- "-99\n",
- "-12321\n",
- "213 3213\n",
- "--123\n",
- " -3000\n",
-};
-
-int inplen = 9;
-
-int main( )
-{
- int i;
- for ( i = 0; i < inplen; i++ ) {
- init();
- exec( inp[i], strlen(inp[i]) );
- finish();
- }
- return 0;
-}
-
-##### OUTPUT #####
-from on 49
-to on 49
-from on 10
-1
-to on 10
-from on 49
-to on 49
-from on 50
-to on 50
-from on 10
-12
-to on 10
-from on 50
-to on 50
-from on 50
-to on 50
-from on 50
-to on 50
-from on 50
-to on 50
-from on 50
-to on 50
-from on 50
-to on 50
-from on 10
-222222
-to on 10
-from on 43
-to on 43
-from on 50
-to on 50
-from on 49
-to on 49
-from on 50
-to on 50
-from on 51
-to on 51
-from on 10
-2123
-to on 10
-from on 45
-to on 45
-from on 57
-to on 57
-from on 57
-to on 57
-from on 10
--99
-to on 10
-from on 45
-to on 45
-from on 49
-to on 49
-from on 50
-to on 50
-from on 51
-to on 51
-from on 50
-to on 50
-from on 49
-to on 49
-from on 10
--12321
-to on 10
-from on 50
-to on 50
-from on 49
-to on 49
-from on 51
-to on 51
-from on 32
--> FAIL
-from on 45
-to on 45
-from on 45
--> FAIL
-from on 32
--> FAIL
diff --git a/test/ragel.d/tokstart1.rl b/test/ragel.d/tokstart1.rl
deleted file mode 100644
index 5e897629..00000000
--- a/test/ragel.d/tokstart1.rl
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * @LANG: c++
- */
-
-#include <iostream>
-#include <string.h>
-using namespace std;
-
-extern char buf[];
-
-struct Scanner
-{
- int cs, act;
- char *ts, *te;
-
- // Initialize the machine. Invokes any init statement blocks. Returns 0
- // if the machine begins in a non-accepting state and 1 if the machine
- // begins in an accepting state.
- void init( );
-
- // Execute the machine on a block of data. Returns -1 if after processing
- // the data, the machine is in the error state and can never accept, 0 if
- // the machine is in a non-accepting state and 1 if the machine is in an
- // accepting state.
- int execute( char *data, int len );
-
- // Indicate that there is no more data. Returns -1 if the machine finishes
- // in the error state and does not accept, 0 if the machine finishes
- // in any other non-accepting state and 1 if the machine finishes in an
- // accepting state.
- int finish( );
-};
-
-%%{
- machine Scanner;
-
- action to_act {
- cout << "to: fc = ";
- if ( fc == '\'' )
- cout << (int)fc;
- else
- cout << fc;
- cout << " ts = " << ( ts == 0 ? -1 : ts-buf ) << endl;
- }
- action from_act {
- cout << "from: fc = ";
- if ( p == eof )
- cout << "EOF";
- else {
- if ( fc == '\'' )
- cout << (int)fc;
- else
- cout << fc;
- }
- cout << " ts = " << ( ts == 0 ? -1 : ts-buf ) << endl;
- }
-
- c_comm := ( any* $0 '*/' @1 @{ fgoto main; } ) $~to_act $*from_act;
- cxx_comm := ( any* $0 '\n' @1 @{ fgoto main; } ) $~to_act $*from_act;
-
- main := |*
-
- # Single and double literals.
- ( 'L'? "'" ( [^'\\\n] | /\\./ )* "'" ) $~ to_act $* from_act;
- ( 'L'? '"' ( [^"\\\n] | /\\./ )* '"' ) $~ to_act $* from_act;
-
- # Identifiers
- ( [a-zA-Z_] [a-zA-Z0-9_]* ) $~ to_act $* from_act;
-
- # Floating literals.
- fract_const = digit* '.' digit+ | digit+ '.';
- exponent = [eE] [+\-]? digit+;
- float_suffix = [flFL];
-
- ( fract_const exponent? float_suffix? |
- digit+ exponent float_suffix? ) $~ to_act $* from_act;
-
- # Integer decimal. Leading part buffered by float.
- ( ( '0' | [1-9] [0-9]* ) [ulUL]{0,3} ) $~ to_act $* from_act;
-
- # Integer octal. Leading part buffered by float.
- ( '0' [0-9]+ [ulUL]{0,2} ) $~ to_act $* from_act;
-
- # Integer hex. Leading 0 buffered by float.
- ( '0x' [0-9a-fA-F]+ [ulUL]{0,2} ) $~ to_act $* from_act;
-
- # Three char compounds, first item already buffered. */
- ( '...' ) $~ to_act $* from_act;
-
- # Single char symbols.
- ( punct - [_"'] ) $~ to_act $* from_act;
-
- # Comments and whitespace.
- ( '/*' ) $~ to_act $* from_act { fgoto c_comm; };
- ( '//' ) $~ to_act $* from_act { fgoto cxx_comm; };
-
- ( any - 33..126 )+ $~ to_act $* from_act;
-
- *|;
-}%%
-
-%% write data;
-
-void Scanner::init( )
-{
- %% write init;
-}
-
-int Scanner::execute( char *data, int len )
-{
- char *p = data;
- char *pe = data + len;
- char *eof = pe;
-
- %% write exec;
-
- return 0;
-}
-
-int Scanner::finish( )
-{
- if ( cs == Scanner_error )
- return -1;
- if ( cs >= Scanner_first_final )
- return 1;
- return 0;
-}
-
-void test( )
-{
- int len = strlen( buf );
- Scanner scanner;
-
- scanner.init();
- scanner.execute( buf, len );
- if ( scanner.cs == Scanner_error ) {
- /* Machine failed before finding a token. */
- cout << "PARSE ERROR" << endl;
- }
- scanner.finish();
-}
-
-char buf[4096];
-
-int main()
-{
- strcpy( buf,
- "a b 0.98 /*\n"
- "9 */'\\''//hi\n"
- "there\n"
- );
- test();
- return 0;
-}
-
-##### OUTPUT #####
-from: fc = a ts = 0
-to: fc = a ts = 0
-from: fc = ts = 0
-to: fc = a ts = -1
-from: fc = ts = 1
-to: fc = ts = 1
-from: fc = b ts = 1
-to: fc = ts = -1
-from: fc = b ts = 2
-to: fc = b ts = 2
-from: fc = ts = 2
-to: fc = b ts = -1
-from: fc = ts = 3
-to: fc = ts = 3
-from: fc = 0 ts = 3
-to: fc = ts = -1
-from: fc = 0 ts = 4
-to: fc = 0 ts = 4
-from: fc = . ts = 4
-to: fc = . ts = 4
-from: fc = 9 ts = 4
-to: fc = 9 ts = 4
-from: fc = 8 ts = 4
-to: fc = 8 ts = 4
-from: fc = ts = 4
-to: fc = 8 ts = -1
-from: fc = ts = 8
-to: fc = ts = 8
-from: fc = / ts = 8
-to: fc = ts = -1
-from: fc = / ts = 9
-to: fc = / ts = 9
-from: fc = * ts = 9
-to: fc = * ts = -1
-from: fc =
- ts = -1
-to: fc =
- ts = -1
-from: fc = 9 ts = -1
-to: fc = 9 ts = -1
-from: fc = ts = -1
-to: fc = ts = -1
-from: fc = * ts = -1
-to: fc = * ts = -1
-from: fc = / ts = -1
-to: fc = / ts = -1
-from: fc = 39 ts = 16
-to: fc = 39 ts = 16
-from: fc = \ ts = 16
-to: fc = \ ts = 16
-from: fc = 39 ts = 16
-to: fc = 39 ts = 16
-from: fc = 39 ts = 16
-to: fc = 39 ts = -1
-from: fc = / ts = 20
-to: fc = / ts = 20
-from: fc = / ts = 20
-to: fc = / ts = -1
-from: fc = h ts = -1
-to: fc = h ts = -1
-from: fc = i ts = -1
-to: fc = i ts = -1
-from: fc =
- ts = -1
-to: fc =
- ts = -1
-from: fc = t ts = 25
-to: fc = t ts = 25
-from: fc = h ts = 25
-to: fc = h ts = 25
-from: fc = e ts = 25
-to: fc = e ts = 25
-from: fc = r ts = 25
-to: fc = r ts = 25
-from: fc = e ts = 25
-to: fc = e ts = 25
-from: fc =
- ts = 25
-to: fc = e ts = -1
-from: fc =
- ts = 30
-to: fc =
- ts = 30
-from: fc = EOF ts = 30
-to: fc =
- ts = -1
-from: fc = EOF ts = 31
diff --git a/test/ragel.d/trans-asm.lm b/test/ragel.d/trans-asm.lm
deleted file mode 100644
index 4c1ad188..00000000
--- a/test/ragel.d/trans-asm.lm
+++ /dev/null
@@ -1,647 +0,0 @@
-global Label: int = 1
-
-int rw_asm_factor( Factor: indep::factor )
-{
- switch Factor
- #if match Factor [`first_token_char]
- #{
- # send Out "ts\[0\]"
- #}
- #else if match Factor [tk_ident `[ expr `]]
- #{
- # send Out
- # "[$Factor.tk_ident]\[ [rw_c_expr(Factor.expr)] \]
- #}
- #else if match Factor [tk_ident `( expr `)]
- #{
- # send Out
- # "[$Factor.tk_ident]( [rw_c_expr(Factor.expr)] )
- #}
- case [`< type `> `( expr `)] {
- rw_asm_expr( Factor.expr )
- }
- case [`( expr `)] {
- rw_asm_expr( Factor.expr )
- }
- case ['true'] {
- send Out
- " movq $1, %rax
- " pushq %rax
- }
- case ['false'] {
- send Out
- " movq $0, %rax
- " pushq %rax
- }
- case [`fentry `( E: expr `)] {
- send Out
- " movq $fentry([E]), %rax
- " pushq %rax
- }
- case [`fc] {
- send Out
- " movsbq (%r12), %rax
- " pushq %rax
- }
- case [`fcurs] {
- send Out
- " fcurs;
- " pushq %rax
- }
- case [`ftargs] {
- send Out
- " ftargs;
- " pushq %rax
- }
- case ["p"] {
- send Out
- " pushq %r12
- }
- case ["te"] {
- send Out
- " movq -24(%rbp), %rax
- " pushq %rax
- }
- case [Ident: tk_ident] {
- send Out
- " movq [Ident](%rip), %rax
- " pushq %rax
- }
- case [Number: tk_number] {
- send Out
- " movq $[Number], %rax
- " pushq %rax
- }
- case [`- Number: tk_number] {
- send Out
- " movq $-[Number], %rax
- " pushq %rax
-
- }
- case "'0'" {
- send Out
- " movq $48, %rax
- " pushq %rax
- }
- case "'a'" {
- send Out
- " movq $97, %rax
- " pushq %rax
- }
- case [String: string] {
- send Out
- " .section .rodata
- "[Label]:
- " .string [String]
- " .text
- " movq $[Label]b, %rax
- " pushq %rax
- Label = Label + 1
- }
- case [`buffer] {
- send Out
- " movq $buf, %rax
- " pushq %rax
- }
- case [`blen] {
- send Out
- " movq bpos(%rip), %rax
- " pushq %rax
- }
- case [`first_token_char]
- {
- # Tokstart: -16
- send Out
- " movq -16(%rbp), %rax
- " movsbq (%rax), %rcx
- " pushq %rcx
- }
- default {
- send Out
- "NOT IMPELMENTED
- "[Factor]
- }
- #else
- #{
- # send Out [$Factor]
- #}
-}
-
-void rw_asm_abs_expr( Expr: indep::abs_expr )
-{
- if ( Expr.Op ) {
- rw_asm_abs_expr( Expr.E1 )
- rw_asm_abs_expr( Expr.E2 )
-
- send Out
- " popq %rcx
- " popq %rax
-
- switch Expr.Op
- case [`+] {
- send Out
- " addq %rcx, %rax
- }
- case [`-] {
- send Out
- " subq %rcx, %rax
- }
- case [`*] {
- send Out
- " imul %rcx, %rax
- }
- case [`==] {
- send Out
- " cmp %rcx, %rax
- " sete %al
- " movsbq %al, %rax
- }
- case [`!=] {
- send Out
- " cmp %rcx, %rax
- " setne %al
- " movsbq %al, %rax
- }
- case [`>=] {
- send Out
- " cmp %rcx, %rax
- " setge %al
- " movsbq %al, %rax
- }
- case [`>] {
- send Out
- " cmp %rcx, %rax
- " setg %al
- " movsbq %al, %rax
- }
- case [`<=] {
- send Out
- " cmp %rax, %rcx
- " setge %al
- " movsbq %al, %rax
- }
- case [`<] {
- send Out
- " cmp %rax, %rcx
- " setg %al
- " movsbq %al, %rax
- }
-
- send Out
- " pushq %rax
- }
- else {
- rw_asm_factor( Expr.factor )
- }
-}
-
-void rw_asm_expr( Expr: indep::expr )
-{
- AbsExpr: indep::abs_expr = indep::abs_comparative( Expr.comparative )
- rw_asm_abs_expr( AbsExpr )
-}
-
-int rw_asm_print_stmt( Stmt: indep::print_stmt )
-{
- switch Stmt
- case [`print_int expr `;] {
- rw_asm_expr( Stmt.expr )
-
- send Out
- " movq $.L_fmt_int, %rdi
- " popq %rsi
- " movq $0, %rax
- " call printf
- }
- case [`print_buf `;] {
- #send Out
- # "fwrite( [rw_c_expr(E1)], 1, [rw_c_expr(E2)], stdout );"
- }
- case [`print_str expr `;] {
- rw_asm_expr( Stmt.expr )
-
- send Out
- " movq $.L_fmt_str, %rdi
- " popq %rsi
- " movq $0, %rax
- " call printf
- }
- case [`print_token `;] {
- L1: int = Label
- Label = Label + 1
-
- L2: int = Label
- Label = Label + 1
-
- send Out
- " movq -16(%rbp), %rax # ts
- " movq -24(%rbp), %rcx # te
- " subq %rax, %rcx # length
- "[L1]:
- " cmp $0, %rcx
- " je [L2]f
- " movsbl (%rax), %edi
- " push %rax
- " push %rcx
- " call putchar
- " pop %rcx
- " pop %rax
- " addq $1, %rax
- " subq $1, %rcx
- " jmp [L1]b
- "[L2]:
- "
- }
- case [`print_off `;] {
- send Out
- " movq %r12, %rax
- " movq -112(%rbp), %rcx
- " subq %rcx, %rax
- " movq $.L_fmt_int, %rdi
- " movq %rax, %rsi
- " movq $0, %rax
- " call printf
- }
-}
-
-int rw_asm_expr_stmt( ExprStmt: indep::expr_stmt )
-{
- switch ExprStmt
- case [tk_ident opt_sub `= expr `;]
- {
- rw_asm_expr( ExprStmt.expr )
-
- send Out
- " popq %rax
- " movq %rax, [ExprStmt.tk_ident](%rip)
- }
- case [expr `;]
- {
- rw_asm_expr( ExprStmt.expr )
- send Out
- " popq %rax
- }
-}
-
-int rw_asm_if_stmt( IfStmt: indep::if_stmt )
-{
- L1: int = Label
- Label = Label + 1
-
- L2: int = Label
- Label = Label + 1
-
- rw_asm_expr( IfStmt.expr )
-
- send Out
- " popq %rax
- " test %rax, %rax
- " jz [L1]f
-
- rw_asm_stmt_list( IfStmt._repeat_stmt )
-
- if ( IfStmt.opt_else._repeat_stmt ) {
- send Out
- " jmp [L2]f
- "[L1]:
-
- rw_asm_stmt_list( IfStmt.opt_else._repeat_stmt )
-
- send Out
- "[L2]:
- }
- else {
- send Out
- "[L1]:
- }
-
-}
-
-void rw_asm_buf_stmt( BufStmt: indep::buf_stmt )
-{
- switch BufStmt
- case [`buf_clear `( `) `;] {
- send Out
- " movq $0, bpos(%rip)
- }
- case [`buf_append `( `) `;] {
- send Out
- " movq bpos(%rip), %rax
- " movb (%r12), %cl
- ' movb %cl, buf(%rax)
- " addq $1, %rax
- " movb $0, buf(%rax)
- " movq %rax, bpos(%rip)
- }
-}
-
-int rw_asm_ragel_stmt( Stmt: indep::ragel_stmt )
-{
- switch Stmt
- case [`fexec E: expr `;] {
- rw_asm_expr( E )
-
- send Out
- " popq %rax
- " fexec %rax;
- }
- case [`fgoto `* E: expr `;] {
- rw_asm_expr( E )
- send Out
- "movq $0, %rax
- "popq %rcx
- "fgoto * %rcx;
- }
- case [`fnext `* E: expr `;] {
- rw_asm_expr( E )
- send Out
- "movq $0, %rax
- "popq %rcx
- "fnext * %rcx;
- }
- case [`fcall `* E: expr `;] {
- rw_asm_expr( E )
- send Out
- "movq $0, %rax
- "popq %rcx
- "fcall * %rcx;
- }
- case [`fncall `* E: expr `;] {
- rw_asm_expr( E )
- send Out
- "movq $0, %rax
- "popq %rcx
- "fncall * %rcx;
- }
- default {
- send Out
- "[Stmt]
- }
-}
-
-int rw_asm_stmt( Stmt: indep::stmt )
-{
- switch Stmt
- case [var_decl] {
- #rw_c_var_decl( Stmt.var_decl )
- }
- case [expr_stmt]
- rw_asm_expr_stmt( Stmt.expr_stmt )
- case [if_stmt]
- rw_asm_if_stmt( Stmt.if_stmt )
- case [print_stmt]
- rw_asm_print_stmt( Stmt.print_stmt )
- case [buf_stmt]
- rw_asm_buf_stmt( Stmt.buf_stmt )
- case [ragel_stmt]
- rw_asm_ragel_stmt( Stmt.ragel_stmt )
-}
-
-void rw_asm_stmt_list( StmtList: indep::stmt* )
-{
- for Stmt: indep::stmt in repeat( StmtList )
- rw_asm_stmt( Stmt )
-}
-
-out_code::lines rw_asm_asm_action_block( ActionBlock: indep::action_block, ActionNum: int )
-{
- Out = new parser<out_code::lines>()
- if match ActionBlock [`{ stmt* `}] {
- send Out
- "{
- " [rw_asm_stmt_list( ActionBlock._repeat_stmt )]
- "}
- }
- else if match ActionBlock [`{ expr `}] {
- send Out
- "{
- " [rw_asm_expr( ActionBlock.expr )]
- " popq %rax
- "}
- }
- send Out [] eos
- return Out->tree
-}
-
-int rw_asm_var_decl( VarDecl: indep::var_decl )
-{
- send Out
- " .section .data
- " .comm [VarDecl.tk_ident],8,8
- " .text
-}
-
-
-void rw_asm( Output: stream )
-{
- send Output
- "#
- "# @LANG: asm
- "# @GENERATED: true
-
- if ProhibitGenflags {
- send Output
- "# @PROHIBIT_GENFLAGS:[ProhibitGenflags]
- }
-
- send Output
- "#
- "
-
- Init: indep::stmt* = RagelTree.Init
- for Stmt: indep::stmt in Init {
- if match Stmt [Decl: var_decl] {
- Out = new parser<out_code::lines>()
- rw_asm_var_decl( Decl )
- send Out [] eos
-
- send Output
- [Out->tree]
- }
- }
-
- ActionNum: int = 0
- Section: indep::section = RagelTree.section
- for Action: ragel::action_block in Section {
- # Reparse as lang-independent code.
- parse IndepActionBlock: indep::action_block[$Action]
- if ( !IndepActionBlock ) {
- print( error, '\n', Action )
- exit(1)
- }
-
- Lines: out_code::lines =
- rw_asm_asm_action_block( IndepActionBlock, ActionNum )
-
- # Reparse back to ragel action block.
- Action = parse ragel::action_block[Lines]
- if ( !Action ) {
- print( error, ': could not reparse action: ', Lines, '\n' )
- exit(1)
- }
-
- ActionNum = ActionNum + 1
- }
-
- send Output
- "
- "[Section]
- "
- " .text
- " .comm buf, 1024, 32
- " .comm bpos, 8, 8
- " .comm stack_data, 1024, 32
- " .section .rodata
- "
- ".L_str_accept:
- " .string \"ACCEPT\"
- ".L_str_fail:
- " .string \"FAIL\"
- ".L_fmt_int:
- " .string \"%ld\"
- ".L_fmt_str:
- " .string \"%s\"
- "
- " %% write data;
- "
- " .text
- "exec:
- " pushq %rbp
- " movq %rsp, %rbp
- "
- " # Ragel requires 96 bytes, we include one word for the data pointer.
- " subq $112, %rsp
- "
- " movq $stack_data, -56(%rbp)
- "
- " movq nfa_bp@GOTPCREL(%rip), %rax
- " movq %rax, -80(%rbp)
- " movq $0, -88(%rbp)
- "
- " pushq %r12
- " pushq %r13
- " movq %rdi, %r12
- "
- " # Save data pointer for use in actions.
- " movq %rdi, -112(%rbp)
-
-
- for Stmt: indep::stmt in Init {
- if match Stmt [ExprStmt: expr_stmt] {
- Out = new parser<out_code::lines>()
- rw_asm_expr_stmt( ExprStmt )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- send Output
- "
- " # Get the length.
- " movq %r12, %rdi
- " call strlen
- " movq %r12, %r13
- " movslq %eax, %rax
- " addq %rax, %r13
- "
- " movq $0, bpos(%rip)
-
- if NeedsEof {
- send Output
- " movq %r13, -8(%rbp)
- }
-
- send Output
- "
- " %% write init;
- " %% write exec;
- "
- " # current state is in r11.
- " movq [MachineName.mn_word]_first_final(%rip), %rax
- " cmpq %rax, %r11
- " jl .L_exec_fail
- " movq $.L_str_accept, %rdi
- " call puts
- " jmp .L_exec_done
- ".L_exec_fail:
- " movq $.L_str_fail, %rdi
- " call puts
- ".L_exec_done:
- " popq %r13
- " popq %r12
- " leave
- " ret
-
- send Output
- " .section .rodata
- ".L_debug_msg:
- " .string \"debug %d\\n\"
-
- NR: int = 0
- for InputString: indep::input_string in RagelTree {
- send Output
- ".L_inp_[NR]:
- " .string [^InputString]
- NR = NR + 1
- }
-
- send Output
- "
- " .align 8
- "inp:
-
- NR = 0
- for InputString: indep::input_string in RagelTree {
- send Output
- " .quad .L_inp_[NR]
- NR = NR + 1
- }
-
- send Output
- "
-
-
- send Output
- " .align 8
- "inplen:
- " .quad [NR]
- "
- " .bss
- " .align 16
- " .type nfa_len, @object
- " .size nfa_len, 8
- "nfa_len:
- " .zero 8
- " .comm nfa_bp,16384,32
- " .comm nfa_s,16384,32
- "
-
- send Output
- " .text
- " .globl main
- "main:
- " pushq %rbp
- " movq %rsp, %rbp
- " pushq %r12
- " movq $0, %r12
- ".L_again:
- " movq inplen(%rip), %rax
- " cmpq %r12, %rax
- " je .L_done
- " movq inp(,%r12,8), %rdi
- " call exec
- " incq %r12
- " jmp .L_again
- ".L_done:
- " popq %r12
- " mov $0, %rax
- " leave
- " ret
- "debug:
- " movl %edi, %esi
- " movq $0, %rax
- " movq $.L_debug_msg, %rdi
- " call printf
- " ret
- "
-}
diff --git a/test/ragel.d/trans-c.lm b/test/ragel.d/trans-c.lm
deleted file mode 100644
index 108c3c44..00000000
--- a/test/ragel.d/trans-c.lm
+++ /dev/null
@@ -1,353 +0,0 @@
-int rw_c_factor( Factor: indep::factor )
-{
- if match Factor [`first_token_char]
- {
- send Out "ts\[0\]"
- }
- else if match Factor [tk_ident `[ expr `]]
- {
- send Out
- "[$Factor.tk_ident]\[ [rw_c_expr(Factor.expr)] \]
- }
- else if match Factor [tk_ident `( expr `)]
- {
- send Out
- "[$Factor.tk_ident]( [rw_c_expr(Factor.expr)] )
- }
- elsif match Factor [`< type `> `( expr `)]
- {
- send Out
- "( [rw_c_type(Factor.type)] ) ( [rw_c_expr(Factor.expr)] )
- }
- elsif match Factor [`( expr `)]
- {
- send Out
- "( [rw_c_expr(Factor.expr)] )
- }
- elsif match Factor ['true']
- {
- send Out '1'
- }
- elsif match Factor ['false']
- {
- send Out '0'
- }
- else
- {
- send Out [$Factor]
- }
-}
-
-void rw_c_type( Type: indep::type )
-{
- if match Type [`int]
- {
- send Out "int"
- }
- elsif match Type [`bool]
- {
- send Out "int"
- }
- elsif match Type [`char]
- {
- send Out "char"
- }
- elsif match Type [`ptr]
- {
- send Out "char *"
- }
- elsif match Type [`byte]
- {
- send Out "unsigned char"
- }
-}
-
-void rw_c_abs_expr( Expr: indep::abs_expr )
-{
- if ( Expr.Op ) {
- send Out
- "[rw_c_abs_expr(Expr.E1)] [$Expr.Op] [rw_c_abs_expr( Expr.E2 )]"
- }
- else {
- rw_c_factor( Expr.factor )
- }
-}
-
-void rw_c_expr( Expr: indep::expr )
-{
- AbsExpr: indep::abs_expr = indep::abs_comparative( Expr.comparative )
- rw_c_abs_expr( AbsExpr )
-}
-
-void rw_c_opt_array( OptArr: indep::opt_arr )
-{
- if OptArr.expr {
- send Out "\[[rw_c_expr( OptArr.expr )]\]"
- }
-}
-
-int rw_c_var_decl( VarDecl: indep::var_decl )
-{
- send Out
- "[rw_c_type( VarDecl.type )] [$VarDecl.tk_ident] [rw_c_opt_array(VarDecl.opt_arr)];
-}
-
-void rw_c_opt_sub( OptSub: indep::opt_sub )
-{
- if ( OptSub.expr )
- send Out "\[[rw_c_expr(OptSub.expr)]\]"
-}
-
-int rw_c_expr_stmt( ExprStmt: indep::expr_stmt )
-{
- if match ExprStmt [tk_ident opt_sub `= expr `;]
- {
- send Out
- "[$ExprStmt.tk_ident rw_c_opt_sub(ExprStmt.opt_sub)] = [rw_c_expr(ExprStmt.expr)];
- }
- else if match ExprStmt [expr `;]
- {
- send Out
- "[rw_c_expr(ExprStmt.expr)];
- }
-}
-
-int rw_c_if_stmt( IfStmt: indep::if_stmt )
-{
- send Out
- "if ( [rw_c_expr( IfStmt.expr )] )
- "{
- " [rw_c_stmt_list( IfStmt._repeat_stmt )]
- "}
-
- if ( IfStmt.opt_else._repeat_stmt ) {
- send Out
- "else {
- " [rw_c_stmt_list( IfStmt.opt_else._repeat_stmt )]
- "}
- }
-}
-
-int rw_c_print_stmt( Stmt: indep::print_stmt )
-{
- if match Stmt [`print_int expr `;] {
- send Out
- "printf( \"%d\", [rw_c_expr(Stmt.expr)] );
- }
- else if match Stmt [`print_buf `;]
- {
- send Out
- "printf( \"%s\", buffer );
- }
- else if match Stmt [`print_str expr `;]
- {
- send Out
- "printf( \"%s\", [rw_c_expr( Stmt.expr )] );
- }
- else if match Stmt [`print_token `;]
- {
- send Out
- "fwrite ( ts , 1 , te - ts , stdout );"
- }
- else if match Stmt [`print_off `;]
- {
- send Out
- "printf( \"%d\", (int)(p - data) );"
- }
-}
-
-int rw_c_ragel_stmt( Stmt: indep::ragel_stmt )
-{
- send Out
- [$Stmt]
-}
-
-void rw_c_buf_stmt( BufStmt: indep::buf_stmt )
-{
- switch BufStmt
- case [`buf_clear `( `) `;] {
- send Out
- " blen = 0;
- }
- case [`buf_append `( `) `;] {
- send Out
- " buffer\[blen++\] = *p;
- " buffer\[blen\] = 0;
- }
-}
-
-
-int rw_c_stmt( Stmt: indep::stmt )
-{
- switch Stmt
- case [var_decl]
- rw_c_var_decl( Stmt.var_decl )
- case [expr_stmt]
- rw_c_expr_stmt( Stmt.expr_stmt )
- case [if_stmt]
- rw_c_if_stmt( Stmt.if_stmt )
- case [print_stmt]
- rw_c_print_stmt( Stmt.print_stmt )
- case [buf_stmt]
- rw_c_buf_stmt( Stmt.buf_stmt )
- case [ragel_stmt]
- rw_c_ragel_stmt( Stmt.ragel_stmt )
-}
-
-void rw_c_stmt_list( StmtList: indep::stmt* )
-{
- for Stmt: indep::stmt in repeat( StmtList )
- rw_c_stmt( Stmt )
-}
-
-out_code::lines rw_c_action_block( ActionBlock: indep::action_block )
-{
- Out = new parser<out_code::lines>()
- if match ActionBlock [`{ stmt* `}] {
- send Out
- "{[rw_c_stmt_list( ActionBlock._repeat_stmt )]}
- }
- else if match ActionBlock [`{ expr `}] {
- send Out
- "{[rw_c_expr( ActionBlock.expr )]}
- }
- send Out [] eos
- return Out->tree
-}
-
-void rw_c( Output: stream )
-{
- send Output
- "/*
- " * @LANG: c
- " * @GENERATED: true
-
- if ProhibitGenflags {
- send Output
- " * @PROHIBIT_GENFLAGS:[ProhibitGenflags]
- }
-
- send Output
- " */
- "
- "#include <string.h>
- "#include <stdio.h>
- "
-
- Init: indep::stmt* = RagelTree.Init
- for Stmt: indep::stmt in Init {
- if match Stmt [Decl: var_decl] {
- Out = new parser<out_code::lines>()
- rw_c_var_decl( Decl )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- Section: indep::section = RagelTree.section
- for Action: ragel::action_block in Section {
- # Reparse as lang-independent code.
- parse IndepActionBlock: indep::action_block[$Action]
- if ( !IndepActionBlock ) {
- print( error, '\n', Action )
- exit(1)
- }
-
- Lines: out_code::lines =
- rw_c_action_block( IndepActionBlock )
-
- # Reparse back to ragel action block.
- Action = parse ragel::action_block[Lines]
- if ( !Action ) {
- print( error, '\n' )
- exit(1)
- }
- }
-
- send Output
- "
- "[Section]
- "
- "%% write data;
- "int cs;
- "int blen;
- "char buffer\[1024\];
- "int nfa_len, nfa_count;
- "struct nfa_s { int state; char *p; } nfa_bp\[20\];
- "
- "void init()
- "{
-
- for Stmt: indep::stmt in Init {
- if match Stmt [ExprStmt: expr_stmt] {
- Out = new parser<out_code::lines>()
- rw_c_expr_stmt( ExprStmt )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- send Output
- " %% write init;
- "}
- "
- "void exec( char *data, int len )
- "{
- " char *p = data;
- " char *pe = data + len;
-
- if NeedsEof {
- send Output
- " char *eof = pe;
- }
-
- send Output
- " %% write exec;
- "}
- "
- "void finish( )
- "{
- " if ( cs >= [$MachineName.mn_word]_first_final )
- " printf( \"ACCEPT\\n\" );
- " else
- " printf( \"FAIL\\n\" );
- "}
- "
-
- send Output
- "char *inp\[\] = {
-
- NR: int = 0
- for InputString: indep::input_string in RagelTree {
- send Output
- [^InputString ",\n"]
- NR = NR + 1
- }
-
- send Output
- "};
- "
-
- send Output
- "int inplen = [NR];
- "
-
- send Output
- "int main( )
- "{
- " int i;
- " for ( i = 0; i < inplen; i++ ) {
- " init();
- " exec( inp\[i\], strlen(inp\[i\]) );
- " finish();
- " }
- " return 0;
- "}
- "
-
-# send Output
-# "##### OUTPUT #####
-#
-# for OutputLine: indep::output_line in RagelTree
-# send Output [OutputLine]
-}
diff --git a/test/ragel.d/trans-crack.lm b/test/ragel.d/trans-crack.lm
deleted file mode 100644
index ba2ed1cc..00000000
--- a/test/ragel.d/trans-crack.lm
+++ /dev/null
@@ -1,349 +0,0 @@
-namespace trans_crack
-
-int factor( Factor: indep::factor )
-{
- if match Factor [`first_token_char]
- {
- send Out "data\[ts\]"
- }
- else if match Factor [tk_ident `[ expr `]]
- {
- send Out
- "[$Factor.tk_ident]\[ [expr(Factor.expr)] \]
- }
- else if match Factor [tk_ident `( expr `)]
- {
- send Out
- "[$Factor.tk_ident]( [expr(Factor.expr)] )
- }
- elsif match Factor [`< type `> `( expr `)]
- {
- send Out
- "( [type(Factor.type)] ( [expr(Factor.expr)] ) )
- }
- elsif match Factor [`( expr `)]
- {
- send Out
- "( [expr(Factor.expr)] )
- }
- elsif match Factor ['true']
- {
- send Out '1'
- }
- elsif match Factor ['false']
- {
- send Out '0'
- }
- elsif match Factor [`buffer]
- {
- send Out
- "buffer"
- }
- elsif match Factor [`blen]
- {
- send Out
- "buffer.size"
- }
- else
- {
- send Out [$Factor]
- }
-}
-
-void type( Type: indep::type )
-{
- switch Type
- case [`int]
- {
- send Out "int"
- }
- case [`bool]
- {
- send Out "int"
- }
- case [`char]
- {
- send Out "byte"
- }
- case [`ptr]
- {
- send Out "int
- }
- case [`byte]
- {
- send Out "byte"
- }
-}
-
-void abs_expr( Expr: indep::abs_expr )
-{
- if ( Expr.Op ) {
- send Out
- "[abs_expr(Expr.E1)] [$Expr.Op] [abs_expr( Expr.E2 )]"
- }
- else {
- factor( Expr.factor )
- }
-}
-
-void expr( Expr: indep::expr )
-{
- AbsExpr: indep::abs_expr = indep::abs_comparative( Expr.comparative )
- abs_expr( AbsExpr )
-}
-
-void array_init( Size: int )
-{
- while ( Size > 1 ) {
- send Out
- "0, "
- Size = Size - 1
- }
-
- if ( Size > 0 ) {
- send Out
- "0"
- }
-}
-
-int var_decl( VarDecl: indep::var_decl )
-{
- if VarDecl.opt_arr.expr {
- send Out
- "array\[[type( VarDecl.type )]\] [VarDecl.tk_ident] = "
- "\[ [array_init( atoi($VarDecl.opt_arr.expr) )] \];
- }
- else {
- send Out
- "[type( VarDecl.type )] [VarDecl.tk_ident];
- }
-}
-
-void opt_sub( OptSub: indep::opt_sub )
-{
- if ( OptSub.expr )
- send Out "\[[expr(OptSub.expr)]\]"
-}
-
-int expr_stmt( ExprStmt: indep::expr_stmt )
-{
- if match ExprStmt [tk_ident opt_sub `= expr `;]
- {
- send Out
- "[$ExprStmt.tk_ident opt_sub(ExprStmt.opt_sub)] = [expr(ExprStmt.expr)];
- }
- else if match ExprStmt [expr `;]
- {
- send Out
- "[expr(ExprStmt.expr)];
- }
-}
-
-int if_stmt( IfStmt: indep::if_stmt )
-{
- send Out
- "if ( [expr( IfStmt.expr )] )
- "{
- " [stmt_list( IfStmt._repeat_stmt )]
- "}
-
- if ( IfStmt.opt_else._repeat_stmt ) {
- send Out
- "else {
- " [stmt_list( IfStmt.opt_else._repeat_stmt )]
- "}
- }
-}
-
-int print_stmt( Stmt: indep::print_stmt )
-{
- switch Stmt
- case [`print_int expr `;] {
- send Out
- "cout.format( [expr(Stmt.expr)] );
- }
- case [`print_buf `;]
- {
- send Out
- "cout.format( buffer );
- }
- case [`print_str expr `;]
- {
- send Out
- "cout.format( [expr( Stmt.expr )] );
- }
- case [`print_token `;]
- {
- send Out
- "int len = uintz(te) - uintz(ts);
- "cout.write( Buffer(data + uintz(ts), len) );
- }
-}
-
-void buf_stmt( BufStmt: indep::buf_stmt )
-{
- switch BufStmt
- case [`buf_clear `( `) `;] {
- send Out
- " buffer = \"\";
- }
- case [`buf_append `( `) `;] {
- send Out
- " buffer = buffer + fc;
- }
-}
-
-
-int ragel_stmt( Stmt: indep::ragel_stmt )
-{
- send Out
- [$Stmt]
-}
-
-int stmt( Stmt: indep::stmt )
-{
- switch Stmt
- case [var_decl]
- var_decl( Stmt.var_decl )
- case [expr_stmt]
- expr_stmt( Stmt.expr_stmt )
- case [if_stmt]
- if_stmt( Stmt.if_stmt )
- case [print_stmt]
- print_stmt( Stmt.print_stmt )
- case [buf_stmt]
- buf_stmt( Stmt.buf_stmt )
- case [ragel_stmt]
- ragel_stmt( Stmt.ragel_stmt )
-}
-
-void stmt_list( StmtList: indep::stmt* )
-{
- for Stmt: indep::stmt in repeat( StmtList )
- stmt( Stmt )
-}
-
-int action_block( ActionBlock: indep::action_block )
-{
- Out = new parser<out_code::lines>()
- if match ActionBlock [`{ stmt* `}] {
- send Out
- "{[stmt_list( ActionBlock._repeat_stmt )]}
- }
- else if match ActionBlock [`{ expr `}] {
- send Out
- "{[expr( ActionBlock.expr )]}
- }
- send Out [] eos
-}
-
-void crack( Output: stream )
-{
- # Translate action blocks.
- Section: indep::section = RagelTree.section
- for Action: ragel::action_block in Section {
- # Reparse as lang-independent code.
- parse IndepActionBlock: indep::action_block[$Action]
- if ( !IndepActionBlock ) {
- print( error, '\n', Action )
- exit(1)
- }
-
- action_block( IndepActionBlock )
-
- # Reparse back to ragel action block.
- Action = parse ragel::action_block[$Out->tree]
- if ( !Action ) {
- print( error, '\n' )
- exit(1)
- }
- }
-
- send Output
- "//
- "// @LANG: crack
- "// @GENERATED: true
-
- if ProhibitGenflags {
- send Output
- "// @PROHIBIT_GENFLAGS:[ProhibitGenflags]
- }
-
- send Output
- "//
- "
- "import crack.io cout;
- "import crack.lang Buffer;
- "
-
- Init: indep::stmt* = RagelTree.Init
- for Stmt: indep::stmt in Init {
- if match Stmt [Decl: var_decl] {
- Out = new parser<out_code::lines>()
- var_decl( Decl )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- send Output
- "
- "[Section]
- "
- "%% write data;
- "
- "void m( String s )
- "{
- " byteptr data = s.buffer;
- " int p = 0;
- " int pe = s.size;
- " int cs;
- " int nfa_len, nfa_count;
- " array\[int\] nfa_bp_state = {20};
- " array\[int\] nfa_bp_p = {20};
- " String buffer;
-
- if NeedsEof {
- send Output
- " int eof = pe;
- }
-
- for Stmt: indep::stmt in Init {
- if match Stmt [ExprStmt: expr_stmt] {
- Out = new parser<out_code::lines>()
- expr_stmt( ExprStmt )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- send Output
- "
- " %% write init;
- " %% write exec;
- "
- " if ( cs >= [MachineName.mn_word]_first_final ) {
- " cout `ACCEPT\\n`;
- " }
- " else {
- " cout `FAIL\\n`;
- " }
- "}
-
- send Output
- ~
- ~void main()
- ~{
-
- for InputString: indep::input_string in RagelTree {
- send Output
- " m( [^InputString] );
- }
-
- send Output
- ~}
- ~
- ~main();
-}
-
-end
diff --git a/test/ragel.d/trans-csharp.lm b/test/ragel.d/trans-csharp.lm
deleted file mode 100644
index e546dafe..00000000
--- a/test/ragel.d/trans-csharp.lm
+++ /dev/null
@@ -1,354 +0,0 @@
-int rw_cs_factor( Factor: indep::factor )
-{
- if match Factor [`first_token_char]
- {
- send Out "data\[ts\]"
- }
- else if match Factor [tk_ident `[ expr `]]
- {
- send Out
- "[$Factor.tk_ident]\[ [rw_cs_expr(Factor.expr)] \]
- }
- else if match Factor [tk_ident `( expr `)]
- {
- send Out
- "[$Factor.tk_ident]( [rw_cs_expr(Factor.expr)] )
- }
- elsif match Factor [`< type `> `( expr `)]
- {
- send Out
- "( [rw_cs_type(Factor.type)] ) ( [rw_cs_expr(Factor.expr)] )
- }
- elsif match Factor [`( expr `)]
- {
- send Out
- "( [rw_cs_expr(Factor.expr)] )
- }
- elsif match Factor ['true']
- {
- send Out 'true'
- }
- elsif match Factor ['false']
- {
- send Out 'false'
- }
- elsif match Factor [`buffer]
- {
- send Out
- "new String( buffer, 0, blen )
- }
- else
- {
- send Out [$Factor]
- }
-}
-
-void rw_cs_type( Type: indep::type )
-{
- if match Type [`int]
- {
- send Out "int"
- }
- elsif match Type [`bool]
- {
- send Out "bool"
- }
- elsif match Type [`char]
- {
- send Out "char"
- }
- elsif match Type [`ptr]
- {
- send Out "int"
- }
- elsif match Type [`byte]
- {
- send Out "unsigned char"
- }
-}
-
-void rw_cs_abs_expr( Expr: indep::abs_expr )
-{
- if ( Expr.Op ) {
- send Out
- "[rw_cs_abs_expr(Expr.E1)] [$Expr.Op] [rw_cs_abs_expr( Expr.E2 )]"
- }
- else {
- rw_cs_factor( Expr.factor )
- }
-}
-
-void rw_cs_expr( Expr: indep::expr )
-{
- AbsExpr: indep::abs_expr = indep::abs_comparative( Expr.comparative )
- rw_cs_abs_expr( AbsExpr )
-}
-
-void rw_cs_opt_array( OptArr: indep::opt_arr )
-{
- if OptArr.expr
- send Out "\[[rw_cs_expr( OptArr.expr )]\]"
-}
-
-int rw_cs_var_decl( VarDecl: indep::var_decl )
-{
- if ( VarDecl.opt_arr.expr ) {
- send Out
- "[rw_cs_type( VarDecl.type )] \[\] [$VarDecl.tk_ident]"
- " = new [rw_cs_type( VarDecl.type )] [rw_cs_opt_array(VarDecl.opt_arr) ];
- }
- else {
- send Out
- "[rw_cs_type( VarDecl.type )] [$VarDecl.tk_ident];
- }
-}
-
-void rw_cs_opt_sub( OptSub: indep::opt_sub )
-{
- if ( OptSub.expr ) {
- send Out "\[[rw_cs_expr(OptSub.expr)]\]
- }
-}
-
-int rw_cs_expr_stmt( ExprStmt: indep::expr_stmt )
-{
- if match ExprStmt [tk_ident opt_sub `= expr `;]
- {
- send Out
- "[$ExprStmt.tk_ident rw_cs_opt_sub(ExprStmt.opt_sub)] = [rw_cs_expr(ExprStmt.expr)];
- }
- else if match ExprStmt [expr `;]
- {
- send Out
- "[rw_cs_expr(ExprStmt.expr)];
- }
-}
-
-int rw_cs_if_stmt( IfStmt: indep::if_stmt )
-{
- send Out
- "if ( [rw_cs_expr( IfStmt.expr )] )
- "{
- " [rw_cs_stmt_list( IfStmt._repeat_stmt )]
- "}
-
- if ( IfStmt.opt_else._repeat_stmt ) {
- send Out
- "else {
- " [rw_cs_stmt_list( IfStmt.opt_else._repeat_stmt )]
- "}
- }
-}
-
-int rw_cs_print_stmt( Stmt: indep::print_stmt )
-{
- if match Stmt [`print_int expr `;] {
- send Out
- "Console.Write( [rw_cs_expr(Stmt.expr)] );"
- }
- else if match Stmt [`print_buf `;]
- {
- send Out
- "Console.Write( new String( buffer, 0, blen ) );
- }
- else if match Stmt [`print_str expr `;]
- {
- send Out
- "Console.Write( [rw_cs_expr( Stmt.expr )] );"
- }
- else if match Stmt [`print_token `;]
- {
- send Out
- "Console.Write( new String( data , ts , te - ts ) );
- }
- else if match Stmt [`print_off `;]
- {
- send Out
- "Console.Write( p );"
- }
-}
-
-void rw_cs_buf_stmt( BufStmt: indep::buf_stmt )
-{
- switch BufStmt
- case [`buf_clear `( `) `;] {
- send Out
- " blen = 0;
- }
- case [`buf_append `( `) `;] {
- send Out
- " buffer\[blen++\] = fc;
- }
-}
-
-
-int rw_cs_ragel_stmt( Stmt: indep::ragel_stmt )
-{
- send Out
- [$Stmt]
-}
-
-int rw_cs_stmt( Stmt: indep::stmt )
-{
- if match Stmt [var_decl]
- rw_cs_var_decl( Stmt.var_decl )
- else if match Stmt [expr_stmt]
- rw_cs_expr_stmt( Stmt.expr_stmt )
- else if match Stmt [if_stmt]
- rw_cs_if_stmt( Stmt.if_stmt )
- else if match Stmt [print_stmt]
- rw_cs_print_stmt( Stmt.print_stmt )
- else if match Stmt [buf_stmt]
- rw_cs_buf_stmt( Stmt.buf_stmt )
- else if match Stmt [ragel_stmt]
- rw_cs_ragel_stmt( Stmt.ragel_stmt )
-}
-
-void rw_cs_stmt_list( StmtList: indep::stmt* )
-{
- for Stmt: indep::stmt in repeat( StmtList )
- rw_cs_stmt( Stmt )
-}
-
-int rw_cs_action_block( ActionBlock: indep::action_block )
-{
- Out = new parser<out_code::lines>()
- if match ActionBlock [`{ stmt* `}] {
- send Out
- "{[rw_cs_stmt_list( ActionBlock._repeat_stmt )]}
- }
- else if match ActionBlock [`{ expr `}] {
- send Out
- "{[rw_cs_expr( ActionBlock.expr )]}
- }
- send Out [] eos
-}
-
-void rw_csharp( Output: stream )
-{
- send Output
- "/*
- " * @LANG: csharp
-
- if ProhibitGenflags {
- send Output
- " * @PROHIBIT_GENFLAGS:[ProhibitGenflags]
- }
-
- send Output
- " * @GENERATED: true
- " */
- "
- "using System;
- "// Disables lots of warnings that appear in the test suite
- "#pragma warning disable 0168, 0169, 0219, 0162, 0414
- "namespace Test {
- "class Test
- "{
-
- Init: indep::stmt* = RagelTree.Init
- for Stmt: indep::stmt in Init {
- if match Stmt [Decl: var_decl] {
- Out = new parser<out_code::lines>()
- rw_cs_var_decl( Decl )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- Section: indep::section = RagelTree.section
- for Action: ragel::action_block in Section {
- # Reparse as lang-independent code.
- parse IndepActionBlock: indep::action_block[$Action]
- if ( !IndepActionBlock ) {
- print( error, '\n', Action )
- exit(1)
- }
-
- # Translate to specific language.
- rw_cs_action_block( IndepActionBlock )
-
- # Reparse back to ragel action block.
- Action = parse ragel::action_block[$Out->tree]
- if ( !Action ) {
- print( error, '\n' )
- exit(1)
- }
- }
-
- send Output
- ["\n" Section "\n"]
-
- send Output
- "%% write data;
- "int cs;
- "int nfa_len, nfa_count;
- "struct nfa_s { public int state; public int p; };
- "nfa_s \[\] nfa_bp = new nfa_s\[20\];
- "
- "void init()
- "{
-
- for Stmt: indep::stmt in Init {
- if match Stmt [ExprStmt: expr_stmt] {
- Out = new parser<out_code::lines>()
- rw_cs_expr_stmt( ExprStmt )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- send Output
- " %% write init;
- "}
- "
- "void exec( char\[\] data, int len )
- "{
- " int p = 0;
- " int pe = len;
- " int eof = len;
- " string _s;
- " char \[\] buffer = new char \[1024\];
- " int blen = 0;
- " %% write exec;
- "}
- "
- "void finish( )
- "{
- " if ( cs >= [$MachineName.mn_word]_first_final )
- " Console.WriteLine( \"ACCEPT\" );
- " else
- " Console.WriteLine( \"FAIL\" );
- "}
- "
-
- send Output
- "static readonly string\[\] inp = {
-
- NR: int = 0
- for InputString: indep::input_string in RagelTree {
- send Output
- [^InputString ",\n"]
- NR = NR + 1
- }
-
- send Output
- "};
- "
-
- send Output
- "
- "static readonly int inplen = [NR];
- "
- "public static void Main (string\[\] args)
- "{
- " Test machine = new Test();
- " for ( int i = 0; i < inplen; i++ ) {
- " machine.init();
- " machine.exec( inp\[i\].ToCharArray(), inp\[i\].Length );
- " machine.finish();
- " }
- "}
- "}
- "}
-}
diff --git a/test/ragel.d/trans-d.lm b/test/ragel.d/trans-d.lm
deleted file mode 100644
index 8176bc6b..00000000
--- a/test/ragel.d/trans-d.lm
+++ /dev/null
@@ -1,345 +0,0 @@
-int rw_d_factor( Factor: indep::factor )
-{
- if match Factor [`first_token_char]
- {
- send Out "ts\[0\]"
- }
- else if match Factor [tk_ident `[ expr `]]
- {
- send Out
- "[$Factor.tk_ident]\[ [rw_d_expr(Factor.expr)] \]
- }
- else if match Factor [tk_ident `( expr `)]
- {
- send Out
- "[$Factor.tk_ident]( [rw_d_expr(Factor.expr)] )
- }
- elsif match Factor [`< type `> `( expr `)]
- {
- send Out
- "cast( [rw_d_type(Factor.type)] ) ( [rw_d_expr(Factor.expr)] )
- }
- elsif match Factor [`( expr `)]
- {
- send Out
- "( [rw_d_expr(Factor.expr)] )
- }
- elsif match Factor ['true']
- {
- send Out '1'
- }
- elsif match Factor ['false']
- {
- send Out '0'
- }
- elsif match Factor [`buffer]
- {
- send Out
- "cast(string)buffer\[0..blen\]"
- }
- else
- {
- send Out [$Factor]
- }
-}
-
-void rw_d_type( Type: indep::type )
-{
- if match Type [`int]
- {
- send Out "int"
- }
- elsif match Type [`bool]
- {
- send Out "int"
- }
- elsif match Type [`char]
- {
- send Out "char"
- }
- elsif match Type [`ptr]
- {
- send Out "const(char) *"
- }
- elsif match Type [`byte]
- {
- send Out "unsigned char"
- }
-}
-
-void rw_d_abs_expr( Expr: indep::abs_expr )
-{
- if ( Expr.Op ) {
- send Out
- "[rw_d_abs_expr(Expr.E1)] [$Expr.Op] [rw_d_abs_expr( Expr.E2 )]"
- }
- else {
- rw_d_factor( Expr.factor )
- }
-}
-
-void rw_d_expr( Expr: indep::expr )
-{
- AbsExpr: indep::abs_expr = indep::abs_comparative( Expr.comparative )
- rw_d_abs_expr( AbsExpr )
-}
-
-void rw_d_opt_array( OptArr: indep::opt_arr )
-{
- if OptArr.expr {
- send Out "\[[rw_d_expr( OptArr.expr )]\]"
- }
-}
-
-int rw_d_var_decl( VarDecl: indep::var_decl )
-{
- send Out
- "[rw_d_type( VarDecl.type )][rw_d_opt_array(VarDecl.opt_arr)] [$VarDecl.tk_ident];
-}
-
-void rw_d_opt_sub( OptSub: indep::opt_sub )
-{
- if ( OptSub.expr )
- send Out "\[[rw_d_expr(OptSub.expr)]\]"
-}
-
-int rw_d_expr_stmt( ExprStmt: indep::expr_stmt )
-{
- if match ExprStmt [tk_ident opt_sub `= expr `;]
- {
- send Out
- "[$ExprStmt.tk_ident rw_d_opt_sub(ExprStmt.opt_sub)] = [rw_d_expr(ExprStmt.expr)];
- }
- else if match ExprStmt [expr `;]
- {
- send Out
- "[rw_d_expr(ExprStmt.expr)];
- }
-}
-
-int rw_d_if_stmt( IfStmt: indep::if_stmt )
-{
- send Out
- "if ( [rw_d_expr( IfStmt.expr )] )
- "{
- " [rw_d_stmt_list( IfStmt._repeat_stmt )]
- "}
-
- if ( IfStmt.opt_else._repeat_stmt ) {
- send Out
- "else {
- " [rw_d_stmt_list( IfStmt.opt_else._repeat_stmt )]
- "}
- }
-}
-
-int rw_d_print_stmt( Stmt: indep::print_stmt )
-{
- if match Stmt [`print_int expr `;] {
- send Out
- "write( [rw_d_expr(Stmt.expr)] );
- }
- else if match Stmt [`print_buf `;]
- {
- send Out
- "printf( \"%s\", &buffer );
- }
- else if match Stmt [`print_str expr `;]
- {
- send Out
- "write( [rw_d_expr(Stmt.expr)] );"
- }
- else if match Stmt [`print_token `;]
- {
- send Out
- "write( ts\[0..(te - ts)\] );"
- }
- else if match Stmt [`print_off `;]
- {
- send Out
- "write( (p - &data\[0\]) );"
- }
-}
-
-void rw_d_buf_stmt( BufStmt: indep::buf_stmt )
-{
- switch BufStmt
- case [`buf_clear `( `) `;] {
- send Out
- " blen = 0;
- }
- case [`buf_append `( `) `;] {
- send Out
- " buffer\[blen++\] = *p;
- " buffer\[blen\] = 0;
- }
-}
-
-int rw_d_ragel_stmt( Stmt: indep::ragel_stmt )
-{
- send Out
- [$Stmt]
-}
-
-int rw_d_stmt( Stmt: indep::stmt )
-{
- if match Stmt [var_decl]
- rw_d_var_decl( Stmt.var_decl )
- else if match Stmt [expr_stmt]
- rw_d_expr_stmt( Stmt.expr_stmt )
- else if match Stmt [if_stmt]
- rw_d_if_stmt( Stmt.if_stmt )
- else if match Stmt [print_stmt]
- rw_d_print_stmt( Stmt.print_stmt )
- else if match Stmt [buf_stmt]
- rw_d_buf_stmt( Stmt.buf_stmt )
- else if match Stmt [ragel_stmt]
- rw_d_ragel_stmt( Stmt.ragel_stmt )
-}
-
-void rw_d_stmt_list( StmtList: indep::stmt* )
-{
- for Stmt: indep::stmt in repeat( StmtList )
- rw_d_stmt( Stmt )
-}
-
-int rw_d_action_block( ActionBlock: indep::action_block )
-{
- Out = new parser<out_code::lines>()
- if match ActionBlock [`{ stmt* `}] {
- send Out
- "{[rw_d_stmt_list( ActionBlock._repeat_stmt )]}
- }
- else if match ActionBlock [`{ expr `}] {
- send Out
- "{[rw_d_expr( ActionBlock.expr )]}
- }
- send Out [] eos
-}
-
-void rw_d( Output: stream )
-{
- send Output
- "/*
- " * @LANG: d
-
- if ProhibitGenflags {
- send Output
- " * @PROHIBIT_GENFLAGS:[ProhibitGenflags]
- }
-
- send Output
- " * @GENERATED: true
- " */
- "
- "import std.stdio;
- "import std.string;
- "
- "class [MachineName.mn_word]
- "{
-
- Init: indep::stmt* = RagelTree.Init
- for Stmt: indep::stmt in Init {
- if match Stmt [Decl: var_decl] {
- Out = new parser<out_code::lines>()
- rw_d_var_decl( Decl )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- # Colm bug.
- Section: indep::section = RagelTree.section
- for Action: ragel::action_block in Section {
- # Reparse as lang-independent code.
- parse IndepActionBlock: indep::action_block[$Action]
-
- rw_d_action_block( IndepActionBlock )
-
- # Reparse back to ragel action block.
- Action = parse ragel::action_block[$Out->tree]
- }
-
- send Output
- "
- "[Section]
- "
- "%% write data;
- "int cs;
- "int blen;
- "char\[1024\] buffer;
- "int nfa_len, nfa_count;
- "struct nfa_s { int state; const(char)* p; };
- "nfa_s\[20\] nfa_bp;
- "
- "void init()
- "{
-
- for Stmt: indep::stmt in Init {
- if match Stmt [ExprStmt: expr_stmt] {
- Out = new parser<out_code::lines>()
- rw_d_expr_stmt( ExprStmt )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- send Output
- " %% write init;
- "}
-
- send Output
- "void exec( const(char)\[\] data )
- "{
- " const(char) *p = data.ptr;
- " const(char) *pe = data.ptr + data.length;
-
- if NeedsEof {
- send Output
- " const(char) *eof = pe;
- }
-
- send Output
- " char\[\] _s;
- "
- " %% write exec;
- "}
- "
- "void finish( )
- "{
- " if ( cs >= [MachineName.mn_word]_first_final )
- " writefln( \"ACCEPT\" );
- " else
- " writefln( \"FAIL\" );
- "}
-
- send Output
- ~static const char[][] inp = [
-
- NR: int = 0
- for InputString: indep::input_string in RagelTree {
- send Output [^InputString ",\n"]
- NR = NR + 1
- }
-
- send Output
- "\];
- "
- "int inplen = [NR];
- "
- "}
-
- send Output
- "int main()
- "{
- " [MachineName.mn_word] m = new [MachineName.mn_word]();
- " int i;
- " for ( i = 0; i < m.inplen; i++ ) {
- " m.init();
- " m.exec( m.inp\[i\] );
- " m.finish();
- " }
- " return 0;
- "}
- "
-}
diff --git a/test/ragel.d/trans-go.lm b/test/ragel.d/trans-go.lm
deleted file mode 100644
index d9543b33..00000000
--- a/test/ragel.d/trans-go.lm
+++ /dev/null
@@ -1,345 +0,0 @@
-include 'out-go.lm'
-
-global Out2: parser<out_go::out_go>
-
-parser<out_go::out_go> new_parser()
-{
- new P: parser<out_go::out_go>()
- Input: _input = P->gets()
- Input->auto_trim( true )
- return P
-}
-
-int rw_go_factor( Factor: indep::factor )
-{
- if match Factor [`first_token_char]
- {
- send Out2 "data\[ts\]"
- }
- else if match Factor [tk_ident `[ expr `]]
- {
- send Out2
- "[$Factor.tk_ident]\[ [rw_go_expr(Factor.expr)] \]
- }
- else if match Factor [tk_ident `( expr `)]
- {
- send Out2
- "[$Factor.tk_ident]( [rw_go_expr(Factor.expr)] )
- }
- elsif match Factor [`< type `> `( expr `)]
- {
- send Out2
- "( [rw_go_type(Factor.type)] ) ( [rw_go_expr(Factor.expr)] )
- }
- elsif match Factor [`( expr `)]
- {
- send Out2
- "( [rw_go_expr(Factor.expr)] )
- }
- elsif match Factor ['true']
- {
- send Out2 'true'
- }
- elsif match Factor ['false']
- {
- send Out2 'false'
- }
- elsif match Factor [`buffer]
- {
- send Out2
- "string ( buffer\[:blen\] )"
- }
- else
- {
- send Out2 [$Factor]
- }
-}
-
-void rw_go_type( Type: indep::type )
-{
- if match Type [`int]
- {
- send Out2 "int"
- }
- elsif match Type [`bool]
- {
- send Out2 "bool"
- }
- elsif match Type [`char]
- {
- send Out2 "byte"
- }
- elsif match Type [`ptr]
- {
- send Out2 "int"
- }
- elsif match Type [`byte]
- {
- send Out2 "unsigned char"
- }
-}
-
-void rw_go_abs_expr( Expr: indep::abs_expr )
-{
- if ( Expr.Op ) {
- send Out2
- "[rw_go_abs_expr(Expr.E1)] [$Expr.Op] [rw_go_abs_expr( Expr.E2 )]"
- }
- else {
- rw_go_factor( Expr.factor )
- }
-}
-
-void rw_go_expr( Expr: indep::expr )
-{
- AbsExpr: indep::abs_expr = indep::abs_comparative( Expr.comparative )
- rw_go_abs_expr( AbsExpr )
-}
-
-void rw_go_opt_array( OptArr: indep::opt_arr )
-{
- if OptArr.expr {
- send Out2 "\[[rw_go_expr( OptArr.expr )]\]"
- }
-}
-
-int rw_go_var_decl( VarDecl: indep::var_decl )
-{
- send Out2
- "var [$VarDecl.tk_ident] [rw_go_opt_array(VarDecl.opt_arr)] [rw_go_type( VarDecl.type )] ;
-}
-
-void rw_go_opt_sub( OptSub: indep::opt_sub )
-{
- if ( OptSub.expr )
- send Out2 "\[[rw_go_expr(OptSub.expr)]\]"
-}
-
-int rw_go_expr_stmt( ExprStmt: indep::expr_stmt )
-{
- if match ExprStmt [tk_ident opt_sub `= expr `;]
- {
- send Out2
- "[$ExprStmt.tk_ident rw_go_opt_sub(ExprStmt.opt_sub)] = [rw_go_expr(ExprStmt.expr)];
- }
- else if match ExprStmt [expr `;]
- {
- send Out2
- "[rw_go_expr(ExprStmt.expr)];
- }
-}
-
-int rw_go_if_stmt( IfStmt: indep::if_stmt )
-{
- send Out2
- "if ( [rw_go_expr( IfStmt.expr )] ) {
- " [rw_go_stmt_list( IfStmt._repeat_stmt )]"
-
- if ( IfStmt.opt_else._repeat_stmt ) {
- send Out2
- "} else {
- " [rw_go_stmt_list( IfStmt.opt_else._repeat_stmt )]"
- }
-
- send Out2
- "}
-}
-
-int rw_go_print_stmt( Stmt: indep::print_stmt )
-{
- if match Stmt [`print_int expr `;] {
- send Out2
- "fmt.Print( [rw_go_expr(Stmt.expr)] );
- }
- else if match Stmt [`print_buf `;]
- {
- send Out2
- "fmt.Print( string(buffer\[0:blen\]) );
- }
- else if match Stmt [`print_str expr `;]
- {
- send Out2
- "fmt.Print( [rw_go_expr( Stmt.expr )] );
- }
- else if match Stmt [`print_token `;]
- {
- send Out2
- "fmt.Print( data\[ts:te\] );
- }
- else if match Stmt [`print_off `;]
- {
- send Out2
- "fmt.Print( p );
- }
-}
-
-int rw_go_ragel_stmt( Stmt: indep::ragel_stmt )
-{
- send Out2
- "[Stmt]
-}
-
-void rw_go_buf_stmt( BufStmt: indep::buf_stmt )
-{
- switch BufStmt
- case [`buf_clear `( `) `;] {
- send Out2
- " blen = 0;
- }
- case [`buf_append `( `) `;] {
- send Out2
- " buffer\[blen\] = fc;
- " blen += 1;
- " buffer\[blen\] = 0;
- }
-}
-
-
-int rw_go_stmt( Stmt: indep::stmt )
-{
- if match Stmt [var_decl]
- rw_go_var_decl( Stmt.var_decl )
- else if match Stmt [expr_stmt]
- rw_go_expr_stmt( Stmt.expr_stmt )
- else if match Stmt [if_stmt]
- rw_go_if_stmt( Stmt.if_stmt )
- else if match Stmt [print_stmt]
- rw_go_print_stmt( Stmt.print_stmt )
- else if match Stmt [buf_stmt]
- rw_go_buf_stmt( Stmt.buf_stmt )
- else if match Stmt [ragel_stmt]
- rw_go_ragel_stmt( Stmt.ragel_stmt )
-}
-
-void rw_go_stmt_list( StmtList: indep::stmt* )
-{
- for Stmt: indep::stmt in repeat( StmtList )
- rw_go_stmt( Stmt )
-}
-
-int rw_go_action_block( ActionBlock: indep::action_block )
-{
- Out2 = new_parser()
-
- if match ActionBlock [`{ stmt* `}] {
- send Out2 [
- "{
- rw_go_stmt_list( ActionBlock._repeat_stmt )
- "}
- ]
- }
- else if match ActionBlock [`{ expr `}] {
- send Out2
- "{ [rw_go_expr( ActionBlock.expr )] }
- }
- send Out2 [] eos
-}
-
-void rw_go( Output: stream )
-{
- send Output
- "/*
- " * @LANG: go
-
- if ProhibitGenflags {
- send Output
- " * @PROHIBIT_GENFLAGS:[ProhibitGenflags]
- }
-
- send Output
- " * @GENERATED: true
- " */
- "
- "package main
- "import \"fmt\"
- "
-
- Init: indep::stmt* = RagelTree.Init
- for Stmt: indep::stmt in Init {
- if match Stmt [Decl: var_decl] {
- Out2 = new_parser()
- rw_go_var_decl( Decl )
- send Out2 [] eos
- send Output [$Out2->tree]
- }
- }
-
- Section: indep::section = RagelTree.section
- for Action: ragel::action_block in Section {
- # Reparse as lang-independent code.
- parse IndepActionBlock: indep::action_block[$Action]
-
- # Translate to specific language.
- rw_go_action_block( IndepActionBlock )
-
- # Reparse back to ragel action block.
- Action = parse ragel::action_block[Out2->tree]
- }
-
- prints( Output, '\n', Section, '\n' )
-
- send Output
- "var cs int;
- "var blen int;
- "var buffer \[1024\] byte;
- "var nfa_len int;
- "var nfa_count int;
- "var nfa_bp \[20\] struct { state int; p int; };
- "
- "%% write data;
- "
- "func prepare() {
-
- for Stmt: indep::stmt in Init {
- if match Stmt [ExprStmt: expr_stmt] {
- Out2 = new_parser()
- rw_go_expr_stmt( ExprStmt )
- send Out2 [] eos
- send Output [$Out2->tree]
- }
- }
-
- send Output
- " %% write init;
- "}
- "
- "func exec(data string) {
- " var p int = 0
- " var pe int = len(data)
-
- if NeedsEof {
- send Output
- " var eof int = pe
- }
-
- send Output
- " %% write exec;
- "}
- "func finish() {
- " if cs >= [MachineName.mn_word]_first_final {
- " fmt.Println(\"ACCEPT\")
- " } else {
- " fmt.Println(\"FAIL\")
- " }
- "}
-
- send Output
- ~var inp []string = []string {
-
- for InputString: indep::input_string in RagelTree {
- send Output [^InputString ",\n"]
- }
-
- send Output
- "};
- "
-
- send Output
- "func main() {
- " for _, data := range inp {
- " prepare()
- " exec(data)
- " finish()
- " }
- "}
-}
diff --git a/test/ragel.d/trans-java.lm b/test/ragel.d/trans-java.lm
deleted file mode 100644
index 5d2b52bd..00000000
--- a/test/ragel.d/trans-java.lm
+++ /dev/null
@@ -1,353 +0,0 @@
-int rw_java_factor( Factor: indep::factor )
-{
- if match Factor [`first_token_char]
- {
- send Out "data\[ts\]"
- }
- else if match Factor [tk_ident `[ expr `]]
- {
- send Out
- "[$Factor.tk_ident]\[ [rw_java_expr(Factor.expr)] \]
- }
- else if match Factor [tk_ident `( expr `)]
- {
- send Out
- "[$Factor.tk_ident]( [rw_java_expr(Factor.expr)] )
- }
- elsif match Factor [`< type `> `( expr `)]
- {
- send Out
- "( [rw_java_type(Factor.type)] ) ( [rw_java_expr(Factor.expr)] )
- }
- elsif match Factor [`( expr `)]
- {
- send Out
- "( [rw_java_expr(Factor.expr)] )
- }
- elsif match Factor ['true']
- {
- send Out 'true'
- }
- elsif match Factor ['false']
- {
- send Out 'false'
- }
- elsif match Factor [`buffer]
- {
- send Out
- "new String( buffer, 0, blen )"
- }
- else
- {
- send Out [$Factor]
- }
-}
-
-void rw_java_type( Type: indep::type )
-{
- if match Type [`int]
- {
- send Out "int"
- }
- elsif match Type [`bool]
- {
- send Out "boolean"
- }
- elsif match Type [`char]
- {
- send Out "char"
- }
- elsif match Type [`ptr]
- {
- send Out "int
- }
- elsif match Type [`byte]
- {
- send Out "unsigned char"
- }
-}
-
-void rw_java_abs_expr( Expr: indep::abs_expr )
-{
- if ( Expr.Op ) {
- send Out
- "[rw_java_abs_expr(Expr.E1)] [$Expr.Op] [rw_java_abs_expr( Expr.E2 )]"
- }
- else {
- rw_java_factor( Expr.factor )
- }
-}
-
-void rw_java_expr( Expr: indep::expr )
-{
- AbsExpr: indep::abs_expr = indep::abs_comparative( Expr.comparative )
- rw_java_abs_expr( AbsExpr )
-}
-
-void rw_java_opt_array( OptArr: indep::opt_arr, Type: indep::type )
-{
- if OptArr.expr {
- send Out "\[\] = new [rw_java_type( Type )]\[[rw_java_expr( OptArr.expr )]\]"
- }
-}
-
-int rw_java_var_decl( VarDecl: indep::var_decl )
-{
- send Out
- "[rw_java_type( VarDecl.type )] [$VarDecl.tk_ident] [rw_java_opt_array(VarDecl.opt_arr, VarDecl.type)];
-}
-
-void rw_java_opt_sub( OptSub: indep::opt_sub )
-{
- if ( OptSub.expr )
- send Out "\[[rw_java_expr(OptSub.expr)]\]"
-}
-
-int rw_java_expr_stmt( ExprStmt: indep::expr_stmt )
-{
- if match ExprStmt [tk_ident opt_sub `= expr `;]
- {
- send Out
- "[$ExprStmt.tk_ident rw_java_opt_sub(ExprStmt.opt_sub)] = [rw_java_expr(ExprStmt.expr)];
- }
- else if match ExprStmt [expr `;]
- {
- send Out
- "[rw_java_expr(ExprStmt.expr)];
- }
-}
-
-int rw_java_if_stmt( IfStmt: indep::if_stmt )
-{
- send Out
- "if ( [rw_java_expr( IfStmt.expr )] )
- "{
- " [rw_java_stmt_list( IfStmt._repeat_stmt )]
- "}
-
- if ( IfStmt.opt_else._repeat_stmt ) {
- send Out
- "else {
- " [rw_java_stmt_list( IfStmt.opt_else._repeat_stmt )]
- "}
- }
-}
-
-int rw_java_print_stmt( Stmt: indep::print_stmt )
-{
- if match Stmt [`print_int expr `;] {
- send Out
- "System.out.print( [rw_java_expr(Stmt.expr)] );
- }
- else if match Stmt [`print_buf `;]
- {
- send Out
- "System.out.print( new String( buffer, 0, blen ) );
- }
- else if match Stmt [`print_str expr `;]
- {
- send Out
- "System.out.print( [rw_java_expr( Stmt.expr )] );
- }
- else if match Stmt [`print_token `;]
- {
- send Out
- "_s = new String( data, ts, te - ts );
- "System.out.print( _s );
- }
- else if match Stmt [`print_off `;]
- {
- send Out
- "System.out.print( p );
- }
-}
-
-void rw_java_buf_stmt( BufStmt: indep::buf_stmt )
-{
- switch BufStmt
- case [`buf_clear `( `) `;] {
- send Out
- " blen = 0;
- }
- case [`buf_append `( `) `;] {
- send Out
- " buffer\[blen\] = fc;
- " blen += 1;
- }
-}
-
-
-int rw_java_ragel_stmt( Stmt: indep::ragel_stmt )
-{
- send Out
- [$Stmt]
-}
-
-int rw_java_stmt( Stmt: indep::stmt )
-{
- if match Stmt [var_decl]
- rw_java_var_decl( Stmt.var_decl )
- else if match Stmt [expr_stmt]
- rw_java_expr_stmt( Stmt.expr_stmt )
- else if match Stmt [if_stmt]
- rw_java_if_stmt( Stmt.if_stmt )
- else if match Stmt [print_stmt]
- rw_java_print_stmt( Stmt.print_stmt )
- else if match Stmt [buf_stmt]
- rw_java_buf_stmt( Stmt.buf_stmt )
- else if match Stmt [ragel_stmt]
- rw_java_ragel_stmt( Stmt.ragel_stmt )
-}
-
-void rw_java_stmt_list( StmtList: indep::stmt* )
-{
- for Stmt: indep::stmt in repeat( StmtList )
- rw_java_stmt( Stmt )
-}
-
-int rw_java_action_block( ActionBlock: indep::action_block )
-{
- Out = new parser<out_code::lines>()
- if match ActionBlock [`{ stmt* `}] {
- send Out
- "{[rw_java_stmt_list( ActionBlock._repeat_stmt )]}
- }
- else if match ActionBlock [`{ expr `}] {
- send Out
- "{[rw_java_expr( ActionBlock.expr )]}
- }
- send Out [] eos
-}
-
-void rw_java( Output: stream )
-{
- # Translate action blocks.
- Section: indep::section = RagelTree.section
- for Action: ragel::action_block in Section {
- # Reparse as lang-independent code.
- parse IndepActionBlock: indep::action_block[$Action]
- if ( !IndepActionBlock ) {
- print( error, '\n', Action )
- exit(1)
- }
-
- rw_java_action_block( IndepActionBlock )
-
- # Reparse back to ragel action block.
- Action = parse ragel::action_block[$Out->tree]
- if ( !Action ) {
- print( error, '\n' )
- exit(1)
- }
- }
-
- send Output
- "/*
- " * @LANG: java
- " * @GENERATED: true
-
- if ProhibitGenflags {
- send Output
- " * @PROHIBIT_GENFLAGS:[ProhibitGenflags]
- }
-
- send Output
- " */
- "
- "
- "class [ClassName]
- "{
-
- Init: indep::stmt* = RagelTree.Init
- for Stmt: indep::stmt in Init {
- if match Stmt [Decl: var_decl] {
- Out = new parser<out_code::lines>()
- rw_java_var_decl( Decl )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- send Output
- "
- "[Section]
- "
- "%% write data;
- "int cs;
- "int nfa_len, nfa_count;
- "int nfa_bp_state\[\] = new int\[20\];
- "int nfa_bp_p\[\] = new int\[20\];
- "
- "void init()
- "{
-
- for Stmt: indep::stmt in Init {
- if match Stmt [ExprStmt: expr_stmt] {
- Out = new parser<out_code::lines>()
- rw_java_expr_stmt( ExprStmt )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- send Output
- " %% write init;
- "}
- "
- "void exec( char data\[\], int len )
- "{
- " char buffer \[\] = new char\[1024\];
- " int blen = 0;
- " int p = 0;
- " int pe = len;
- "
-
- if NeedsEof {
- send Output
- " int eof = len;
- }
-
- send Output
- " String _s;
- " %% write exec;
- "}
- "
- "void finish( )
- "{
- " if ( cs >= [MachineName.mn_word]_first_final )
- " System.out.println( \"ACCEPT\" );
- " else
- " System.out.println( \"FAIL\" );
- "}
- "
-
- send Output
- "static final String inp\[\] = {
-
- NR: int = 0
- for InputString: indep::input_string in RagelTree {
- send Output
- [^InputString ",\n"]
- NR = NR + 1
- }
-
- send Output
- "};
- "
-
- send Output
- "static final int inplen = [NR];
- "
-
- send Output
- "public static void main (String\[\] args)
- "{
- " [ClassName] machine = new [ClassName]();
- " for ( int i = 0; i < inplen; i++ ) {
- " machine.init();
- " machine.exec( inp\[i\].toCharArray(), inp\[i\].length() );
- " machine.finish();
- " }
- "}
- "}
-}
diff --git a/test/ragel.d/trans-julia.lm b/test/ragel.d/trans-julia.lm
deleted file mode 100644
index cf153c64..00000000
--- a/test/ragel.d/trans-julia.lm
+++ /dev/null
@@ -1,342 +0,0 @@
-namespace trans_julia
-
-int factor( Factor: indep::factor )
-{
- if match Factor [`first_token_char]
- {
- send Out "data\[ts+1\]"
- }
- else if match Factor [tk_ident `[ expr `]]
- {
- send Out
- "[$Factor.tk_ident]\[ [expr(Factor.expr)] \]
- }
- else if match Factor [tk_ident `( expr `)]
- {
- send Out
- "[$Factor.tk_ident]( [expr(Factor.expr)] )
- }
- elsif match Factor [`< type `> `( expr `)]
- {
- send Out
- "convert( [type(Factor.type)], ( [expr(Factor.expr)] ) )
- }
- elsif match Factor [`( expr `)]
- {
- send Out
- "( [expr(Factor.expr)] )
- }
- elsif match Factor ['true']
- {
- send Out 'true'
- }
- elsif match Factor ['false']
- {
- send Out 'false'
- }
- elsif match Factor [`buffer]
- {
- send Out
- "buffer"
- }
- elsif match Factor [`blen]
- {
- send Out
- "length(buffer)"
- }
- else
- {
- send Out [$Factor]
- }
-}
-
-void type( Type: indep::type )
-{
- switch Type
- case [`int]
- {
- send Out "Int"
- }
- case [`bool]
- {
- send Out "Int8"
- }
- case [`char]
- {
- send Out "Uint8"
- }
- case [`ptr]
- {
- send Out "i32
- }
- case [`byte]
- {
- send Out "unsigned char"
- }
-}
-
-void abs_expr( Expr: indep::abs_expr )
-{
- if ( Expr.Op ) {
- send Out
- "[abs_expr(Expr.E1)] [$Expr.Op] [abs_expr( Expr.E2 )]"
- }
- else {
- factor( Expr.factor )
- }
-}
-
-void expr( Expr: indep::expr )
-{
- AbsExpr: indep::abs_expr = indep::abs_comparative( Expr.comparative )
- abs_expr( AbsExpr )
-}
-
-void array_init( Size: int )
-{
- while ( Size > 1 ) {
- send Out
- "0, "
- Size = Size - 1
- }
-
- if ( Size > 0 ) {
- send Out
- "0"
- }
-}
-
-int var_decl( VarDecl: indep::var_decl )
-{
- if VarDecl.opt_arr.expr {
- send Out
- "[VarDecl.tk_ident] = [type( VarDecl.type )]"
- "\[ [array_init( atoi($VarDecl.opt_arr.expr) )] \];
- }
- else {
- send Out
- "[VarDecl.tk_ident] = 0;
- }
-}
-
-void opt_sub( OptSub: indep::opt_sub )
-{
- if ( OptSub.expr )
- send Out "\[[expr(OptSub.expr)]\]"
-}
-
-int expr_stmt( ExprStmt: indep::expr_stmt )
-{
- if match ExprStmt [tk_ident opt_sub `= expr `;]
- {
- send Out
- "[$ExprStmt.tk_ident opt_sub(ExprStmt.opt_sub)] = [expr(ExprStmt.expr)];
- }
- else if match ExprStmt [expr `;]
- {
- send Out
- "[expr(ExprStmt.expr)];
- }
-}
-
-int if_stmt( IfStmt: indep::if_stmt )
-{
- send Out
- "if ( [expr( IfStmt.expr )] )
- " [stmt_list( IfStmt._repeat_stmt )]
-
- if ( IfStmt.opt_else._repeat_stmt ) {
- send Out
- "else
- " [stmt_list( IfStmt.opt_else._repeat_stmt )]
- }
-
- send Out
- "end
-}
-
-int print_stmt( Stmt: indep::print_stmt )
-{
- switch Stmt
- case [`print_int expr `;] {
- send Out
- "print( [expr(Stmt.expr)] );
- }
- case [`print_buf `;]
- {
- send Out
- "print( buffer );
- }
- case [`print_str expr `;]
- {
- send Out
- "print( [expr( Stmt.expr )] );
- }
- case [`print_token `;]
- {
- send Out
- "print( String( data\[(ts+1) : (te)\] ) );
- }
- case [`print_off `;]
- {
- send Out
- "print( p );"
- }
-}
-
-void buf_stmt( BufStmt: indep::buf_stmt )
-{
- switch BufStmt
- case [`buf_clear `( `) `;] {
- send Out
- " buffer = \"\";
- }
- case [`buf_append `( `) `;] {
- send Out
- " buffer = buffer * String(Char\[fc\]);
- }
-}
-
-
-int ragel_stmt( Stmt: indep::ragel_stmt )
-{
- send Out
- [$Stmt]
-}
-
-int stmt( Stmt: indep::stmt )
-{
- switch Stmt
- case [var_decl]
- var_decl( Stmt.var_decl )
- case [expr_stmt]
- expr_stmt( Stmt.expr_stmt )
- case [if_stmt]
- if_stmt( Stmt.if_stmt )
- case [print_stmt]
- print_stmt( Stmt.print_stmt )
- case [buf_stmt]
- buf_stmt( Stmt.buf_stmt )
- case [ragel_stmt]
- ragel_stmt( Stmt.ragel_stmt )
-}
-
-void stmt_list( StmtList: indep::stmt* )
-{
- for Stmt: indep::stmt in repeat( StmtList )
- stmt( Stmt )
-}
-
-int action_block( ActionBlock: indep::action_block )
-{
- Out = new parser<out_code::lines>()
- if match ActionBlock [`{ stmt* `}] {
- send Out
- "{[stmt_list( ActionBlock._repeat_stmt )]}
- }
- else if match ActionBlock [`{ expr `}] {
- send Out
- "{[expr( ActionBlock.expr )]}
- }
- send Out [] eos
-}
-
-void julia( Output: stream )
-{
- # Translate action blocks.
- Section: indep::section = RagelTree.section
- for Action: ragel::action_block in Section {
- # Reparse as lang-independent code.
- parse IndepActionBlock: indep::action_block[$Action]
- if ( !IndepActionBlock ) {
- print( error, '\n', Action )
- exit(1)
- }
-
- action_block( IndepActionBlock )
-
- # Reparse back to ragel action block.
- Action = parse ragel::action_block[$Out->tree]
- if ( !Action ) {
- print( error, '\n' )
- exit(1)
- }
- }
-
- send Output
- "//
- "// @LANG: julia
- "// @GENERATED: true
-
- if ProhibitGenflags {
- send Output
- "// @PROHIBIT_GENFLAGS:[ProhibitGenflags]
- }
-
- send Output
- "//
- "
-
-
- send Output
- "
- "[Section]
- "
- "%% write data;
- "
- "function m( data_string::AbstractString )
- " data = Vector{UInt8}( data_string )
- " p = 0
- " pe = length(data)
- " eof = length(data)
- " cs = 0
- " buffer = \"\"
- " nfa_len = 0
- " nfa_count = 0
- " nfa_bp_state = Array{Int, 1}(undef, 20)
- " nfa_bp_p = Array{Int, 1}(undef, 20)
-
- Init: indep::stmt* = RagelTree.Init
- for Stmt: indep::stmt in Init {
- if match Stmt [Decl: var_decl] {
- Out = new parser<out_code::lines>()
- var_decl( Decl )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- for Stmt: indep::stmt in Init {
- if match Stmt [ExprStmt: expr_stmt] {
- Out = new parser<out_code::lines>()
- expr_stmt( ExprStmt )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- send Output
- "
- " %% write init;
- " %% write exec;
- "
- " if ( cs >= [MachineName.mn_word]_first_final )
- " println( \"ACCEPT\" );
- " else
- " println( \"FAIL\" );
- " end
- "end
-
-
-
- send Output
- ~
-
- for InputString: indep::input_string in RagelTree {
- send Output
- " m( [^InputString] );
- }
-
-}
-
-end
diff --git a/test/ragel.d/trans-ocaml.lm b/test/ragel.d/trans-ocaml.lm
deleted file mode 100644
index 6cec5ad4..00000000
--- a/test/ragel.d/trans-ocaml.lm
+++ /dev/null
@@ -1,371 +0,0 @@
-int rw_ocaml_factor( Factor: indep::factor )
-{
- switch Factor
- case [`first_token_char] {
- send Out
- "( Char.code data.\[ts.contents\] )"
- }
- case [tk_ident `[ expr `]] {
- send Out
- "[$Factor.tk_ident]\[ [rw_ocaml_expr(Factor.expr)] \]
- }
- case [ `fentry `( E: expr `)] {
- send Out
- "fentry( [E] )"
- }
- case [tk_ident `( expr `)] {
- send Out
- "[$Factor.tk_ident]( [rw_ocaml_expr(Factor.expr)] )
- }
- case [`< type `> `( expr `)] {
- send Out
- "( [rw_ocaml_expr(Factor.expr)] )
- }
- case [`( expr `)] {
- send Out
- "( [rw_ocaml_expr(Factor.expr)] )
- }
- case ['true'] {
- send Out 'true'
- }
- case ['false'] {
- send Out 'false'
- }
- case "'0'" {
- send Out
- "( Char.code '0' )"
- }
- case "'a'" {
- send Out
- "( Char.code 'a' )"
- }
- case [`fc] {
- send Out
- "fc"
- }
- case [tk_ident] {
- send Out
- "[Factor.tk_ident].contents"
- }
- case [`buffer]
- {
- send Out
- "String.sub buffer 0 blen.contents"
- }
- case [`blen]
- {
- send Out
- "blen.contents"
- }
- default {
- send Out
- [Factor]
- }
-}
-
-void rw_ocaml_type( Type: indep::type )
-{
- if match Type [`int]
- {
- send Out "int"
- }
- elsif match Type [`bool]
- {
- send Out "bool"
- }
- elsif match Type [`char]
- {
- send Out "char"
- }
- elsif match Type [`ptr]
- {
- send Out "char *"
- }
- elsif match Type [`byte]
- {
- send Out "unsigned char"
- }
-}
-
-void rw_ocaml_abs_expr( Expr: indep::abs_expr )
-{
- if ( Expr.Op ) {
- send Out
- "[rw_ocaml_abs_expr(Expr.E1)] [$Expr.Op] [rw_ocaml_abs_expr( Expr.E2 )]"
- }
- else {
- rw_ocaml_factor( Expr.factor )
- }
-}
-
-void rw_ocaml_expr( Expr: indep::expr )
-{
- AbsExpr: indep::abs_expr = indep::abs_comparative( Expr.comparative )
- rw_ocaml_abs_expr( AbsExpr )
-}
-
-void rw_ocaml_opt_array( OptArr: indep::opt_arr )
-{
- if OptArr.expr {
- send Out "\[[rw_ocaml_expr( OptArr.expr )]\]"
- }
-}
-
-int rw_ocaml_var_decl( VarDecl: indep::var_decl )
-{
- OptArr: indep::opt_arr = VarDecl.opt_arr
- if OptArr.expr {
- send Out
- "let [$VarDecl.tk_ident] = Array.make 32 0
- }
- else if match VarDecl.type [`bool] {
- send Out
- "let [VarDecl.tk_ident] = ref false
- }
- else {
- send Out
- "let [VarDecl.tk_ident] = ref 0
- }
-}
-
-void rw_ocaml_opt_sub( OptSub: indep::opt_sub )
-{
- if ( OptSub.expr )
- send Out "\[[rw_ocaml_expr(OptSub.expr)]\]"
-}
-
-int rw_ocaml_expr_stmt( ExprStmt: indep::expr_stmt )
-{
- if match ExprStmt [tk_ident opt_sub `= expr `;]
- {
- if match ExprStmt.opt_sub [] {
- send Out
- "[$ExprStmt.tk_ident rw_ocaml_opt_sub(ExprStmt.opt_sub)] := [rw_ocaml_expr(ExprStmt.expr)];
- }
- else {
- send Out
- "Array.set [$ExprStmt.tk_ident] [rw_ocaml_expr(ExprStmt.opt_sub.expr)] [rw_ocaml_expr(ExprStmt.expr)];
-
- }
- }
- else if match ExprStmt [expr `;]
- {
- send Out
- "[rw_ocaml_expr(ExprStmt.expr)];
- }
-}
-
-int rw_ocaml_if_stmt( IfStmt: indep::if_stmt )
-{
- send Out
- "if [rw_ocaml_expr( IfStmt.expr )] then
- "begin
- " [rw_ocaml_stmt_list( IfStmt._repeat_stmt )]
- "end
-
- if ( IfStmt.opt_else._repeat_stmt ) {
- send Out
- "else
- "begin
- " [rw_ocaml_stmt_list( IfStmt.opt_else._repeat_stmt )]
- "end
- }
- send Out
- ";
-}
-
-int rw_ocaml_print_stmt( Stmt: indep::print_stmt )
-{
- if match Stmt [`print_int expr `;] {
- send Out
- "print_int( [rw_ocaml_expr(Stmt.expr)] );
- }
- else if match Stmt [`print_buf `;]
- {
- send Out
- "print_string( String.sub buffer 0 blen.contents );
- }
- else if match Stmt [`print_str expr `;]
- {
- send Out
- "print_string( [rw_ocaml_expr( Stmt.expr )] );
- }
- else if match Stmt [`print_token `;]
- {
- send Out
- "for i = ts.contents to te.contents - 1 do print_char data.\[i\] done; "
- }
-}
-
-void rw_ocaml_buf_stmt( BufStmt: indep::buf_stmt )
-{
- switch BufStmt
- case [`buf_clear `( `) `;] {
- send Out
- "begin
- " blen := 0;
- "end
- }
- case [`buf_append `( `) `;] {
- send Out
- " begin
- " Bytes.set buffer blen.contents data.\[p.contents\];
- " blen := blen.contents + 1;
- " end
- }
-}
-
-int rw_ocaml_ragel_stmt( Stmt: indep::ragel_stmt )
-{
- switch Stmt
- case [`fnext `* E: expr `;] {
- send Out
- "fnext *[rw_ocaml_expr(E)];
- }
- case [`fncall `* E: expr `;] {
- send Out
- "fncall *[rw_ocaml_expr(E)];
- }
- default {
- send Out
- [Stmt]
- }
-}
-
-int rw_ocaml_stmt( Stmt: indep::stmt )
-{
- if match Stmt [var_decl]
- rw_ocaml_var_decl( Stmt.var_decl )
- else if match Stmt [expr_stmt]
- rw_ocaml_expr_stmt( Stmt.expr_stmt )
- else if match Stmt [if_stmt]
- rw_ocaml_if_stmt( Stmt.if_stmt )
- else if match Stmt [print_stmt]
- rw_ocaml_print_stmt( Stmt.print_stmt )
- else if match Stmt [buf_stmt]
- rw_ocaml_buf_stmt( Stmt.buf_stmt )
- else if match Stmt [ragel_stmt]
- rw_ocaml_ragel_stmt( Stmt.ragel_stmt )
-}
-
-void rw_ocaml_stmt_list( StmtList: indep::stmt* )
-{
- for Stmt: indep::stmt in repeat( StmtList )
- rw_ocaml_stmt( Stmt )
-}
-
-int rw_ocaml_action_block( ActionBlock: indep::action_block )
-{
- Out = new parser<out_code::lines>()
- if match ActionBlock [`{ stmt* `}] {
- send Out
- "{[rw_ocaml_stmt_list( ActionBlock._repeat_stmt )]}
- }
- else if match ActionBlock [`{ expr `}] {
- send Out
- "{[rw_ocaml_expr( ActionBlock.expr )]}
- }
- send Out [] eos
-}
-
-void rw_ocaml( Output: stream )
-{
- send Output
- "(*
- " * @LANG: ocaml
- " * @GENERATED: true
-
- if ProhibitGenflags {
- send Output
- " * @PROHIBIT_GENFLAGS:[ProhibitGenflags]
- }
-
- send Output
- " *)
- "
-
- Init: indep::stmt* = RagelTree.Init
- for Stmt: indep::stmt in Init {
- if match Stmt [Decl: var_decl] {
- Out = new parser<out_code::lines>()
- rw_ocaml_var_decl( Decl )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- Section: indep::section = RagelTree.section
- for Action: ragel::action_block in Section {
- # Reparse as lang-independent code.
- parse IndepActionBlock: indep::action_block[$Action]
- if ( !IndepActionBlock ) {
- print( "error parsing indep action block: ", error, '\n', Action )
- exit(1)
- }
-
- rw_ocaml_action_block( IndepActionBlock )
-
- # Reparse back to ragel action block.
- Action = parse ragel::action_block[$Out->tree]
- if ( !Action ) {
- print( "error parsing ragel action block: ", error, '\n', $Out->tree )
- exit(1)
- }
- }
-
- send Output
- "
- "[Section]
- "
- "
- "%% write data;
- "
- "let exec data =
- " let buffer = Bytes.create(1024) in
- " let blen :int ref = ref 0 in
- " let cs = ref 0 in
- " let p = ref 0 in
- " let pe = ref (String.length data) in
- " let nfa_len = ref 0 in
- " let nfa_count = ref 0 in
- " let nfa_bp_state = Array.make 20 0 in
- " let nfa_bp_p = Array.make 20 0 in
-
- if NeedsEof {
- send Output
- " let eof = pe in
- }
-
-
- for Stmt: indep::stmt in Init {
- if match Stmt [ExprStmt: expr_stmt] {
- Out = new parser<out_code::lines>()
- rw_ocaml_expr_stmt( ExprStmt )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- send Output
- " %% write init;
- " %% write exec;
- " if !cs >= [MachineName.mn_word]_first_final then
- " print_string \"ACCEPT\\n\"
- " else
- " print_string \"FAIL\\n\"
- ";;
- "
-
- send Output
- "let () =
-
- for InputString: indep::input_string in RagelTree {
- send Output
- " exec [^InputString];
- }
-
- send Output
- " ()
- ";;
- "
-}
diff --git a/test/ragel.d/trans-ruby.lm b/test/ragel.d/trans-ruby.lm
deleted file mode 100644
index 53e108c0..00000000
--- a/test/ragel.d/trans-ruby.lm
+++ /dev/null
@@ -1,343 +0,0 @@
-int rw_ruby_factor( Factor: indep::factor )
-{
- switch Factor
- case [`first_token_char] {
- send Out "data\[ts\].ord"
- }
- case [tk_ident `[ expr `]] {
- send Out
- "[$Factor.tk_ident]\[ [rw_ruby_expr(Factor.expr)] \]
- }
- case [tk_ident `( expr `)] {
- send Out
- "[$Factor.tk_ident]( [rw_ruby_expr(Factor.expr)] )
- }
- case [`< type `> `( expr `)] {
- send Out
- "( [rw_ruby_expr(Factor.expr)] )
- }
- case [`( expr `)] {
- send Out
- "( [rw_ruby_expr(Factor.expr)] )
- }
- case ['true'] {
- send Out 'true'
- }
- case ['false'] {
- send Out 'false'
- }
- case "'0'" {
- send Out '"0"[0].ord'
- }
- case "'a'" {
- send Out '"a"[0].ord'
- }
- case [`buffer] {
- send Out
- "buffer\[0..blen-1\].pack( \"c*\" )"
- }
- default {
- send Out [$Factor]
- }
-}
-
-void rw_ruby_type( Type: indep::type )
-{
- if match Type [`int]
- {
- send Out "int"
- }
- elsif match Type [`bool]
- {
- send Out "bool"
- }
- elsif match Type [`char]
- {
- send Out "char"
- }
- elsif match Type [`ptr]
- {
- send Out "char *"
- }
- elsif match Type [`byte]
- {
- send Out "unsigned char"
- }
-}
-
-void rw_ruby_abs_expr( Expr: indep::abs_expr )
-{
- if ( Expr.Op ) {
- send Out
- "[rw_ruby_abs_expr(Expr.E1)] [$Expr.Op] [rw_ruby_abs_expr( Expr.E2 )]"
- }
- else {
- rw_ruby_factor( Expr.factor )
- }
-}
-
-void rw_ruby_expr( Expr: indep::expr )
-{
- AbsExpr: indep::abs_expr = indep::abs_comparative( Expr.comparative )
- rw_ruby_abs_expr( AbsExpr )
-}
-
-void rw_ruby_opt_array( OptArr: indep::opt_arr )
-{
- if OptArr.expr {
- send Out "\[[rw_ruby_expr( OptArr.expr )]\]"
- }
-}
-
-int rw_ruby_var_decl( VarDecl: indep::var_decl )
-{
- OptArr: indep::opt_arr = VarDecl.opt_arr
- if OptArr.expr {
- send Out
- "[$VarDecl.tk_ident] = Array.new
- }
- else if match VarDecl.type [`bool] {
- send Out
- "[$VarDecl.tk_ident] = false
- }
- else {
- send Out
- "[$VarDecl.tk_ident] = 0
- }
-}
-
-void rw_ruby_opt_sub( OptSub: indep::opt_sub )
-{
- if ( OptSub.expr )
- send Out "\[[rw_ruby_expr(OptSub.expr)]\]"
-}
-
-int rw_ruby_expr_stmt( ExprStmt: indep::expr_stmt )
-{
- if match ExprStmt [tk_ident opt_sub `= expr `;]
- {
- send Out
- "[$ExprStmt.tk_ident rw_ruby_opt_sub(ExprStmt.opt_sub)] = [rw_ruby_expr(ExprStmt.expr)];
- }
- else if match ExprStmt [expr `;]
- {
- send Out
- "[rw_ruby_expr(ExprStmt.expr)];
- }
-}
-
-int rw_ruby_if_stmt( IfStmt: indep::if_stmt )
-{
- send Out
- "if ( [rw_ruby_expr( IfStmt.expr )] )
- " [rw_ruby_stmt_list( IfStmt._repeat_stmt )]
-
- if ( IfStmt.opt_else._repeat_stmt ) {
- send Out
- "else
- " [rw_ruby_stmt_list( IfStmt.opt_else._repeat_stmt )]
- }
- send Out
- "end
-}
-
-int rw_ruby_print_stmt( Stmt: indep::print_stmt )
-{
- if match Stmt [`print_int expr `;] {
- send Out
- "print( [rw_ruby_expr(Stmt.expr)] );
- }
- else if match Stmt [`print_buf `;]
- {
- send Out
- "print( buffer\[0..blen-1\].pack( \"c*\" ) );
- }
- else if match Stmt [`print_str expr `;]
- {
- send Out
- "print( [rw_ruby_expr( Stmt.expr )] );
- }
- else if match Stmt [`print_token `;]
- {
- send Out
- "_m = data\[ts..te-1\];
- "print( _m );
- }
-}
-
-int rw_ruby_ragel_stmt( Stmt: indep::ragel_stmt )
-{
- send Out
- [$Stmt]
-}
-
-void rw_ruby_buf_stmt( BufStmt: indep::buf_stmt )
-{
- switch BufStmt
- case [`buf_clear `( `) `;] {
- send Out
- " blen = 0;
- }
- case [`buf_append `( `) `;] {
- send Out
- " buffer\[blen\] = fc;
- " blen += 1;
- }
-}
-
-int rw_ruby_stmt( Stmt: indep::stmt )
-{
- switch Stmt
- case [var_decl]
- rw_ruby_var_decl( Stmt.var_decl )
- case [expr_stmt]
- rw_ruby_expr_stmt( Stmt.expr_stmt )
- case [if_stmt]
- rw_ruby_if_stmt( Stmt.if_stmt )
- case [print_stmt]
- rw_ruby_print_stmt( Stmt.print_stmt )
- case [buf_stmt]
- rw_ruby_buf_stmt( Stmt.buf_stmt )
- case [ragel_stmt]
- rw_ruby_ragel_stmt( Stmt.ragel_stmt )
-}
-
-void rw_ruby_stmt_list( StmtList: indep::stmt* )
-{
- for Stmt: indep::stmt in repeat( StmtList )
- rw_ruby_stmt( Stmt )
-}
-
-int rw_ruby_action_block( ActionBlock: indep::action_block )
-{
- Out = new parser<out_code::lines>()
- if match ActionBlock [`{ stmt* `}] {
- send Out
- "{[rw_ruby_stmt_list( ActionBlock._repeat_stmt )]}
- }
- else if match ActionBlock [`{ expr `}] {
- send Out
- "{[rw_ruby_expr( ActionBlock.expr )]}
- }
- send Out [] eos
-}
-
-void rw_ruby( Output: stream )
-{
- Section: indep::section = RagelTree.section
-
- # Lowercase the machine name
- for MachineName: ragel::machine_name in Section {
- for Word: ragel::word in MachineName {
- Word.data = tolower( Word.data )
- }
- }
-
- MachineName = ragel::machine_name in Section
-
- # Rewrite the action blocks.
- for Action: ragel::action_block in Section {
- # Reparse as lang-independent code.
- parse IndepActionBlock: indep::action_block[$Action]
- if ( !IndepActionBlock ) {
- print( error, '\n', Action )
- exit(1)
- }
-
- rw_ruby_action_block( IndepActionBlock )
-
- # Reparse back to ragel action block.
- Action = parse ragel::action_block[$Out->tree]
- if ( !Action ) {
- print( error, '\n' )
- exit(1)
- }
- }
-
-
- send Output
- "#
- "# @LANG: ruby
- "# @GENERATED: true
-
- if ProhibitGenflags {
- send Output
- "# @PROHIBIT_GENFLAGS:[ProhibitGenflags]
- }
-
- send Output
- "#
- "
-
- send Output
- "
- "[Section]
- "
- "%% write data;
- "
- "def run_machine( data )
- " p = 0
- " pe = data.length
- " eof = data.length
- " cs = 0;
- " _m = ""
- " _a = ""
- " nfa_len = 0
- " nfa_count = 0
- " nfa_bp_state = Array.new()
- " nfa_bp_p = Array.new()
- " buffer = Array.new
- " blen = 0
-
- Init: indep::stmt* = RagelTree.Init
- for Stmt: indep::stmt in Init {
- if match Stmt [Decl: var_decl] {
- Out = new parser<out_code::lines>()
- rw_ruby_var_decl( Decl )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- for Stmt: indep::stmt in Init {
- if match Stmt [ExprStmt: expr_stmt] {
- Out = new parser<out_code::lines>()
- rw_ruby_expr_stmt( ExprStmt )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- send Output
- " %% write init;
- " %% write exec;
- " if cs >= [MachineName.mn_word]_first_final
- " puts \"ACCEPT\"
- " else
- " puts \"FAIL\"
- " end
- "end
- "
-
- send Output
- "inp = \[
-
- NR: int = 0
- for InputString: indep::input_string in RagelTree {
- send Output
- [^InputString ",\n"]
- NR = NR + 1
- }
-
- send Output
- "\]
- "
-
- send Output
- "inplen = [NR]
- "
-
- send Output
- "inp.each { |str| run_machine(str) }
- "
-}
diff --git a/test/ragel.d/trans-rust.lm b/test/ragel.d/trans-rust.lm
deleted file mode 100644
index 94a77035..00000000
--- a/test/ragel.d/trans-rust.lm
+++ /dev/null
@@ -1,352 +0,0 @@
-namespace trans_rust
-
-int factor( Factor: indep::factor )
-{
- if match Factor [`first_token_char]
- {
- send Out "data\[ts as usize\]"
- }
- else if match Factor [tk_ident `[ expr `]]
- {
- send Out
- "[$Factor.tk_ident]\[ [expr(Factor.expr)] \]
- }
- else if match Factor [tk_ident `( expr `)]
- {
- send Out
- "[$Factor.tk_ident]( [expr(Factor.expr)] )
- }
- elsif match Factor [`< type `> `( expr `)]
- {
- send Out
- "( ( [expr(Factor.expr)] ) as [type(Factor.type)] )
- }
- elsif match Factor [`( expr `)]
- {
- send Out
- "( [expr(Factor.expr)] )
- }
- elsif match Factor ['true']
- {
- send Out 'true'
- }
- elsif match Factor ['false']
- {
- send Out 'false'
- }
- elsif match Factor [`buffer]
- {
- send Out
- "buffer"
- }
- elsif match Factor [`blen]
- {
- send Out
- "buffer.len()"
- }
- else
- {
- send Out [$Factor]
- }
-}
-
-void type( Type: indep::type )
-{
- switch Type
- case [`int]
- {
- send Out "i32"
- }
- case [`bool]
- {
- send Out "bool"
- }
- case [`char]
- {
- send Out "u8"
- }
- case [`ptr]
- {
- send Out "i32
- }
- case [`byte]
- {
- send Out "unsigned char"
- }
-}
-
-void abs_expr( Expr: indep::abs_expr )
-{
- if ( Expr.Op ) {
- send Out
- "[abs_expr(Expr.E1)] [$Expr.Op] [abs_expr( Expr.E2 )]"
- }
- else {
- factor( Expr.factor )
- }
-}
-
-void expr( Expr: indep::expr )
-{
- AbsExpr: indep::abs_expr = indep::abs_comparative( Expr.comparative )
- abs_expr( AbsExpr )
-}
-
-void array_init( Size: int )
-{
- while ( Size > 1 ) {
- send Out
- "0, "
- Size = Size - 1
- }
-
- if ( Size > 0 ) {
- send Out
- "0"
- }
-}
-
-int var_decl( VarDecl: indep::var_decl )
-{
- if VarDecl.opt_arr.expr {
- send Out
- "static mut [VarDecl.tk_ident] : "
- "\[ [type( VarDecl.type )] ; [expr( VarDecl.opt_arr.expr )]\] = "
- "\[ [array_init( atoi($VarDecl.opt_arr.expr) )] \];
- }
- else if match VarDecl.type [`bool] {
- send Out
- "static mut [VarDecl.tk_ident] : [type( VarDecl.type )] = false;
- }
- else {
- send Out
- "static mut [VarDecl.tk_ident] : [type( VarDecl.type )] = 0;
- }
-}
-
-void opt_sub( OptSub: indep::opt_sub )
-{
- if ( OptSub.expr )
- send Out "\[[expr(OptSub.expr)]\]"
-}
-
-int expr_stmt( ExprStmt: indep::expr_stmt )
-{
- if match ExprStmt [tk_ident opt_sub `= expr `;]
- {
- send Out
- "[$ExprStmt.tk_ident opt_sub(ExprStmt.opt_sub)] = [expr(ExprStmt.expr)];
- }
- else if match ExprStmt [expr `;]
- {
- send Out
- "[expr(ExprStmt.expr)];
- }
-}
-
-int if_stmt( IfStmt: indep::if_stmt )
-{
- send Out
- "if ( [expr( IfStmt.expr )] )
- "{
- " [stmt_list( IfStmt._repeat_stmt )]
- "}
-
- if ( IfStmt.opt_else._repeat_stmt ) {
- send Out
- "else {
- " [stmt_list( IfStmt.opt_else._repeat_stmt )]
- "}
- }
-}
-
-int print_stmt( Stmt: indep::print_stmt )
-{
- switch Stmt
- case [`print_int expr `;] {
- send Out
- "print!( \"{}\", [expr(Stmt.expr)] );
- }
- case [`print_buf `;]
- {
- send Out
- "print!( \"{}\", buffer );
- }
- case [`print_str expr `;]
- {
- send Out
- "print!( \"{}\", [expr( Stmt.expr )] );
- }
- case [`print_token `;]
- {
- send Out
- "let s = match std::str::from_utf8(&data\[ts as usize .. te as usize\]) {
- " Ok(v) => v,
- " Err(e) => panic!(\"Invalid UTF-8 sequence: {}\", e),
- " };
- "print!( \"{}\", s );
- }
-}
-
-void buf_stmt( BufStmt: indep::buf_stmt )
-{
- switch BufStmt
- case [`buf_clear `( `) `;] {
- send Out
- " buffer = String::new();
- }
- case [`buf_append `( `) `;] {
- send Out
- " buffer.push( ( fc ) as char );
- }
-}
-
-
-int ragel_stmt( Stmt: indep::ragel_stmt )
-{
- send Out
- [$Stmt]
-}
-
-int stmt( Stmt: indep::stmt )
-{
- switch Stmt
- case [var_decl]
- var_decl( Stmt.var_decl )
- case [expr_stmt]
- expr_stmt( Stmt.expr_stmt )
- case [if_stmt]
- if_stmt( Stmt.if_stmt )
- case [print_stmt]
- print_stmt( Stmt.print_stmt )
- case [buf_stmt]
- buf_stmt( Stmt.buf_stmt )
- case [ragel_stmt]
- ragel_stmt( Stmt.ragel_stmt )
-}
-
-void stmt_list( StmtList: indep::stmt* )
-{
- for Stmt: indep::stmt in repeat( StmtList )
- stmt( Stmt )
-}
-
-int action_block( ActionBlock: indep::action_block )
-{
- Out = new parser<out_code::lines>()
- if match ActionBlock [`{ stmt* `}] {
- send Out
- "{[stmt_list( ActionBlock._repeat_stmt )]}
- }
- else if match ActionBlock [`{ expr `}] {
- send Out
- "{[expr( ActionBlock.expr )]}
- }
- send Out [] eos
-}
-
-void rust( Output: stream )
-{
- # Translate action blocks.
- Section: indep::section = RagelTree.section
- for Action: ragel::action_block in Section {
- # Reparse as lang-independent code.
- parse IndepActionBlock: indep::action_block[$Action]
- if ( !IndepActionBlock ) {
- print( error, '\n', Action )
- exit(1)
- }
-
- action_block( IndepActionBlock )
-
- # Reparse back to ragel action block.
- Action = parse ragel::action_block[$Out->tree]
- if ( !Action ) {
- print( error, '\n' )
- exit(1)
- }
- }
-
- send Output
- "//
- "// @LANG: rust
- "// @GENERATED: true
-
- if ProhibitGenflags {
- send Output
- "// @PROHIBIT_GENFLAGS:[ProhibitGenflags]
- }
-
- send Output
- "//
- "
-
- Init: indep::stmt* = RagelTree.Init
- for Stmt: indep::stmt in Init {
- if match Stmt [Decl: var_decl] {
- Out = new parser<out_code::lines>()
- var_decl( Decl )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- send Output
- "
- "[Section]
- "
- "%% write data;
- "
- "unsafe fn m( s: String )
- "{
- " let data: &\[u8\] = s.as_bytes();
- " let mut p:i32 = 0;
- " let mut pe:i32 = s.len() as i32;
- " let mut eof:i32 = s.len() as i32;
- " let mut cs: i32 = 0;
- " let mut buffer = String::new();
- " let mut nfa_len:i32 = 0;
- " let mut nfa_count:i32 = 0;
- " let mut nfa_bp_state: \[i32; 20\] = \[0; 20\];
- " let mut nfa_bp_p: \[i32; 20\] = \[0; 20\];
-
- for Stmt: indep::stmt in Init {
- if match Stmt [ExprStmt: expr_stmt] {
- Out = new parser<out_code::lines>()
- expr_stmt( ExprStmt )
- send Out [] eos
- send Output [Out->tree]
- }
- }
-
- send Output
- "
- " %% write init;
- " %% write exec;
- "
- " if ( cs >= [MachineName.mn_word]_first_final ) {
- " println!( \"ACCEPT\" );
- " }
- " else {
- " println!( \"FAIL\" );
- " }
- "}
-
-
-
- send Output
- ~
- ~fn main()
- ~{
-
- for InputString: indep::input_string in RagelTree {
- send Output
- " unsafe { m( [^InputString].to_string() ); }
- }
-
- send Output
- ~}
- ~
-}
-
-end
diff --git a/test/ragel.d/trans.lm b/test/ragel.d/trans.lm
deleted file mode 100644
index 660f94b8..00000000
--- a/test/ragel.d/trans.lm
+++ /dev/null
@@ -1,493 +0,0 @@
-include 'ragel.lm'
-
-namespace inline
- lex
- literal `fpc `fc `fcurs `ftargs
- `fentry `fhold `fexec `fgoto `fnext
- `fcall `fret `fbreak `fncall `fnret `fnbreak
-
- token ident /ident/
- token number /digit+/
- token hex_number /'0x' [0-9a-fA-F]+/
- token dec_number /'0x' [0-9a-fA-F]+/
-
- token comment
- / c_comment | cpp_comment /
-
- token string
- / s_literal | d_literal /
-
- token whitespace
- / ( [ \t] | NL )+ /
-
- literal
- `{ `} `:: `* `, `( `) `;
-
- token var_ref
- / "$" [a-zA-Z_][a-zA-Z_0-9]* /
- {
- if GblActionParams
- {
- input->push( make_token(
- typeid<var_ref>, input->pull( match_length ) ) )
- }
- else
- {
- # Just pull one char. Don't consume the word because it may
- # be a keyword.
- input->push( make_token(
- typeid<c_any>, input->pull( 1 ) ) )
- }
- }
-
- token c_any
- / any /
- end
-
-end
-
-
-namespace host
- lex
- literal `%%{
-
- token close_inc /'}--%%'/
- {
- input->push( make_token( typeid<close_inc>, input->pull( match_length ) ) )
- restoreGlobals()
- }
-
- token close_imp /'}++%%'/
- {
- input->push( make_token( typeid<close_imp>, input->pull( match_length ) ) )
- restoreGlobals()
- }
-
- token slr / '%%' [^{] [^\n]* '\n' /
- {
- # Translates single line to multi-line
- input->pull( 2 )
- R: str = input->pull( match_length - 3 )
- input->push( "\n}%%" )
- input->push( R )
- input->push( "%%{" )
- }
-
- rl NL / '\n' /
-
- rl s_literal
- / "'" ([^'\\\n] | '\\' (any | NL))* "'" /
-
- rl d_literal
- / '"' ([^"\\] | NL | '\\' (any | NL))* '"' /
-
- literal `define `=
-
- token ident /ident "'"?/
- token number /digit+/
- token hex_number /'0x' [0-9a-fA-F]+/
-
- token comment
- / c_comment | cpp_comment /
-
- token string
- / s_literal | d_literal /
-
- token whitespace
- / ( [ \t] | NL )+ /
-
- token c_any / any /
- end
-
- token no_match //
-
- def tok
- [no_match ident whitespace number] :ImportNum
- | [no_match ident whitespace string] :ImportStr
- | [no_match ident] :Else
- | [`define whitespace ident whitespace? number] :ImportDefNum
- | [`define whitespace ident whitespace? string] :ImportDefStr
- | [ident whitespace? `= whitespace? number] :ImportAssignNum
- | [ident whitespace? `= whitespace? string] :ImportAssignStr
- | [`define] :Def
- | [`=] :Eq
- | [ident] :Ident
- | [number] :Number
- | [hex_number] :HexNumber
- | [comment] :Comment
- | [string] :String
- | [whitespace] :Whitespace
- | [c_any] :Any
- {
- NM: no_match = make_token( typeid<no_match>, "" )
- I: ident = make_token( typeid<ident>, $lhs.c_any )
- lhs = cons tok [NM I]
- }
-end
-
-
-namespace indep
- # Opening the test case header.
- lex
- ignore / ( [ \t] | NL )+ /
-
- token c_comm_open
- / '/*' /
- end
-
- # Contents of test case heaer.
- lex
- token comm_name /'@' [A-Za-z0-9_]+ ':' /
- token comm_term /'*/'/
- token comm_any / any /
- end
-
- token comm_val /[^\n]* '\n' /
-
- lex
- literal `%%{ `}%%
-
- literal `int `bool `char `ptr `byte `if `else
- `print_int `print_buf `print_str `print_token `print_off
- `first_token_char `buffer `blen `buf_append `buf_clear
-
- literal `fpc `fc `fcurs `ftargs `fentry
- `fhold `fexec `fgoto `fnext `fcall
- `fret `fbreak `fncall `fnret `fnbreak
-
- literal `; `< `> `( `) `[ `] `=
- `* `! `{ `} `+ `- `== `!=
- `>= `<= `,
-
- ignore / ( [ \t] | NL )+ /
-
- token tk_ident /ident/
- token tk_number /digit+/
- token tk_hex_number /'0x' [0-9a-fA-F]+/
-
- rl INPUT /'INPUT'/
- rl OUTPUT /'OUTPUT'/
-
- token sect_INPUT
- / '#'+ ' '* INPUT ' '* '#'+ '\n' /
-
- token sect_OUTPUT
- / '#'+ ' '* OUTPUT ' '* '#'+ '\n' / -ni
-
- token string
- / s_literal | d_literal /
-
- ignore / cpp_comment /
- ignore / c_comment /
- end
-
- lex
- token output_line /[^\n]* '\n'/
- end
-
- def comm_def
- [comm_name comm_val]
-
- def comm_item
- [comm_def]
- | [comm_any]
-
- def test_header
- [c_comm_open comm_item* comm_term]
-
- def input_string
- [string]
-
- def input_list
- [input_list input_string]
- | [input_string]
-
- def input
- [input_list]
-
- def output
- [output_line*]
-
- def factor
- [`first_token_char]
- | [`buffer]
- | [`blen]
- | [tk_ident]
- | [tk_ident `[ expr `]]
- | [tk_ident `( expr `)]
- | [tk_number]
- | [`- tk_number]
- | [tk_hex_number]
- | [string]
- | [`< type `> `( expr `)]
- | [`( expr `)]
- | [ragel_factor]
-
- def ragel_factor
- [`fentry `( expr `)]
- | [`fc]
- | [`fcurs]
- | [`ftargs]
-
- def mult_op
- [`*]
-
- def add_op
- [`+]
- | [`-]
-
- def cmp_op
- [`<]
- | [`>]
- | [`!=]
- | [`==]
- | [`<=]
- | [`>=]
-
- def abs_op
- [mult_op]
- | [add_op]
- | [cmp_op]
-
- abs_expr abs_multiplicative( Expr: indep::multiplicative )
- {
- if ( !Expr.Op ) {
- return cons abs_expr [Expr.factor]
- }
- else {
- return cons abs_expr [
- abs_multiplicative( Expr._multiplicative )
- Expr.Op
- Expr.factor
- ]
- }
- }
-
- abs_expr abs_additive( Expr: indep::additive )
- {
- if ( !Expr.Op ) {
- return cons abs_expr [
- abs_multiplicative( Expr.multiplicative )
- ]
- }
- else {
- return cons abs_expr [
- abs_additive( Expr._additive )
- Expr.Op
- abs_multiplicative( Expr.multiplicative )
- ]
- }
- }
-
- abs_expr abs_comparative( Expr: indep::comparative )
- {
- if ( !Expr.Op ) {
- return cons abs_expr [
- abs_additive( Expr.additive )
- ]
- }
- else {
- return cons abs_expr [
- abs_comparative( Expr._comparative )
- Expr.Op
- abs_additive( Expr.additive )
- ]
- }
- }
-
- def multiplicative
- [multiplicative Op: mult_op factor]
- | [factor]
-
- def additive
- [additive Op: add_op multiplicative]
- | [multiplicative]
-
- def comparative
- [comparative Op: cmp_op additive]
- | [additive]
-
- def abs_expr
- [E1: abs_expr Op: abs_op E2: abs_expr]
- | [factor]
-
- def expr
- [comparative]
-
- def type
- [`int]
- | [`bool]
- | [`char]
- | [`ptr]
- | [`byte]
-
- def opt_arr
- [`[ expr `]]
- | []
-
- def var_decl
- [type tk_ident opt_arr `;]
-
- def opt_sub
- [ `[ expr `] ]
- | []
-
- def expr_stmt
- [tk_ident opt_sub `= expr `;]
- | [expr `;]
-
- def if_stmt
- [`if `( expr `) `{ stmt* `} opt_else]
-
- def opt_else
- [`else `{ stmt* `}]
- | []
-
- def print_stmt
- [`print_int expr `;]
- | [`print_buf `;]
- | [`print_str expr `;]
- | [`print_token `;]
- | [`print_off `;]
-
- def ragel_stmt
- [`fgoto tk_ident `;]
- | [`fcall tk_ident `;]
- | [`fncall tk_ident `;]
- | [`fnext tk_ident `;]
- | [`fgoto `* expr `;]
- | [`fcall `* expr `;]
- | [`fncall `* expr `;]
- | [`fnext `* expr `;]
- | [`fexec expr `;]
- | [`fhold `;]
- | [`fbreak `;]
- | [`fnbreak `;]
- | [`fret `;]
- | [`fnret `;]
-
- def buf_stmt
- [`buf_append `( `) `;]
- | [`buf_clear `( `) `;]
-
- def stmt
- [var_decl]
- | [expr_stmt]
- | [if_stmt]
- | [print_stmt]
- | [buf_stmt]
- | [ragel_stmt]
-
- def action_block
- [`{ stmt* `}]
- | [`{ expr `}]
-
- def section
- [`%%{ ragel::ragel_start `}%%]
-
- def start
- [
- test_header
- Init: stmt*
- section
- sect_INPUT
- input
- sect_OUTPUT
- output
- ]
-end
-
-namespace out_code
- lex
- token line
- /[^\n]* '\n'/
- end
-
- def lines
- [line*]
-
- alias line_parser
- parser<lines>
-end
-
-global Out: parser<out_code::lines>
-
-include 'trans-c.lm'
-include 'trans-asm.lm'
-include 'trans-d.lm'
-include 'trans-csharp.lm'
-include 'trans-go.lm'
-include 'trans-java.lm'
-include 'trans-ruby.lm'
-include 'trans-ocaml.lm'
-include 'trans-rust.lm'
-include 'trans-julia.lm'
-include 'trans-crack.lm'
-
-str argvPop()
-{
- AE: list_el<str> = argv->pop_el()
- return AE->value
-}
-
-Lang: str = argvPop()
-OutputFile: str = argvPop()
-InputFile: str = argvPop()
-global ClassName: str = argvPop()
-
-Input: stream = open( InputFile, "r" )
-Output: stream = open( OutputFile, "w" )
-
-global RagelTree: indep::start = parse indep::start[ Input ]
-
-if ( !RagelTree ) {
- print( error, '\n' )
- exit(1)
-}
-
-# Find the machine name.
-global MachineName: ragel::machine_name = ragel::machine_name in RagelTree
-
-global NeedsEof: bool = false
-global ProhibitGenflags: str
-for CommDef: indep::comm_def in RagelTree {
- switch CommDef
- case "@NEEDS_EOF: yes\n"
- {
- NeedsEof = true
- }
- case "@PROHIBIT_GENFLAGS:[CV: comm_val]"
- {
- ProhibitGenflags = $CV
- }
-}
-
-if ( Lang == 'c' )
- rw_c( Output )
-elsif ( Lang == 'cg' )
- rw_c( Output )
-elsif ( Lang == 'cv' )
- rw_c( Output )
-elsif ( Lang == 'asm' )
- rw_asm( Output )
-elsif ( Lang == 'd' )
- rw_d( Output )
-elsif ( Lang == 'csharp' )
- rw_csharp( Output )
-elsif ( Lang == 'go' )
- rw_go( Output )
-elsif ( Lang == 'java' )
- rw_java( Output )
-elsif ( Lang == 'ruby' )
- rw_ruby( Output )
-elsif ( Lang == 'ocaml' )
- rw_ocaml( Output )
-elsif ( Lang == 'rust' )
- trans_rust::rust( Output )
-elsif ( Lang == 'julia' )
- trans_julia::julia( Output )
-elsif ( Lang == 'crack' )
- trans_crack::crack( Output )
-else {
- print( 'trans: unrecognized language: ', Lang, '\n' )
-}
diff --git a/test/ragel.d/union.rl b/test/ragel.d/union.rl
deleted file mode 100644
index c5596399..00000000
--- a/test/ragel.d/union.rl
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * @LANG: c++
- * Show off concurrent abilities.
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-using namespace std;
-
-#define BUFSIZE 2048
-
-struct Concurrent
-{
- Concurrent() :
- cur_char(0),
- start_word(0),
- start_comment(0),
- start_literal(0)
- {}
-
- int cur_char;
- int start_word;
- int start_comment;
- int start_literal;
-
- int cs;
-
- // Initialize the machine. Invokes any init statement blocks. Returns 0
- // if the machine begins in a non-accepting state and 1 if the machine
- // begins in an accepting state.
- void init( );
-
- // Execute the machine on a block of data. Returns -1 if after processing
- // the data, the machine is in the error state and can never accept, 0 if
- // the machine is in a non-accepting state and 1 if the machine is in an
- // accepting state.
- void execute( const char *data, int len );
-
- // Indicate that there is no more data. Returns -1 if the machine finishes
- // in the error state and does not accept, 0 if the machine finishes
- // in any other non-accepting state and 1 if the machine finishes in an
- // accepting state.
- int finish( );
-};
-
-%%{
- machine Concurrent;
-
- action next_char {
- cur_char += 1;
- }
-
- action start_word {
- start_word = cur_char;
- }
- action end_word {
- cout << "word: " << start_word <<
- " " << cur_char-1 << endl;
- }
-
- action start_comment {
- start_comment = cur_char;
- }
- action end_comment {
- cout << "comment: " << start_comment <<
- " " << cur_char-1 << endl;
- }
-
- action start_literal {
- start_literal = cur_char;
- }
- action end_literal {
- cout << "literal: " << start_literal <<
- " " << cur_char-1 << endl;
- }
-
- # Count characters.
- chars = ( any @next_char )*;
-
- # Words are non-whitespace.
- word = ( any-space )+ >start_word %end_word;
- words = ( ( word | space ) $1 %0 )*;
-
- # Finds C style comments.
- comment = ( '/*' any* $0 '*/'@1 ) >start_comment %end_comment;
- comments = ( ( comment | any ) $1 %0 )*;
-
- # Finds single quoted strings.
- literalChar = ( any - ['\\] ) | ( '\\' . any );
- literal = ('\'' literalChar* '\'' ) >start_literal %end_literal;
- literals = ( ( literal | (any-'\'') ) $1 %0 )*;
-
- main := chars | words | comments | literals;
-}%%
-
-%% write data;
-
-void Concurrent::init( )
-{
- cur_char = 0;
- %% write init;
-}
-
-void Concurrent::execute( const char *data, int len )
-{
- const char *p = data;
- const char *pe = data + len;
- const char *eof = pe;
-
- %% write exec;
-}
-
-int Concurrent::finish( )
-{
- if ( cs == Concurrent_error )
- return -1;
- if ( cs >= Concurrent_first_final )
- return 1;
- return 0;
-}
-
-void test( const char *buf )
-{
- Concurrent concurrent;
- concurrent.init();
- concurrent.execute( buf, strlen(buf) );
- if ( concurrent.finish() > 0 )
- cout << "ACCEPT" << endl;
- else
- cout << "FAIL" << endl;
-}
-
-int main()
-{
- test(
- "/* in a comment,\n"
- " * ' and now in a literal string\n"
- " */ \n"
- " \n"
- "the comment has now ended but the literal string lives on\n"
- "\n"
- "' comment closed\n" );
- test( "/* * ' \\' */ \\' '\n" );
- test( "/**/'\\''/*/*/\n" );
- return 0;
-}
-
-##### OUTPUT #####
-word: 1 2
-word: 4 5
-word: 7 7
-word: 9 16
-word: 19 19
-word: 21 21
-word: 23 25
-word: 27 29
-word: 31 32
-word: 34 34
-word: 36 42
-word: 44 49
-word: 52 53
-comment: 1 53
-word: 58 60
-word: 62 68
-word: 70 72
-word: 74 76
-word: 78 82
-word: 84 86
-word: 88 90
-word: 92 98
-word: 100 105
-word: 107 111
-word: 113 114
-word: 117 117
-literal: 21 117
-word: 119 125
-word: 127 132
-ACCEPT
-word: 1 2
-word: 4 4
-word: 6 6
-word: 8 9
-word: 11 12
-comment: 1 12
-word: 14 15
-word: 17 17
-literal: 6 17
-ACCEPT
-comment: 1 4
-literal: 5 8
-word: 1 13
-comment: 9 13
-ACCEPT
diff --git a/test/ragel.d/url1.rl b/test/ragel.d/url1.rl
deleted file mode 100644
index fffc6b4f..00000000
--- a/test/ragel.d/url1.rl
+++ /dev/null
@@ -1,540 +0,0 @@
-(*
- * @LANG: ocaml
- *)
-
-(*
-//
-// URL Parser
-// Copyright (c) 2010 J.A. Roberts Tunney
-// MIT License
-//
-// Converted to OCaml by ygrek
-//
-// To compile:
-//
-// ragel -O url.rl -o url.ml
-// ragel -O url_authority.rl -o url_authority.ml
-// ocamlopt -g unix.cmxa url_authority.ml url.ml -o url
-// ./url
-//
-// To show a diagram of your state machine:
-//
-// ragel -V -G2 -p -o url.dot url.rl
-// dot -Tpng -o url.png url.dot
-// chrome url.png
-//
-// ragel -V -G2 -p -o url_authority.dot url_authority.rl
-// dot -Tpng -o url_authority.png url_authority.dot
-// chrome url_authority.png
-//
-// Reference:
-//
-// - http://tools.ietf.org/html/rfc3986
-//
-*)
-
-(*
-// -*-go-*-
-//
-// URL Parser
-// Copyright (c) 2010 J.A. Roberts Tunney
-// MIT License
-//
-*)
-
-%% machine url_authority;
-%% write data;
-
-(*
-// i parse strings like `alice@pokémon.com`.
-//
-// sounds simple right? but i also parse stuff like:
-//
-// bob%20barker:priceisright@[dead:beef::666]:5060;isup-oli=00
-//
-// which in actual reality is:
-//
-// - User: "bob barker"
-// - Pass: "priceisright"
-// - Host: "dead:beef::666"
-// - Port: 5060
-// - Params: "isup-oli=00"
-//
-// which was probably extracted from an absolute url that looked like:
-//
-// sip:bob%20barker:priceisright@[dead:beef::666]:5060;isup-oli=00/palfun.html?haha#omg
-//
-// which was probably extracted from its address form:
-//
-// "Bob Barker" <sip:bob%20barker:priceisright@[dead:beef::666]:5060;isup-oli=00/palfun.html?haha#omg>;tag=666
-//
-// who would have thought this could be so hard ._.
-*)
-
-type url = {
- scheme : string; (* http, sip, file, etc. (never blank, always lowercase) *)
- user : string; (* who is you *)
- pass : string; (* for like, logging in *)
- host : string; (* IP 4/6 address or hostname (mandatory) *)
- port : int; (* like 80 or 5060 (default 0) *)
- params : string; (* stuff after ';' (NOT UNESCAPED, used in sip) *)
- path : string; (* stuff starting with '/' *)
- query : string; (* stuff after '?' (NOT UNESCAPED) *)
- fragment : string; (* stuff after '#' *)
-}
-
-let fail fmt = Printf.ksprintf failwith fmt
-
-let unhex c =
- match c with
- | '0'..'9' -> Char.code c - Char.code '0'
- | 'a'..'f' -> Char.code c - Char.code 'a' + 10
- | 'A'..'F' -> Char.code c - Char.code 'A' + 10
- | _ -> fail "unhex %C" c
-
-let parse_authority u data =
- let (cs, p, pe, eof) = (ref 0, ref 0, ref (String.length data), ref (String.length data)) in
- let mark = ref 0 in
-
-(*
- // temporary holding place for user:pass and/or host:port cuz an
- // optional term (user[:pass]) coming before a mandatory term
- // (host[:pass]) would require require backtracking and all that
- // evil nondeterministic stuff which ragel seems to hate. (for
- // this same reason you're also allowed to use square quotes
- // around the username.)
-*)
- let (b1, b2) = (ref "", ref "") in
-
-(*
- // this buffer is so we can unescape while we roll
- var hex byte
- buf := make([]byte, len(data))
- amt := 0
-*)
- let buf = Buffer.create 10 in
- let hex = ref 0 in
-
- %%{
- action mark { mark := !p }
- action str_start { Buffer.reset buf }
- action str_char { Buffer.add_char buf data.[p.contents] }
- action str_lower { Buffer.add_char buf (Char.lowercase data.[p.contents])}
- action hex_hi { hex := unhex data.[p.contents] * 16 }
- action hex_lo { Buffer.add_char buf (Char.chr (!hex + unhex data.[p.contents])) }
- action copy_b1 { b1 := Buffer.contents buf; Buffer.clear buf }
- action copy_b2 { b2 := Buffer.contents buf; Buffer.clear buf }
- action copy_host { u := { !u with host = !b1 }; Buffer.clear buf }
-
- action copy_port {
- if !b2 <> "" then
- begin
- u := { !u with port = int_of_string !b2 };
- if !u.port > 65535 then fail "bad url authority: %S" data
- end
- }
-
- action params {
- u := { !u with params = String.sub data !mark (!p - !mark) }
- }
-
- action params_eof {
- u := { !u with params = String.sub data !mark (!p - !mark) }
-(* return nil *)
- }
-
- action atsymbol {
- u := { !u with user = !b1; pass = !b2 };
- b2 := ""
- }
-
- action alldone {
- u := { !u with host = !b1 };
- if !u.host = "" then
- u := { !u with host = Buffer.contents buf }
- else
- begin
- if Buffer.length buf > 0 then b2 := Buffer.contents buf;
- if !b2 <> "" then
- begin
- u := { !u with port = int_of_string !b2 };
- if !u.port > 65535 then fail "bad url authority: %S" data
- end
- end
-(* return nil *)
- }
-
- # define what a single character is allowed to be
- toxic = ( cntrl | 127 ) ;
- scary = ( toxic | space | "\"" | "#" | "%" | "<" | ">" ) ;
- authdelims = ( "/" | "?" | "#" | ":" | "@" | ";" | "[" | "]" ) ;
- userchars = any -- ( authdelims | scary ) ;
- userchars_esc = userchars | ":" ;
- passchars = userchars ;
- hostchars = passchars | "@" ;
- hostchars_esc = hostchars | ":" ;
- portchars = digit ;
- paramchars = hostchars | ":" | ";" ;
-
- # define how characters trigger actions
- escape = "%" xdigit xdigit ;
- unescape = "%" ( xdigit @hex_hi ) ( xdigit @hex_lo ) ;
- userchar = unescape | ( userchars @str_char ) ;
- userchar_esc = unescape | ( userchars_esc @str_char ) ;
- passchar = unescape | ( passchars @str_char ) ;
- hostchar = unescape | ( hostchars @str_char ) ;
- hostchar_esc = unescape | ( hostchars_esc @str_char ) ;
- portchar = unescape | ( portchars @str_char ) ;
- paramchar = escape | paramchars ;
-
- # define multi-character patterns
- user_plain = userchar+ >str_start %copy_b1 ;
- user_quoted = "[" ( userchar_esc+ >str_start %copy_b1 ) "]" ;
- user = ( user_quoted | user_plain ) %/alldone ;
- pass = passchar+ >str_start %copy_b2 %/alldone ;
- host_plain = hostchar+ >str_start %copy_b1 %copy_host ;
- host_quoted = "[" ( hostchar_esc+ >str_start %copy_b1 %copy_host ) "]" ;
- host = ( host_quoted | host_plain ) %/alldone ;
- port = portchar* >str_start %copy_b2 %copy_port %/alldone ;
- params = ";" ( paramchar* >mark %params %/params_eof ) ;
- userpass = user ( ":" pass )? ;
- hostport = host ( ":" port )? ;
- authority = ( userpass ( "@" @atsymbol ) )? hostport params? ;
-
- main := authority;
- write init;
- write exec;
- }%%
-
- (*
- // if cs >= url_authority_first_final {
- // return nil
- // }
- *)
-
- (*
- // fmt.Println("error state", cs)
- // fmt.Println(string(data))
- // for i := 0; i < p; i++ {
- // fmt.Print(" ")
- // }
- // fmt.Println("^")
- // fmt.Println(url)
- *)
- ;;
-
-
-let dummy = {
- scheme = ""; user = ""; pass = ""; host = ""; port = 0;
- params = ""; path = ""; query = ""; fragment = ""; }
-
-let show u =
- Printf.sprintf "%s :// %s : %s @ %s : %d ;%s %s ?%s #%s" u.scheme u.user u.pass u.host u.port
- u.params u.path u.query u.fragment
-
-%% machine url;
-%% write data;
-
-(*
-// i parse absolute urls and don't suck at it. i'll parse just about
-// any type of url you can think of and give you a human-friendly data
-// structure.
-//
-// this routine takes no more than a few microseconds, is reentrant,
-// performs in a predictable manner (for security/soft-realtime,)
-// doesn't modify your `data` buffer, and under no circumstances will
-// it panic (i hope!)
-*)
-let url_parse data =
- let (cs, p, pe, eof) = (ref 0, ref 0, ref (String.length data), ref (String.length data)) in
- let mark = ref 0 in
- let u = ref dummy in
-
- (*
- // this buffer is so we can unescape while we roll
- *)
- let buf = Buffer.create 16 in
- let hex = ref 0 in
-
- %%{
- action mark { mark := !p }
- action str_start { Buffer.reset buf }
- action str_char { Buffer.add_char buf data.[p.contents] }
- action str_lower { Buffer.add_char buf (Char.lowercase data.[p.contents])}
- action hex_hi { hex := unhex data.[p.contents] * 16 }
- action hex_lo { Buffer.add_char buf (Char.chr (!hex + unhex data.[p.contents])) }
- action scheme { u := { !u with scheme = Buffer.contents buf } }
- action authority { parse_authority u (String.sub data !mark (!p - !mark)) }
- action path { u := { !u with path = Buffer.contents buf } }
- action query { u := { !u with query = String.sub data !mark (!p - !mark) } }
- action fragment { u := { !u with fragment = Buffer.contents buf } }
-
- # # do this instead if you *actually* use URNs (lol)
- # action authority { url.Authority = string(data[mark:p]) }
-
- # define what a single character is allowed to be
- toxic = ( cntrl | 127 ) ;
- scary = ( toxic | " " | "\"" | "#" | "%" | "<" | ">" ) ;
- schmchars = ( lower | digit | "+" | "-" | "." ) ;
- authchars = any -- ( scary | "/" | "?" | "#" ) ;
- pathchars = any -- ( scary | "?" | "#" ) ;
- querchars = any -- ( scary | "#" ) ;
- fragchars = any -- ( scary ) ;
-
- # define how characters trigger actions
- escape = "%" xdigit xdigit ;
- unescape = "%" ( xdigit @hex_hi ) ( xdigit @hex_lo ) ;
- schmfirst = ( upper @str_lower ) | ( lower @str_char ) ;
- schmchar = ( upper @str_lower ) | ( schmchars @str_char ) ;
- authchar = escape | authchars ;
- pathchar = unescape | ( pathchars @str_char ) ;
- querchar = escape | querchars ;
- fragchar = unescape | ( fragchars @str_char ) ;
-
- # define multi-character patterns
- scheme = ( schmfirst schmchar* ) >str_start %scheme ;
- authority = authchar+ >mark %authority ;
- path = ( ( "/" @str_char ) pathchar* ) >str_start %path ;
- query = "?" ( querchar* >mark %query ) ;
- fragment = "#" ( fragchar* >str_start %fragment ) ;
- url = scheme ":" "//"? authority path? query? fragment?
- | scheme ":" "//" authority? path? query? fragment?
- ;
-
- main := url;
- write init;
- write exec;
- }%%
-
- if !cs < url_first_final then
- if !p = !pe then
- fail "unexpected eof: %s" data
- else
- fail "error in url at pos %d (%c): %s" !p data.[!p] data
- else
- !u
-
-(* ////////////////////////////////////////////////////////////////////// *)
-
-let tests = [
- "http://user:pass@example.com:80;hello/lol.php?fun#omg",
- {
- scheme = "http";
- user = "user";
- pass = "pass";
- host = "example.com";
- port = 80;
- params = "hello";
- path = "/lol.php";
- query = "fun";
- fragment = "omg";
- };
-
- "a:b",
- { dummy with
- scheme = "a";
- host = "b";
- };
-
- "GoPHeR://@example.com@:;/?#",
- { dummy with
- scheme = "gopher";
- host = "@example.com@";
- path = "/";
- };
-
- "ldap://[2001:db8::7]/c=GB?objectClass/?one",
- { dummy with
- scheme = "ldap";
- host = "2001:db8::7";
- path = "/c=GB";
- query = "objectClass/?one";
- };
-
- "http://user@example.com",
- { dummy with
- scheme = "http";
- user = "user";
- host = "example.com";
- };
-
- "http://品研发和研发管@☃.com:65000;%20",
- { dummy with
- scheme = "http";
- user = "品研发和研发管";
- host = "☃.com";
- port = 65000;
- params = "%20";
- };
-
- "https://example.com:80",
- { dummy with
- scheme = "https";
- host = "example.com";
- port = 80;
- };
-
- "file:///etc/passwd",
- { dummy with
- scheme = "file";
- path = "/etc/passwd";
- };
-
- "file:///c:/WINDOWS/clock.avi",
- { dummy with
- scheme = "file";
- path = "/c:/WINDOWS/clock.avi"; (* <-- is this kosher? *)
- };
-
- "file://hostname/path/to/the%20file.txt",
- { dummy with
- scheme = "file";
- host = "hostname";
- path = "/path/to/the file.txt";
- };
-
- "sip:example.com",
- { dummy with
- scheme = "sip";
- host = "example.com";
- };
-
- "sip:example.com:5060",
- { dummy with
- scheme = "sip";
- host = "example.com";
- port = 5060;
- };
-
- "mailto:ditto@pokémon.com",
- { dummy with
- scheme = "mailto";
- user = "ditto";
- host = "pokémon.com";
- };
-
- "sip:[dead:beef::666]:5060",
- { dummy with
- scheme = "sip";
- host = "dead:beef::666";
- port = 5060;
- };
-
- "tel:+12126660420",
- { dummy with
- scheme = "tel";
- host = "+12126660420";
- };
-
- "sip:bob%20barker:priceisright@[dead:beef::666]:5060;isup-oli=00/palfun.html?haha#omg",
- {
- scheme = "sip";
- user = "bob barker";
- pass = "priceisright";
- host = "dead:beef::666";
- port = 5060;
- params = "isup-oli=00";
- path = "/palfun.html";
- query = "haha";
- fragment = "omg";
- };
-
- "http://www.google.com/search?%68l=en&safe=off&q=omfg&aq=f&aqi=g2g-s1g1g-s1g5&aql=&oq=&gs_rfai=",
- { dummy with
- scheme = "http";
- host = "www.google.com";
- path = "/search";
- query = "%68l=en&safe=off&q=omfg&aq=f&aqi=g2g-s1g1g-s1g5&aql=&oq=&gs_rfai=";
- };
-]
-
-(*
-func (test *urlTest) compare(url *URL) (passed bool) {
- if url.Scheme != test.url.Scheme {
- fmt.Fprintf(os.Stderr, "FAIL url(%#v) scheme: %#v != %#v\n",
- string(test.s), url.Scheme, test.url.Scheme)
- passed = true
- }
- if url.User != test.url.User {
- fmt.Fprintf(os.Stderr, "FAIL url(%#v) user: %#v != %#v\n",
- string(test.s), url.User, test.url.User)
- passed = true
- }
- if url.Pass != test.url.Pass {
- fmt.Fprintf(os.Stderr, "FAIL url(%#v) pass: %#v != %#v\n",
- string(test.s), url.Pass, test.url.Pass)
- passed = true
- }
- if url.Host != test.url.Host {
- fmt.Fprintf(os.Stderr, "FAIL url(%#v) host: %#v != %#v\n",
- string(test.s), url.Host, test.url.Host)
- passed = true
- }
- if url.Port != test.url.Port {
- fmt.Fprintf(os.Stderr, "FAIL url(%#v) port: %#v != %#v\n",
- string(test.s), url.Port, test.url.Port)
- passed = true
- }
- if url.Port != test.url.Port {
- fmt.Fprintf(os.Stderr, "FAIL url(%#v) port: %#v != %#v\n",
- string(test.s), url.Port, test.url.Port)
- passed = true
- }
- if url.Params != test.url.Params {
- fmt.Fprintf(os.Stderr, "FAIL url(%#v) params: %#v != %#v\n",
- string(test.s), url.Params, test.url.Params)
- passed = true
- }
- if url.Path != test.url.Path {
- fmt.Fprintf(os.Stderr, "FAIL url(%#v) path: %#v != %#v\n",
- string(test.s), url.Path, test.url.Path)
- passed = true
- }
- if url.Query != test.url.Query {
- fmt.Fprintf(os.Stderr, "FAIL url(%#v) query: %#v != %#v\n",
- string(test.s), url.Query, test.url.Query)
- passed = true
- }
- if url.Fragment != test.url.Fragment {
- fmt.Fprintf(os.Stderr, "FAIL url(%#v) fragment: %#v != %#v\n",
- string(test.s), url.Fragment, test.url.Fragment)
- passed = true
- }
- return !passed
-}
-*)
-
-let bench () =
- let rounds = 0 in
- let urls = [
- "a:a";
- "http://google.com/";
- "sip:jtunney@lobstertech.com";
- "http://user:pass@example.com:80;hello/lol.php?fun#omg";
- "file:///etc/passwd";
- ] in
- List.iter (fun url ->
- for i = 1 to rounds do
- ignore (url_parse url)
- done;
- Printf.printf "BENCH parse %S \n%!" url
- ) urls
-
-let test () =
- List.iter (fun (s,res) ->
- let url = url_parse s in
- if url <> res then
- fail "got %S for %S" (show url) (*show res*) s
- ) tests
-
-let () =
- test ();
- bench ();
- exit 0
-
-##### OUTPUT #####
-BENCH parse "a:a"
-BENCH parse "http://google.com/"
-BENCH parse "sip:jtunney@lobstertech.com"
-BENCH parse "http://user:pass@example.com:80;hello/lol.php?fun#omg"
-BENCH parse "file:///etc/passwd"
diff --git a/test/ragel.d/xml.rl b/test/ragel.d/xml.rl
deleted file mode 100644
index 650e9679..00000000
--- a/test/ragel.d/xml.rl
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * XML parser based on the XML 1.0 BNF from:
- * http://www.jelks.nu/XML/xmlebnf.html
- *
- * @LANG: c++
- * @PROHIBIT_FLAGS: -m -n -F0 -F1 -G0 -G1 -G2 -W0 -W1
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <stdio.h>
-
-using namespace std;
-
-#define BUFSIZE 2048
-
-struct XML
-{
- int cur_char;
- int start_word;
- int start_comment;
- int start_literal;
-
- int cs, top, stack[1024];
-
- int init( );
- int execute( const unsigned short *data, int len );
- int finish( );
-};
-
-%%{
- machine XML;
- alphtype unsigned short;
-
- action next_char {
- cur_char += 1;
- }
-
- action start_word {
- start_word = cur_char;
- }
- action end_word {
- cout << "word: " << start_word <<
- " " << cur_char-1 << endl;
- }
-
- Extender = 0x00B7 | 0x02D0 | 0x02D1 | 0x0387 | 0x0640 | 0x0E46 | 0x0EC6 | 0x3005 | (0x3031..0x3035) | (0x309D..0x309E) | (0x30FC..0x30FE);
-
- Digit = (0x0030..0x0039) | (0x0660..0x0669) | (0x06F0..0x06F9) | (0x0966..0x096F) | (0x09E6..0x09EF) | (0x0A66..0x0A6F) | (0x0AE6..0x0AEF) | (0x0B66..0x0B6F) | (0x0BE7..0x0BEF) | (0x0C66..0x0C6F) | (0x0CE6..0x0CEF) | (0x0D66..0x0D6F) | (0x0E50..0x0E59) | (0x0ED0..0x0ED9) | (0x0F20..0x0F29);
-
- CombiningChar = (0x0300..0x0345) | (0x0360..0x0361) | (0x0483..0x0486) | (0x0591..0x05A1) | (0x05A3..0x05B9) | (0x05BB..0x05BD) | 0x05BF | (0x05C1..0x05C2) | 0x05C4 | (0x064B..0x0652) | 0x0670 | (0x06D6..0x06DC) | (0x06DD..0x06DF) | (0x06E0..0x06E4) | (0x06E7..0x06E8) | (0x06EA..0x06ED) | (0x0901..0x0903) | 0x093C | (0x093E..0x094C) | 0x094D | (0x0951..0x0954) | (0x0962..0x0963) | (0x0981..0x0983) | 0x09BC | 0x09BE | 0x09BF | (0x09C0..0x09C4) | (0x09C7..0x09C8) | (0x09CB..0x09CD) | 0x09D7 | (0x09E2..0x09E3) | 0x0A02 | 0x0A3C | 0x0A3E | 0x0A3F | (0x0A40..0x0A42) | (0x0A47..0x0A48) | (0x0A4B..0x0A4D) | (0x0A70..0x0A71) | (0x0A81..0x0A83) | 0x0ABC | (0x0ABE..0x0AC5) | (0x0AC7..0x0AC9) | (0x0ACB..0x0ACD) | (0x0B01..0x0B03) | 0x0B3C | (0x0B3E..0x0B43) | (0x0B47..0x0B48) | (0x0B4B..0x0B4D) | (0x0B56..0x0B57) | (0x0B82..0x0B83) | (0x0BBE..0x0BC2) | (0x0BC6..0x0BC8) | (0x0BCA..0x0BCD) | 0x0BD7 | (0x0C01..0x0C03) | (0x0C3E..0x0C44) | (0x0C46..0x0C48) | (0x0C4A..0x0C4D) | (0x0C55..0x0C56) | (0x0C82..0x0C83) | (0x0CBE..0x0CC4) | (0x0CC6..0x0CC8) | (0x0CCA..0x0CCD) | (0x0CD5..0x0CD6) | (0x0D02..0x0D03) | (0x0D3E..0x0D43) | (0x0D46..0x0D48) | (0x0D4A..0x0D4D) | 0x0D57 | 0x0E31 | (0x0E34..0x0E3A) | (0x0E47..0x0E4E) | 0x0EB1 | (0x0EB4..0x0EB9) | (0x0EBB..0x0EBC) | (0x0EC8..0x0ECD) | (0x0F18..0x0F19) | 0x0F35 | 0x0F37 | 0x0F39 | 0x0F3E | 0x0F3F | (0x0F71..0x0F84) | (0x0F86..0x0F8B) | (0x0F90..0x0F95) | 0x0F97 | (0x0F99..0x0FAD) | (0x0FB1..0x0FB7) | 0x0FB9 | (0x20D0..0x20DC) | 0x20E1 | (0x302A..0x302F) | 0x3099 | 0x309A;
-
- Ideographic = (0x4E00..0x9FA5) | 0x3007 | (0x3021..0x3029);
-
- BaseChar = (0x0041..0x005A) | (0x0061..0x007A) | (0x00C0..0x00D6) | (0x00D8..0x00F6) | (0x00F8..0x00FF) | (0x0100..0x0131) | (0x0134..0x013E) | (0x0141..0x0148) | (0x014A..0x017E) | (0x0180..0x01C3) | (0x01CD..0x01F0) | (0x01F4..0x01F5) | (0x01FA..0x0217) | (0x0250..0x02A8) | (0x02BB..0x02C1) | 0x0386 | (0x0388..0x038A) | 0x038C | (0x038E..0x03A1) | (0x03A3..0x03CE) | (0x03D0..0x03D6) | 0x03DA | 0x03DC | 0x03DE | 0x03E0 | (0x03E2..0x03F3) | (0x0401..0x040C) | (0x040E..0x044F) | (0x0451..0x045C) | (0x045E..0x0481) | (0x0490..0x04C4) | (0x04C7..0x04C8) | (0x04CB..0x04CC) | (0x04D0..0x04EB) | (0x04EE..0x04F5) | (0x04F8..0x04F9) | (0x0531..0x0556) | 0x0559 | (0x0561..0x0586) | (0x05D0..0x05EA) | (0x05F0..0x05F2) | (0x0621..0x063A) | (0x0641..0x064A) | (0x0671..0x06B7) | (0x06BA..0x06BE) | (0x06C0..0x06CE) | (0x06D0..0x06D3) | 0x06D5 | (0x06E5..0x06E6) | (0x0905..0x0939) | 0x093D | (0x0958..0x0961) | (0x0985..0x098C) | (0x098F..0x0990) | (0x0993..0x09A8) | (0x09AA..0x09B0) | 0x09B2 | (0x09B6..0x09B9) | (0x09DC..0x09DD) | (0x09DF..0x09E1) | (0x09F0..0x09F1) | (0x0A05..0x0A0A) | (0x0A0F..0x0A10) | (0x0A13..0x0A28) | (0x0A2A..0x0A30) | (0x0A32..0x0A33) | (0x0A35..0x0A36) | (0x0A38..0x0A39) | (0x0A59..0x0A5C) | 0x0A5E | (0x0A72..0x0A74) | (0x0A85..0x0A8B) | 0x0A8D | (0x0A8F..0x0A91) | (0x0A93..0x0AA8) | (0x0AAA..0x0AB0) | (0x0AB2..0x0AB3) | (0x0AB5..0x0AB9) | 0x0ABD | 0x0AE0 | (0x0B05..0x0B0C) | (0x0B0F..0x0B10) | (0x0B13..0x0B28) | (0x0B2A..0x0B30) | (0x0B32..0x0B33) | (0x0B36..0x0B39) | 0x0B3D | (0x0B5C..0x0B5D) | (0x0B5F..0x0B61) | (0x0B85..0x0B8A) | (0x0B8E..0x0B90) | (0x0B92..0x0B95) | (0x0B99..0x0B9A) | 0x0B9C | (0x0B9E..0x0B9F) | (0x0BA3..0x0BA4) | (0x0BA8..0x0BAA) | (0x0BAE..0x0BB5) | (0x0BB7..0x0BB9) | (0x0C05..0x0C0C) | (0x0C0E..0x0C10) | (0x0C12..0x0C28) | (0x0C2A..0x0C33) | (0x0C35..0x0C39) | (0x0C60..0x0C61) | (0x0C85..0x0C8C) | (0x0C8E..0x0C90) | (0x0C92..0x0CA8) | (0x0CAA..0x0CB3) | (0x0CB5..0x0CB9) | 0x0CDE | (0x0CE0..0x0CE1) | (0x0D05..0x0D0C) | (0x0D0E..0x0D10) | (0x0D12..0x0D28) | (0x0D2A..0x0D39) | (0x0D60..0x0D61) | (0x0E01..0x0E2E) | 0x0E30 | (0x0E32..0x0E33) | (0x0E40..0x0E45) | (0x0E81..0x0E82) | 0x0E84 | (0x0E87..0x0E88) | 0x0E8A | 0x0E8D | (0x0E94..0x0E97) | (0x0E99..0x0E9F) | (0x0EA1..0x0EA3) | 0x0EA5 | 0x0EA7 | (0x0EAA..0x0EAB) | (0x0EAD..0x0EAE) | 0x0EB0 | (0x0EB2..0x0EB3) | 0x0EBD | (0x0EC0..0x0EC4) | (0x0F40..0x0F47) | (0x0F49..0x0F69) | (0x10A0..0x10C5) | (0x10D0..0x10F6) | 0x1100 | (0x1102..0x1103) | (0x1105..0x1107) | 0x1109 | (0x110B..0x110C) | (0x110E..0x1112) | 0x113C | 0x113E | 0x1140 | 0x114C | 0x114E | 0x1150 | (0x1154..0x1155) | 0x1159 | (0x115F..0x1161) | 0x1163 | 0x1165 | 0x1167 | 0x1169 | (0x116D..0x116E) | (0x1172..0x1173) | 0x1175 | 0x119E | 0x11A8 | 0x11AB | (0x11AE..0x11AF) | (0x11B7..0x11B8) | 0x11BA | (0x11BC..0x11C2) | 0x11EB | 0x11F0 | 0x11F9 | (0x1E00..0x1E9B) | (0x1EA0..0x1EF9) | (0x1F00..0x1F15) | (0x1F18..0x1F1D) | (0x1F20..0x1F45) | (0x1F48..0x1F4D) | (0x1F50..0x1F57) | 0x1F59 | 0x1F5B | 0x1F5D | (0x1F5F..0x1F7D) | (0x1F80..0x1FB4) | (0x1FB6..0x1FBC) | 0x1FBE | (0x1FC2..0x1FC4) | (0x1FC6..0x1FCC) | (0x1FD0..0x1FD3) | (0x1FD6..0x1FDB) | (0x1FE0..0x1FEC) | (0x1FF2..0x1FF4) | (0x1FF6..0x1FFC) | 0x2126 | (0x212A..0x212B) | 0x212E | (0x2180..0x2182) | (0x3041..0x3094) | (0x30A1..0x30FA) | (0x3105..0x312C) | (0xAC00..0xD7A3);
-
- # Full Unicode 3.1 requires: Char = 0x9 | 0xA | 0xD | (0x20..0xD7FF) | (0xE000..0xFFFD) | (0x10000..0x10FFFF);
-
- Char = 0x9 | 0xA | 0xD | (0x20..0xD7FF) | (0xE000..0xFFFD);
-
- Letter = BaseChar | Ideographic;
-
- NameChar = Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender;
-
- include CommonXml "xmlcommon.rl";
-
-}%%
-
- %% write data;
-
- int XML::init( )
- {
- %% write init;
- cur_char = 0;
- return 1;
- }
-
- int XML::execute( const unsigned short *data, int len )
- {
- const unsigned short *p = data;
- const unsigned short *pe = data + len;
-
- %% write exec;
-
- if ( cs == XML_error )
- return -1;
- if ( cs >= XML_first_final )
- return 1;
- return 0;
- }
-
- int XML::finish( )
- {
- if ( cs == XML_error )
- return -1;
- if ( cs >= XML_first_final )
- return 1;
- return 0;
- }
-
- int main()
- {
- return 0;
- }
diff --git a/test/ragel.d/xmlcommon.rl b/test/ragel.d/xmlcommon.rl
deleted file mode 100644
index dd4a38c0..00000000
--- a/test/ragel.d/xmlcommon.rl
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * This file is included by xml.rl
- *
- * @ENABLED: no
- */
-
-%%{
-
- #
- # Common XML grammar rules based on the XML 1.0 BNF from:
- # http://www.jelks.nu/XML/xmlebnf.html
- #
-
- machine CommonXml;
-
- S = (0x20 | 0x9 | 0xD | 0xA)+;
-
- # WAS PubidChar = 0x20 | 0xD | 0xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%];
- PubidChar = 0x20 | 0xD | 0xA | [a-zA-Z0-9] | [\-'()+,./:=?;!*#@$_%];
-
- PubidLiteral = '"' PubidChar* '"' | "'" (PubidChar - "'")* "'";
-
- Name = (Letter | '_' | ':') (NameChar)*;
-
- Comment = '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->';
-
- # Used strong subtraction operator, and replaced * with +. Ragel complained since using
- # * results in a machine that accepts 0 length strings, and later it's only used in an
- # optional construct anyway.
- #
- CharData_Old = [^<&]* - ([^<&]* ']]>' [^<&]*);
- CharData = [^<&]+ -- ']]>';
-
- SystemLiteral = ('"' [^"]* '"') | ("'" [^']* "'");
-
- Eq = S? '=' S?;
-
- VersionNum = ([a-zA-Z0-9_.:] | '-')+;
-
- # WAS S 'version' Eq (' VersionNum ' | " VersionNum ") - fixed quotes
- VersionInfo = S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"');
-
- ExternalID = 'SYSTEM' S SystemLiteral | 'PUBLIC' S PubidLiteral S SystemLiteral;
-
- PublicID = 'PUBLIC' S PubidLiteral;
-
- NotationDecl = '<!NOTATION' S Name S (ExternalID | PublicID) S? '>';
-
- EncName = [A-Za-z] ([A-Za-z0-9._] | '-')*;
-
- EncodingDecl = S 'encoding' Eq ('"' EncName '"' | "'" EncName "'" );
-
- # UNUSED TextDecl = '<?xml' VersionInfo? EncodingDecl S? '?>';
-
- NDataDecl = S 'NDATA' S Name;
-
- PEReference = '%' Name ';';
-
- EntityRef = '&' Name ';';
-
- CharRef = '&#' [0-9]+ ';' | '&0x' [0-9a-fA-F]+ ';';
-
- Reference = EntityRef | CharRef;
-
- EntityValue = '"' ([^%&"] | PEReference | Reference)* '"' | "'" ([^%&'] | PEReference | Reference)* "'";
-
- PEDef = EntityValue | ExternalID;
-
- EntityDef = EntityValue | (ExternalID NDataDecl?);
-
- PEDecl = '<!ENTITY' S '%' S Name S PEDef S? '>';
-
- GEDecl = '<!ENTITY' S Name S EntityDef S? '>';
-
- EntityDecl = GEDecl | PEDecl;
-
- Mixed = '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' | '(' S? '#PCDATA' S? ')';
-
- # WAS cp = (Name | choice | seq) ('?' | '*' | '+')?;
-
- # WAS seq = '(' S? cp ( S? ',' S? cp )* S? ')';
-
- # WAS choice = '(' S? cp ( S? '|' S? cp )* S? ')';
-
- # WAS children = (choice | seq) ('?' | '*' | '+')?;
-
- # TODO put validation for this in and make it clearer
- alt = '?' | '*' | '+';
- children = '(' S?
- ( ( Name alt? ) |
- '(' |
- ( ')' alt? ) |
- [,|] |
- S )
- ')' alt?;
-
- contentspec = 'EMPTY' | 'ANY' | Mixed | children;
-
- elementdecl = '<!ELEMENT' S Name S contentspec S? '>';
-
- AttValue = '"' ([^<&"] | Reference)* '"' | "'" ([^<&'] | Reference)* "'";
-
- Attribute = Name Eq AttValue;
-
- Nmtoken = (NameChar)+;
-
- # UNUSED Nmtokens = Nmtoken (S Nmtoken)*;
-
- Enumeration = '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')';
-
- NotationType = 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')';
-
- EnumeratedType = NotationType | Enumeration;
-
- TokenizedType = 'ID' | 'IDREF' | 'IDREFS' | 'ENTITY' | 'ENTITIES' | 'NMTOKEN' | 'NMTOKENS';
-
- StringType = 'CDATA';
-
- AttType = StringType | TokenizedType | EnumeratedType;
-
- DefaultDecl = '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? AttValue);
-
- AttDef = S Name S AttType S DefaultDecl;
-
- AttlistDecl = '<!ATTLIST' S Name AttDef* S? '>';
-
- EmptyElemTag = '<' Name (S Attribute)* S? '/>';
-
- ETag = '</' Name S? '>';
-
- PITarget_Old = Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'));
- PITarget = Name -- "xml"i;
-
- PI = '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>';
-
- markupdecl = elementdecl | AttlistDecl | EntityDecl | NotationDecl | PI | Comment;
-
- doctypedecl = '<!DOCTYPE' S Name (S ExternalID)? S? ('[' (markupdecl | PEReference | S)* ']' S?)? '>';
-
- # TODO extSubsetDecl = ( markupdecl | conditionalSect | PEReference | S )*;
- # UNUSED extSubsetDecl = ( markupdecl | PEReference | S )*;
-
- # UNUSED extSubset = TextDecl? extSubsetDecl;
-
- # UNUSED Ignore = Char* - (Char* ('<![' | ']]>') Char*);
-
- # TODO: ignoreSectContents = Ignore ('<![' ignoreSectContents ']]>' Ignore)*;
- # UNUSED ignoreSectContents = Ignore ('<![' ']]>' Ignore)*;
-
- # UNUSED ignoreSect = '<![' S? 'IGNORE' S? '[' ignoreSectContents* ']]>';
-
- # UNUSED includeSect = '<![' S? 'INCLUDE' S? '[' extSubsetDecl ']]>';
-
- # UNUSED conditionalSect = includeSect | ignoreSect;
-
- STag = '<' Name (S Attribute)* S? '>';
-
- CDStart = '<![CDATA[';
-
- CDEnd = ']]>';
-
- # WAS CData = (Char* - (Char* ']]>' Char*));
- CData = (Char* -- CDEnd);
-
- CDSect = CDStart CData CDEnd;
-
- # UNUSED Subcode = ([a-z] | [A-Z])+;
-
- # UNUSED UserCode = ('x' | 'X') '-' ([a-z] | [A-Z])+;
-
- # UNUSED IanaCode = ('i' | 'I') '-' ([a-z] | [A-Z])+;
-
- # UNUSED ISO639Code = ([a-z] | [A-Z]) ([a-z] | [A-Z]);
-
- # UNUSED Langcode = ISO639Code | IanaCode | UserCode;
-
- # UNUSED LanguageID = Langcode ('-' Subcode)*;
-
- SDDecl = S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'));
-
- # UNUSED extPE = TextDecl? extSubsetDecl;
-
- Misc = Comment | PI | S;
-
- XMLDecl = '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>';
-
- prolog = XMLDecl? Misc* (doctypedecl Misc*)?;
-
- # UNUSED Names = Name (S Name)*;
-
- # Added fcall - TODO check logic is correct
- # UNUSED extParsedEnt = TextDecl? @{fcall content;};
-
- # TODO tag stack validation
-
- # WAS element = EmptyElemTag | STag content ETag
- # WAS content = (element | CharData | Reference | CDSect | PI | Comment)*;
- content = (EmptyElemTag | STag | ETag | CharData | Reference | CDSect | PI | Comment)*;
-
- # WAS document = prolog element Misc*;
- document = prolog ( EmptyElemTag | ( STag content ETag ) ) Misc*;
-
- main := document;
-
-}%%
diff --git a/test/ragel.d/zlen1.rl b/test/ragel.d/zlen1.rl
deleted file mode 100644
index 279818a0..00000000
--- a/test/ragel.d/zlen1.rl
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * @LANG: indep
- */
-
-%%{
- machine zlen1;
- main := zlen;
-}%%
-
-##### INPUT #####
-""
-"x"
-##### OUTPUT #####
-ACCEPT
-FAIL