diff options
author | Adrian Thurston <thurston@colm.net> | 2020-01-01 20:44:10 +0200 |
---|---|---|
committer | Adrian Thurston <thurston@colm.net> | 2020-01-01 20:44:10 +0200 |
commit | 8661124b75f7baed8a90ccdd638ceb2a2de43754 (patch) | |
tree | 9300de32e1e2c29b4189c785e8d01983087100dd | |
parent | 40c519e1a325d3f69389bbee472dea06118b3770 (diff) | |
download | colm-8661124b75f7baed8a90ccdd638ceb2a2de43754.tar.gz |
added missing open/close block to BREAK and NBREAK
refs #102
-rw-r--r-- | ragel/ipgoto.cc | 8 | ||||
-rw-r--r-- | test/ragel.d/fbreak1.rl | 56 |
2 files changed, 60 insertions, 4 deletions
diff --git a/ragel/ipgoto.cc b/ragel/ipgoto.cc index c273b012..f6db530c 100644 --- a/ragel/ipgoto.cc +++ b/ragel/ipgoto.cc @@ -220,18 +220,18 @@ void IpGoto::TARGS( ostream &ret, bool inFinish, int targState ) void IpGoto::BREAK( ostream &ret, int targState, bool csForced ) { - ret << "{" << P() << "+= 1; "; + ret << OPEN_GEN_BLOCK() << P() << "+= 1; "; if ( !csForced ) ret << vCS() << " = " << targState << "; "; - ret << "goto " << _out << ";}"; + ret << "goto " << _out << ";" << CLOSE_GEN_BLOCK(); } void IpGoto::NBREAK( ostream &ret, int targState, bool csForced ) { - ret << "{" << P() << "+= 1; "; + ret << OPEN_GEN_BLOCK() << P() << "+= 1; "; if ( !csForced ) ret << vCS() << " = " << targState << "; "; - ret << nbreak << " = 1;}"; + ret << nbreak << " = 1;" << CLOSE_GEN_BLOCK(); } void IpGoto::NFA_PUSH_ACTION( RedNfaTarg *targ ) diff --git a/test/ragel.d/fbreak1.rl b/test/ragel.d/fbreak1.rl new file mode 100644 index 00000000..249d85b4 --- /dev/null +++ b/test/ragel.d/fbreak1.rl @@ -0,0 +1,56 @@ +/* + * @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 |