diff options
author | thurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0> | 2007-01-21 22:58:22 +0000 |
---|---|---|
committer | thurston <thurston@052ea7fc-9027-0410-9066-f65837a77df0> | 2007-01-21 22:58:22 +0000 |
commit | 12056158053532946b53b6249cb0e6cfd4580051 (patch) | |
tree | 9b5449ef42e829f98bf7a6c6e0554b88d4ab9132 /test/gotocallret2.rl | |
download | ragel-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/gotocallret2.rl')
-rw-r--r-- | test/gotocallret2.rl | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/test/gotocallret2.rl b/test/gotocallret2.rl new file mode 100644 index 0000000..4a3bc0e --- /dev/null +++ b/test/gotocallret2.rl @@ -0,0 +1,77 @@ +/* + * @LANG: indep + */ + +char comm; +int top; +int stack[32]; +ptr tokstart; +ptr tokend; +int act; +int val; +%% +%%{ + machine GotoCallRet; + + sp = ' '; + + handle := any @{ + prints "handle "; + fhold; + if ( val == 1 ) fnext *fentry(one); + if ( val == 2 ) fnext *fentry(two); + if ( val == 3 ) fnext main; + }; + + one := |* + '{' => { prints "{ "; fcall *fentry(one); }; + "[" => { prints "[ "; fcall *fentry(two); }; + "}" sp* => { prints "} "; fret; }; + [a-z]+ => { prints "word "; val = 1; fgoto *fentry(handle); }; + ' ' => { prints "space "; }; + *|; + + two := |* + '{' => { prints "{ "; fcall *fentry(one); }; + "[" => { prints "[ "; fcall *fentry(two); }; + ']' sp* => { prints "] "; fret; }; + [a-z]+ => { prints "word "; val = 2; fgoto *fentry(handle); }; + ' ' => { prints "space "; }; + *|; + + main := |* + '{' => { prints "{ "; fcall one; }; + "[" => { prints "[ "; fcall two; }; + [a-z]+ => { prints "word "; val = 3; fgoto handle; }; + [a-z] ' foil' => { prints "this is the foil";}; + ' ' => { prints "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" +_____INPUT_____ */ +/* _____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 +_____OUTPUT_____ */ + |