summaryrefslogtreecommitdiff
path: root/test/range.rl
diff options
context:
space:
mode:
authorthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>2007-01-21 22:58:22 +0000
committerthurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0>2007-01-21 22:58:22 +0000
commit12056158053532946b53b6249cb0e6cfd4580051 (patch)
tree9b5449ef42e829f98bf7a6c6e0554b88d4ab9132 /test/range.rl
downloadragel-12056158053532946b53b6249cb0e6cfd4580051.tar.gz
ragel-12056158053532946b53b6249cb0e6cfd4580051.tar.bz2
ragel-12056158053532946b53b6249cb0e6cfd4580051.zip
Import from my private repository. Snapshot after version 5.16, immediately
following the rewrite of the parsers. Repository revision number 3961. git-svn-id: http://svn.complang.org/ragel/trunk@2 052ea7fc-9027-0410-9066-f65837a77df0
Diffstat (limited to 'test/range.rl')
-rw-r--r--test/range.rl76
1 files changed, 76 insertions, 0 deletions
diff --git a/test/range.rl b/test/range.rl
new file mode 100644
index 0000000..34bc430
--- /dev/null
+++ b/test/range.rl
@@ -0,0 +1,76 @@
+/*
+ * @LANG: c
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+struct range
+{
+ int cs;
+};
+
+%%{
+ machine range_fsm;
+ variable curstate 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 )
+{
+ %% write eof;
+
+ if ( fsm->cs == range_fsm_error )
+ return -1;
+ if ( fsm->cs >= range_fsm_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;
+}
+
+#ifdef _____OUTPUT_____
+ACCEPT
+ACCEPT
+ACCEPT
+FAIL
+FAIL
+#endif