summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2021-11-07 15:24:41 -0800
committerAdrian Thurston <thurston@colm.net>2021-11-07 15:24:41 -0800
commit6e3af69137f6fbe000ce2d8dca33cef764722a40 (patch)
tree9940af8cdf9e4630c63105371187a008f082ba40
parentee588e7fb921afbad8c6b171f69ebd1161f66850 (diff)
downloadragel-6e3af69137f6fbe000ce2d8dca33cef764722a40.tar.gz
moved the findAlphType code from colm over here
-rw-r--r--src/common.cc37
-rw-r--r--src/ncommon.cc39
-rw-r--r--src/nragel.h11
-rw-r--r--src/parsedata.cc3
4 files changed, 52 insertions, 38 deletions
diff --git a/src/common.cc b/src/common.cc
index b36dcace..ff8934e6 100644
--- a/src/common.cc
+++ b/src/common.cc
@@ -28,43 +28,6 @@
#include "ragel.h"
-HostType *findAlphType( const HostLang *hostLang, const char *s1 )
-{
- for ( int i = 0; i < hostLang->numHostTypes; i++ ) {
- if ( strcmp( s1, hostLang->hostTypes[i].data1 ) == 0 &&
- hostLang->hostTypes[i].data2 == 0 )
- {
- return hostLang->hostTypes + i;
- }
- }
-
- return 0;
-}
-
-HostType *findAlphType( const HostLang *hostLang, const char *s1, const char *s2 )
-{
- for ( int i = 0; i < hostLang->numHostTypes; i++ ) {
- if ( strcmp( s1, hostLang->hostTypes[i].data1 ) == 0 &&
- hostLang->hostTypes[i].data2 != 0 &&
- strcmp( s2, hostLang->hostTypes[i].data2 ) == 0 )
- {
- return hostLang->hostTypes + i;
- }
- }
-
- return 0;
-}
-
-HostType *findAlphTypeInternal( const HostLang *hostLang, const char *s1 )
-{
- for ( int i = 0; i < hostLang->numHostTypes; i++ ) {
- if ( strcmp( s1, hostLang->hostTypes[i].internalName ) == 0 )
- return hostLang->hostTypes + i;
- }
-
- return 0;
-}
-
std::streamsize output_filter::countAndWrite( const char *s, std::streamsize n )
{
for ( int i = 0; i < n; i++ ) {
diff --git a/src/ncommon.cc b/src/ncommon.cc
index ae959efd..4e7f270d 100644
--- a/src/ncommon.cc
+++ b/src/ncommon.cc
@@ -26,6 +26,8 @@
#include <libfsm/common.h>
#include <libfsm/ragel.h>
+#include "nragel.h"
+
/*
* C
*/
@@ -68,3 +70,40 @@ extern "C" const HostLang hostLangC = {
&genLineDirectiveC
};
+HostType *findAlphType( const HostLang *hostLang, const char *s1 )
+{
+ for ( int i = 0; i < hostLang->numHostTypes; i++ ) {
+ if ( strcmp( s1, hostLang->hostTypes[i].data1 ) == 0 &&
+ hostLang->hostTypes[i].data2 == 0 )
+ {
+ return hostLang->hostTypes + i;
+ }
+ }
+
+ return 0;
+}
+
+HostType *findAlphType( const HostLang *hostLang, const char *s1, const char *s2 )
+{
+ for ( int i = 0; i < hostLang->numHostTypes; i++ ) {
+ if ( strcmp( s1, hostLang->hostTypes[i].data1 ) == 0 &&
+ hostLang->hostTypes[i].data2 != 0 &&
+ strcmp( s2, hostLang->hostTypes[i].data2 ) == 0 )
+ {
+ return hostLang->hostTypes + i;
+ }
+ }
+
+ return 0;
+}
+
+HostType *findAlphTypeInternal( const HostLang *hostLang, const char *s1 )
+{
+ for ( int i = 0; i < hostLang->numHostTypes; i++ ) {
+ if ( strcmp( s1, hostLang->hostTypes[i].internalName ) == 0 )
+ return hostLang->hostTypes + i;
+ }
+
+ return 0;
+}
+
diff --git a/src/nragel.h b/src/nragel.h
new file mode 100644
index 00000000..f8c7f4ad
--- /dev/null
+++ b/src/nragel.h
@@ -0,0 +1,11 @@
+#ifndef _NRAGEL_H
+#define _NRAGEL_H
+
+#include <libfsm/common.h>
+#include <libfsm/ragel.h>
+
+HostType *findAlphType( const HostLang *hostLang, const char *s1 );
+HostType *findAlphType( const HostLang *hostLang, const char *s1, const char *s2 );
+HostType *findAlphTypeInternal( const HostLang *hostLang, const char *s1 );
+
+#endif
diff --git a/src/parsedata.cc b/src/parsedata.cc
index 9eb0b262..07474582 100644
--- a/src/parsedata.cc
+++ b/src/parsedata.cc
@@ -26,13 +26,14 @@
#include <stdlib.h>
#include <limits.h>
+#include <colm/tree.h>
#include <libfsm/ragel.h>
#include "parsedata.h"
#include "parsetree.h"
#include "mergesort.h"
#include "version.h"
#include "inputdata.h"
-#include <colm/tree.h>
+#include "nragel.h"
using namespace std;