Discussion:
[ragel-users] [PATCH 1/3] ocaml codegen: choose unique name for type state
ygrek
2012-06-18 20:48:30 UTC
Permalink
it makes possible to define several machines in one source file
---
ragel/mlcodegen.h | 1 +
ragel/mlfflat.cc | 2 +-
ragel/mlflat.cc | 2 +-
ragel/mlftable.cc | 2 +-
ragel/mlgoto.cc | 2 +-
ragel/mltable.cc | 2 +-
6 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/ragel/mlcodegen.h b/ragel/mlcodegen.h
index 2c91254..c1df012 100644
--- a/ragel/mlcodegen.h
+++ b/ragel/mlcodegen.h
@@ -135,6 +135,7 @@ protected:
string ET() { return "_" + DATA_PREFIX() + "eof_trans"; }
string SP() { return "_" + DATA_PREFIX() + "key_spans"; }
string CSP() { return "_" + DATA_PREFIX() + "cond_key_spans"; }
+ string TYPE_STATE() { return "_" + DATA_PREFIX() + "state"; }
string START() { return DATA_PREFIX() + "start"; }
string ERROR() { return DATA_PREFIX() + "error"; }
string FIRST_FINAL() { return DATA_PREFIX() + "first_final"; }
diff --git a/ragel/mlfflat.cc b/ragel/mlfflat.cc
index 9251a9a..2e14543 100644
--- a/ragel/mlfflat.cc
+++ b/ragel/mlfflat.cc
@@ -235,7 +235,7 @@ void OCamlFFlatCodeGen::writeData()

STATE_IDS();

- out << "type state = { mutable keys : int; mutable trans : int; }"
+ out << "type " << TYPE_STATE() << " = { mutable keys : int; mutable trans : int; }"
<< TOP_SEP();

out << "exception Goto_match" << TOP_SEP();
diff --git a/ragel/mlflat.cc b/ragel/mlflat.cc
index 5307b6e..236dfa1 100644
--- a/ragel/mlflat.cc
+++ b/ragel/mlflat.cc
@@ -634,7 +634,7 @@ void OCamlFlatCodeGen::writeData()

STATE_IDS();

- out << "type state = { mutable trans : int; mutable acts : int; mutable nacts : int; }"
+ out << "type " << TYPE_STATE() << " = { mutable trans : int; mutable acts : int; mutable nacts : int; }"
<< TOP_SEP();

out << "exception Goto_match" << TOP_SEP();
diff --git a/ragel/mlftable.cc b/ragel/mlftable.cc
index 7cf258e..15a9885 100644
--- a/ragel/mlftable.cc
+++ b/ragel/mlftable.cc
@@ -289,7 +289,7 @@ void OCamlFTabCodeGen::writeData()

STATE_IDS();

- out << "type state = { mutable keys : int; mutable trans : int; }"
+ out << "type " << TYPE_STATE() << " = { mutable keys : int; mutable trans : int; }"
<< TOP_SEP();

out << "exception Goto_match" << TOP_SEP();
diff --git a/ragel/mlgoto.cc b/ragel/mlgoto.cc
index 0c9d298..65570d8 100644
--- a/ragel/mlgoto.cc
+++ b/ragel/mlgoto.cc
@@ -659,7 +659,7 @@ void OCamlGotoCodeGen::writeData()

STATE_IDS();

- out << "type state = { mutable acts : " << ARRAY_TYPE(redFsm->maxActionLoc) <<
+ out << "type " << TYPE_STATE() << " = { mutable acts : " << ARRAY_TYPE(redFsm->maxActionLoc) <<
" ; mutable nacts : " << ARRAY_TYPE(redFsm->maxActArrItem) << "; }"
<< TOP_SEP();

diff --git a/ragel/mltable.cc b/ragel/mltable.cc
index 5c4ae2c..b04f725 100644
--- a/ragel/mltable.cc
+++ b/ragel/mltable.cc
@@ -807,7 +807,7 @@ void OCamlTabCodeGen::writeData()

STATE_IDS();

- out << "type state = { mutable keys : int; mutable trans : int; mutable acts : int; mutable nacts : int; }"
+ out << "type " << TYPE_STATE() << " = { mutable keys : int; mutable trans : int; mutable acts : int; mutable nacts : int; }"
<< TOP_SEP();

out << "exception Goto_match" << TOP_SEP();
--
1.7.10
Loading...