+++ /dev/null
-#
-# Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
-#
-
-# This file is part of Ragel.
-#
-# Ragel is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Ragel is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ragel; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-SUBDIRS = common ragel rlcodegen test examples doc
-
-#*************************************
-
-# Programs
-CXX = @CXX@
-
-# Get the version info.
-include version.mk
-
-# Rules.
-all:
- @cd common && $(MAKE) && cd ../ragel && $(MAKE) && cd ../rlcodegen && $(MAKE)
-
-new-version:
- sed 's/^\(Version:[[:space:]]*\)[0-9.]*$$/\1$(VERSION)/' ragel.spec > spec-new
- cat spec-new > ragel.spec && rm spec-new
-
-distclean: distclean-rec distclean-local
-
-distclean-rec:
- for dir in $(SUBDIRS); do cd $$dir; $(MAKE) distclean; cd ..; done
-
-distclean-local: clean-local
- rm -f Makefile config.cache config.status config.log
-
-clean: clean-rec clean-local
-
-clean-rec:
- for dir in $(SUBDIRS); do cd $$dir; $(MAKE) clean; cd ..; done
-
-clean-local:
- rm -f tags
-
-install:
- @cd ragel && $(MAKE) install && cd ../rlcodegen && $(MAKE) install
+++ /dev/null
-#
-# Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
-#
-
-# This file is part of Ragel.
-#
-# Ragel is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Ragel is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ragel; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-INCS = -Iaapl
-DEFS =
-
-CFLAGS = -g -Wall
-LDFLAGS =
-
-SUBDIRS = codegen test examples doc
-
-CC_SRCS = \
- rlparse.cpp rlscan.cpp main.cpp parsetree.cpp \
- parsedata.cpp fsmstate.cpp fsmbase.cpp fsmattach.cpp \
- fsmmin.cpp fsmgraph.cpp fsmap.cpp xmlcodegen.cpp
-
-GEN_SRC = version.h
-
-LIBS = @LIBS@
-PREFIX = @prefix@
-
-#*************************************
-
-include ../version.mk
-
-# Programs
-CXX = @CXX@
-
-# What kind of header does bison put out?
-BISON_HEAD_SUFFIX = @BISON_HEAD_SUFFIX@
-
-# Get objects and dependencies from sources.
-RAGEL_OBJS = $(RAGEL_CC_SRCS:%.cpp=%.o)
-RLCG_OBJS = $(RLCG_CC_SRCS:%.cpp=%.o)
-DEPS = $(RAGEL_CC_SRCS:%.cpp=.%.d) $(RLCG_CC_SRCS:%.cpp=.%.d)
-
-# Rules.
-all: $(GEN_SRC)
-
-version.h: ../version.mk
- echo '#define VERSION "$(VERSION)"' > version.h
- echo '#define PUBDATE "$(PUBDATE)"' >> version.h
-
-%.o: %.cpp
- @$(CXX) -M $(DEFS) $(INCS) $< > .$*.d
- $(CXX) -c $(CFLAGS) $(DEFS) $(INCS) -o $@ $<
-
-distclean: clean
- rm -f Makefile config.h
-
-clean:
- rm -f tags .*.d *.o version.h
-
--include $(DEPS)
+++ /dev/null
-/*
- * Copyright 2003 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _BUFFER_H
-#define _BUFFER_H
-
-#define BUFFER_INITIAL_SIZE 4096
-
-/* An automatically grown buffer for collecting tokens. Always reuses space;
- * never down resizes. */
-struct Buffer
-{
- Buffer()
- {
- data = (char*) malloc( BUFFER_INITIAL_SIZE );
- allocated = BUFFER_INITIAL_SIZE;
- length = 0;
- }
- ~Buffer() { free(data); }
-
- void append( char p )
- {
- if ( length == allocated ) {
- allocated *= 2;
- data = (char*) realloc( data, allocated );
- }
- data[length++] = p;
- }
-
- void clear() { length = 0; }
-
- char *data;
- int allocated;
- int length;
-};
-
-#endif /* _BUFFER_H */
+++ /dev/null
-/*
- * Copyright 2006 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "common.h"
-
-HostType hostTypesC[] =
-{
- { "char", 0, true, CHAR_MIN, CHAR_MAX, sizeof(char) },
- { "unsigned", "char", false, 0, UCHAR_MAX, sizeof(unsigned char) },
- { "short", 0, true, SHRT_MIN, SHRT_MAX, sizeof(short) },
- { "unsigned", "short", false, 0, USHRT_MAX, sizeof(unsigned short) },
- { "int", 0, true, INT_MIN, INT_MAX, sizeof(int) },
- { "unsigned", "int", false, 0, UINT_MAX, sizeof(unsigned int) },
- { "long", 0, true, LONG_MIN, LONG_MAX, sizeof(long) },
- { "unsigned", "long", false, 0, ULONG_MAX, sizeof(unsigned long) }
-};
-
-HostType hostTypesD[] =
-{
- { "byte", 0, true, CHAR_MIN, CHAR_MAX, 1 },
- { "ubyte", 0, false, 0, UCHAR_MAX, 1 },
- { "char", 0, false, 0, UCHAR_MAX, 1 },
- { "short", 0, true, SHRT_MIN, SHRT_MAX, 2 },
- { "ushort", 0, false, 0, USHRT_MAX, 2 },
- { "wchar", 0, false, 0, USHRT_MAX, 2 },
- { "int", 0, true, INT_MIN, INT_MAX, 4 },
- { "uint", 0, false, 0, UINT_MAX, 4 },
- { "dchar", 0, false, 0, UINT_MAX, 4 }
-};
-
-HostType hostTypesJava[] =
-{
- { "byte", 0, true, CHAR_MIN, CHAR_MAX, 1 },
- { "short", 0, true, SHRT_MIN, SHRT_MAX, 2 },
- { "char", 0, false, 0, USHRT_MAX, 2 },
- { "int", 0, true, INT_MIN, INT_MAX, 4 },
-};
-
-HostLang hostLangC = { hostTypesC, 8, hostTypesC+0, true };
-HostLang hostLangD = { hostTypesD, 9, hostTypesD+2, true };
-HostLang hostLangJava = { hostTypesJava, 4, hostTypesJava+2, false };
-
-HostLang *hostLang = &hostLangC;
-HostLangType hostLangType = CCode;
-
-/* Construct a new parameter checker with for paramSpec. */
-ParamCheck::ParamCheck(char *paramSpec, int argc, char **argv)
-:
- state(noparam),
- argOffset(0),
- curArg(0),
- iCurArg(1),
- paramSpec(paramSpec),
- argc(argc),
- argv(argv)
-{
-}
-
-/* Check a single option. Returns the index of the next parameter. Sets p to
- * the arg character if valid, 0 otherwise. Sets parg to the parameter arg if
- * there is one, NULL otherwise. */
-bool ParamCheck::check()
-{
- bool requiresParam;
-
- if ( iCurArg >= argc ) { /* Off the end of the arg list. */
- state = noparam;
- return false;
- }
-
- if ( argOffset != 0 && *argOffset == 0 ) {
- /* We are at the end of an arg string. */
- iCurArg += 1;
- if ( iCurArg >= argc ) {
- state = noparam;
- return false;
- }
- argOffset = 0;
- }
-
- if ( argOffset == 0 ) {
- /* Set the current arg. */
- curArg = argv[iCurArg];
-
- /* We are at the beginning of an arg string. */
- if ( argv[iCurArg] == 0 || /* Argv[iCurArg] is null. */
- argv[iCurArg][0] != '-' || /* Not a param. */
- argv[iCurArg][1] == 0 ) { /* Only a dash. */
- parameter = 0;
- parameterArg = 0;
-
- iCurArg += 1;
- state = noparam;
- return true;
- }
- argOffset = argv[iCurArg] + 1;
- }
-
- /* Get the arg char. */
- char argChar = *argOffset;
-
- /* Loop over all the parms and look for a match. */
- char *pSpec = paramSpec;
- while ( *pSpec != 0 ) {
- char pSpecChar = *pSpec;
-
- /* If there is a ':' following the char then
- * it requires a parm. If a parm is required
- * then move ahead two in the parmspec. Otherwise
- * move ahead one in the parm spec. */
- if ( pSpec[1] == ':' ) {
- requiresParam = true;
- pSpec += 2;
- }
- else {
- requiresParam = false;
- pSpec += 1;
- }
-
- /* Do we have a match. */
- if ( argChar == pSpecChar ) {
- if ( requiresParam ) {
- if ( argOffset[1] == 0 ) {
- /* The param must follow. */
- if ( iCurArg + 1 == argc ) {
- /* We are the last arg so there
- * cannot be a parameter to it. */
- parameter = argChar;
- parameterArg = 0;
- iCurArg += 1;
- argOffset = 0;
- state = invalid;
- return true;
- }
- else {
- /* the parameter to the arg is the next arg. */
- parameter = pSpecChar;
- parameterArg = argv[iCurArg + 1];
- iCurArg += 2;
- argOffset = 0;
- state = match;
- return true;
- }
- }
- else {
- /* The param for the arg is built in. */
- parameter = pSpecChar;
- parameterArg = argOffset + 1;
- iCurArg += 1;
- argOffset = 0;
- state = match;
- return true;
- }
- }
- else {
- /* Good, we matched the parm and no
- * arg is required. */
- parameter = pSpecChar;
- parameterArg = 0;
- argOffset += 1;
- state = match;
- return true;
- }
- }
- }
-
- /* We did not find a match. Bad Argument. */
- parameter = argChar;
- parameterArg = 0;
- argOffset += 1;
- state = invalid;
- return true;
-}
-
-
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _COMMON_H
-#define _COMMON_H
-
-#include <climits>
-
-typedef unsigned long long Size;
-
-struct Key
-{
-private:
- long key;
-
-public:
- friend inline Key operator+(const Key key1, const Key key2);
- friend inline Key operator-(const Key key1, const Key key2);
- friend inline Key operator/(const Key key1, const Key key2);
- friend inline long operator&(const Key key1, const Key key2);
-
- friend inline bool operator<( const Key key1, const Key key2 );
- friend inline bool operator<=( const Key key1, const Key key2 );
- friend inline bool operator>( const Key key1, const Key key2 );
- friend inline bool operator>=( const Key key1, const Key key2 );
- friend inline bool operator==( const Key key1, const Key key2 );
- friend inline bool operator!=( const Key key1, const Key key2 );
-
- friend struct KeyOps;
-
- Key( ) {}
- Key( const Key &key ) : key(key.key) {}
- Key( long key ) : key(key) {}
-
- /* Returns the value used to represent the key. This value must be
- * interpreted based on signedness. */
- long getVal() const { return key; };
-
- /* Returns the key casted to a long long. This form of the key does not
- * require and signedness interpretation. */
- long long getLongLong() const;
-
- bool isUpper() const { return ( 'A' <= key && key <= 'Z' ); }
- bool isLower() const { return ( 'a' <= key && key <= 'z' ); }
- bool isPrintable() const { return ( 32 <= key && key < 127 ); }
-
- Key toUpper() const
- { return Key( 'A' + ( key - 'a' ) ); }
- Key toLower() const
- { return Key( 'a' + ( key - 'A' ) ); }
-
- void operator+=( const Key other )
- {
- /* FIXME: must be made aware of isSigned. */
- key += other.key;
- }
-
- void operator-=( const Key other )
- {
- /* FIXME: must be made aware of isSigned. */
- key -= other.key;
- }
-
- void operator|=( const Key other )
- {
- /* FIXME: must be made aware of isSigned. */
- key |= other.key;
- }
-
- /* Decrement. Needed only for ranges. */
- inline void decrement();
- inline void increment();
-};
-
-struct HostType
-{
- char *data1;
- char *data2;
- bool isSigned;
- long long minVal;
- long long maxVal;
- unsigned int size;
-};
-
-struct HostLang
-{
- HostType *hostTypes;
- int numHostTypes;
- HostType *defaultAlphType;
- bool explicitUnsigned;
-};
-
-
-/* Target language. */
-enum HostLangType
-{
- CCode,
- DCode,
- JavaCode
-};
-
-extern HostLang *hostLang;
-extern HostLangType hostLangType;
-
-extern HostLang hostLangC;
-extern HostLang hostLangD;
-extern HostLang hostLangJava;
-
-/* An abstraction of the key operators that manages key operations such as
- * comparison and increment according the signedness of the key. */
-struct KeyOps
-{
- /* Default to signed alphabet. */
- KeyOps() :
- isSigned(true),
- alphType(0)
- {}
-
- /* Default to signed alphabet. */
- KeyOps( bool isSigned )
- :isSigned(isSigned) {}
-
- bool isSigned;
- Key minKey, maxKey;
- HostType *alphType;
-
- void setAlphType( HostType *alphType )
- {
- this->alphType = alphType;
- isSigned = alphType->isSigned;
- if ( isSigned ) {
- minKey = (long) alphType->minVal;
- maxKey = (long) alphType->maxVal;
- }
- else {
- minKey = (long) (unsigned long) alphType->minVal;
- maxKey = (long) (unsigned long) alphType->maxVal;
- }
- }
-
- /* Compute the distance between two keys. */
- Size span( Key key1, Key key2 )
- {
- return isSigned ?
- (unsigned long long)(
- (long long)key2.key -
- (long long)key1.key + 1) :
- (unsigned long long)(
- (unsigned long)key2.key) -
- (unsigned long long)((unsigned long)key1.key) + 1;
- }
-
- Size alphSize()
- { return span( minKey, maxKey ); }
-
- HostType *typeSubsumes( long long maxVal )
- {
- for ( int i = 0; i < hostLang->numHostTypes; i++ ) {
- if ( maxVal <= hostLang->hostTypes[i].maxVal )
- return hostLang->hostTypes + i;
- }
- return 0;
- }
-
- HostType *typeSubsumes( bool isSigned, long long maxVal )
- {
- for ( int i = 0; i < hostLang->numHostTypes; i++ ) {
- if ( ( isSigned && hostLang->hostTypes[i].isSigned || !isSigned ) &&
- maxVal <= hostLang->hostTypes[i].maxVal )
- return hostLang->hostTypes + i;
- }
- return 0;
- }
-};
-
-extern KeyOps *keyOps;
-
-inline bool operator<( const Key key1, const Key key2 )
-{
- return keyOps->isSigned ? key1.key < key2.key :
- (unsigned long)key1.key < (unsigned long)key2.key;
-}
-
-inline bool operator<=( const Key key1, const Key key2 )
-{
- return keyOps->isSigned ? key1.key <= key2.key :
- (unsigned long)key1.key <= (unsigned long)key2.key;
-}
-
-inline bool operator>( const Key key1, const Key key2 )
-{
- return keyOps->isSigned ? key1.key > key2.key :
- (unsigned long)key1.key > (unsigned long)key2.key;
-}
-
-inline bool operator>=( const Key key1, const Key key2 )
-{
- return keyOps->isSigned ? key1.key >= key2.key :
- (unsigned long)key1.key >= (unsigned long)key2.key;
-}
-
-inline bool operator==( const Key key1, const Key key2 )
-{
- return key1.key == key2.key;
-}
-
-inline bool operator!=( const Key key1, const Key key2 )
-{
- return key1.key != key2.key;
-}
-
-/* Decrement. Needed only for ranges. */
-inline void Key::decrement()
-{
- key = keyOps->isSigned ? key - 1 : ((unsigned long)key)-1;
-}
-
-/* Increment. Needed only for ranges. */
-inline void Key::increment()
-{
- key = keyOps->isSigned ? key+1 : ((unsigned long)key)+1;
-}
-
-inline long long Key::getLongLong() const
-{
- return keyOps->isSigned ? (long long)key : (long long)(unsigned long)key;
-}
-
-inline Key operator+(const Key key1, const Key key2)
-{
- /* FIXME: must be made aware of isSigned. */
- return Key( key1.key + key2.key );
-}
-
-inline Key operator-(const Key key1, const Key key2)
-{
- /* FIXME: must be made aware of isSigned. */
- return Key( key1.key - key2.key );
-}
-
-inline long operator&(const Key key1, const Key key2)
-{
- /* FIXME: must be made aware of isSigned. */
- return key1.key & key2.key;
-}
-
-inline Key operator/(const Key key1, const Key key2)
-{
- /* FIXME: must be made aware of isSigned. */
- return key1.key / key2.key;
-}
-
-#endif /* _COMMON_H */
+++ /dev/null
-/*
- * Copyright 2001 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _CONFIG_H
-#define _CONFIG_H
-
-/* Compilers. */
-#undef GDC
-#undef GOBJC
-#undef CXX
-#undef CC
-#undef JAVAC
-#undef TXL
-
-#endif /* _CONFIG_H */
+++ /dev/null
-/*
- * Copyright 2001, 2002 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _PCHECK_H
-#define _PCHECK_H
-
-class ParamCheck
-{
-public:
- ParamCheck(char *paramSpec, int argc, char **argv);
-
- bool check();
-
- char *parameterArg; /* The argument to the parameter. */
- char parameter; /* The parameter matched. */
- enum { match, invalid, noparam } state;
-
- char *argOffset; /* If we are reading params inside an
- * arg this points to the offset. */
-
- char *curArg; /* Pointer to the current arg. */
- int iCurArg; /* Index to the current arg. */
-
-private:
- char *paramSpec; /* Parameter spec supplied by the coder. */
- int argc; /* Arguement data from the command line. */
- char **argv;
-
-};
-
-#endif /* _PCHECK_H */
+++ /dev/null
-#! /bin/sh
-# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.59.
-#
-# Copyright (C) 2003 Free Software Foundation, Inc.
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-## --------------------- ##
-## M4sh Initialization. ##
-## --------------------- ##
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
- set -o posix
-fi
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
- as_unset=unset
-else
- as_unset=false
-fi
-
-
-# Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-for as_var in \
- LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
- LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
- LC_TELEPHONE LC_TIME
-do
- if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
- eval $as_var=C; export $as_var
- else
- $as_unset $as_var
- fi
-done
-
-# Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-
-
-# Name of the executable.
-as_me=`$as_basename "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)$' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X/"$0" |
- sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
- /^X\/\(\/\/\)$/{ s//\1/; q; }
- /^X\/\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
-
-
-# PATH needs CR, and LINENO needs CR and PATH.
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- echo "#! /bin/sh" >conf$$.sh
- echo "exit 0" >>conf$$.sh
- chmod +x conf$$.sh
- if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
- PATH_SEPARATOR=';'
- else
- PATH_SEPARATOR=:
- fi
- rm -f conf$$.sh
-fi
-
-
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" || {
- # Find who we are. Look in the path if we contain no path at all
- # relative or not.
- case $0 in
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
-
- ;;
- esac
- # We did not find ourselves, most probably we were run as `sh COMMAND'
- # in which case we are not to be found in the path.
- if test "x$as_myself" = x; then
- as_myself=$0
- fi
- if test ! -f "$as_myself"; then
- { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
- { (exit 1); exit 1; }; }
- fi
- case $CONFIG_SHELL in
- '')
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for as_base in sh bash ksh sh5; do
- case $as_dir in
- /*)
- if ("$as_dir/$as_base" -c '
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
- $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
- $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
- CONFIG_SHELL=$as_dir/$as_base
- export CONFIG_SHELL
- exec "$CONFIG_SHELL" "$0" ${1+"$@"}
- fi;;
- esac
- done
-done
-;;
- esac
-
- # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
- # uniformly replaced by the line number. The first 'sed' inserts a
- # line-number line before each line; the second 'sed' does the real
- # work. The second script uses 'N' to pair each line-number line
- # with the numbered line, and appends trailing '-' during
- # substitution so that $LINENO is not a special case at line end.
- # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
- # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
- sed '=' <$as_myself |
- sed '
- N
- s,$,-,
- : loop
- s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
- t loop
- s,-$,,
- s,^['$as_cr_digits']*\n,,
- ' >$as_me.lineno &&
- chmod +x $as_me.lineno ||
- { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
- { (exit 1); exit 1; }; }
-
- # Don't try to exec as it changes $[0], causing all sort of problems
- # (the dirname of $[0] is not the place where we might find the
- # original and so on. Autoconf is especially sensible to this).
- . ./$as_me.lineno
- # Exit status is that of the last command.
- exit
-}
-
-
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
- *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T=' ' ;;
- *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
- *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
-esac
-
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-rm -f conf$$ conf$$.exe conf$$.file
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
- # We could just check for DJGPP; but this test a) works b) is more generic
- # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
- if test -f conf$$.exe; then
- # Don't use ln at all; we don't have any links
- as_ln_s='cp -p'
- else
- as_ln_s='ln -s'
- fi
-elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
-else
- as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.file
-
-if mkdir -p . 2>/dev/null; then
- as_mkdir_p=:
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-
-as_executable_p="test -f"
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" $as_nl"
-
-# CDPATH.
-$as_unset CDPATH
-
-
-# Name of the host.
-# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
-# so uname gets run too.
-ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
-
-exec 6>&1
-
-#
-# Initializations.
-#
-ac_default_prefix=/usr/local
-ac_config_libobj_dir=.
-cross_compiling=no
-subdirs=
-MFLAGS=
-MAKEFLAGS=
-SHELL=${CONFIG_SHELL-/bin/sh}
-
-# Maximum number of lines to put in a shell here document.
-# This variable seems obsolete. It should probably be removed, and
-# only ac_max_sed_lines should be used.
-: ${ac_max_here_lines=38}
-
-# Identity of this package.
-PACKAGE_NAME=
-PACKAGE_TARNAME=
-PACKAGE_VERSION=
-PACKAGE_STRING=
-PACKAGE_BUGREPORT=
-
-ac_unique_file="ragel/main.cpp"
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS BUILD_PARSERS CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX SET_MAKE FLEX GPERF BISON GDC GOBJC JAVAC TXL LIBOBJS LTLIBOBJS'
-ac_subst_files=''
-
-# Initialize some variables set by options.
-ac_init_help=
-ac_init_version=false
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-cache_file=/dev/null
-exec_prefix=NONE
-no_create=
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-verbose=
-x_includes=NONE
-x_libraries=NONE
-
-# Installation directory options.
-# These are left unexpanded so users can "make install exec_prefix=/foo"
-# and all the variables that are supposed to be based on exec_prefix
-# by default will actually change.
-# Use braces instead of parens because sh, perl, etc. also accept them.
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datadir='${prefix}/share'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-libdir='${exec_prefix}/lib'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-infodir='${prefix}/info'
-mandir='${prefix}/man'
-
-ac_prev=
-for ac_option
-do
- # If the previous option needs an argument, assign it.
- if test -n "$ac_prev"; then
- eval "$ac_prev=\$ac_option"
- ac_prev=
- continue
- fi
-
- ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
-
- # Accept the important Cygnus configure options, so we can diagnose typos.
-
- case $ac_option in
-
- -bindir | --bindir | --bindi | --bind | --bin | --bi)
- ac_prev=bindir ;;
- -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
- bindir=$ac_optarg ;;
-
- -build | --build | --buil | --bui | --bu)
- ac_prev=build_alias ;;
- -build=* | --build=* | --buil=* | --bui=* | --bu=*)
- build_alias=$ac_optarg ;;
-
- -cache-file | --cache-file | --cache-fil | --cache-fi \
- | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
- ac_prev=cache_file ;;
- -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
- | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
- cache_file=$ac_optarg ;;
-
- --config-cache | -C)
- cache_file=config.cache ;;
-
- -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
- ac_prev=datadir ;;
- -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
- | --da=*)
- datadir=$ac_optarg ;;
-
- -disable-* | --disable-*)
- ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid feature name: $ac_feature" >&2
- { (exit 1); exit 1; }; }
- ac_feature=`echo $ac_feature | sed 's/-/_/g'`
- eval "enable_$ac_feature=no" ;;
-
- -enable-* | --enable-*)
- ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid feature name: $ac_feature" >&2
- { (exit 1); exit 1; }; }
- ac_feature=`echo $ac_feature | sed 's/-/_/g'`
- case $ac_option in
- *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
- *) ac_optarg=yes ;;
- esac
- eval "enable_$ac_feature='$ac_optarg'" ;;
-
- -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
- | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
- | --exec | --exe | --ex)
- ac_prev=exec_prefix ;;
- -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
- | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
- | --exec=* | --exe=* | --ex=*)
- exec_prefix=$ac_optarg ;;
-
- -gas | --gas | --ga | --g)
- # Obsolete; use --with-gas.
- with_gas=yes ;;
-
- -help | --help | --hel | --he | -h)
- ac_init_help=long ;;
- -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
- ac_init_help=recursive ;;
- -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
- ac_init_help=short ;;
-
- -host | --host | --hos | --ho)
- ac_prev=host_alias ;;
- -host=* | --host=* | --hos=* | --ho=*)
- host_alias=$ac_optarg ;;
-
- -includedir | --includedir | --includedi | --included | --include \
- | --includ | --inclu | --incl | --inc)
- ac_prev=includedir ;;
- -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
- | --includ=* | --inclu=* | --incl=* | --inc=*)
- includedir=$ac_optarg ;;
-
- -infodir | --infodir | --infodi | --infod | --info | --inf)
- ac_prev=infodir ;;
- -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
- infodir=$ac_optarg ;;
-
- -libdir | --libdir | --libdi | --libd)
- ac_prev=libdir ;;
- -libdir=* | --libdir=* | --libdi=* | --libd=*)
- libdir=$ac_optarg ;;
-
- -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
- | --libexe | --libex | --libe)
- ac_prev=libexecdir ;;
- -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
- | --libexe=* | --libex=* | --libe=*)
- libexecdir=$ac_optarg ;;
-
- -localstatedir | --localstatedir | --localstatedi | --localstated \
- | --localstate | --localstat | --localsta | --localst \
- | --locals | --local | --loca | --loc | --lo)
- ac_prev=localstatedir ;;
- -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
- | --localstate=* | --localstat=* | --localsta=* | --localst=* \
- | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
- localstatedir=$ac_optarg ;;
-
- -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
- ac_prev=mandir ;;
- -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
- mandir=$ac_optarg ;;
-
- -nfp | --nfp | --nf)
- # Obsolete; use --without-fp.
- with_fp=no ;;
-
- -no-create | --no-create | --no-creat | --no-crea | --no-cre \
- | --no-cr | --no-c | -n)
- no_create=yes ;;
-
- -no-recursion | --no-recursion | --no-recursio | --no-recursi \
- | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
- no_recursion=yes ;;
-
- -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
- | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
- | --oldin | --oldi | --old | --ol | --o)
- ac_prev=oldincludedir ;;
- -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
- | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
- | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
- oldincludedir=$ac_optarg ;;
-
- -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
- ac_prev=prefix ;;
- -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
- prefix=$ac_optarg ;;
-
- -program-prefix | --program-prefix | --program-prefi | --program-pref \
- | --program-pre | --program-pr | --program-p)
- ac_prev=program_prefix ;;
- -program-prefix=* | --program-prefix=* | --program-prefi=* \
- | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
- program_prefix=$ac_optarg ;;
-
- -program-suffix | --program-suffix | --program-suffi | --program-suff \
- | --program-suf | --program-su | --program-s)
- ac_prev=program_suffix ;;
- -program-suffix=* | --program-suffix=* | --program-suffi=* \
- | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
- program_suffix=$ac_optarg ;;
-
- -program-transform-name | --program-transform-name \
- | --program-transform-nam | --program-transform-na \
- | --program-transform-n | --program-transform- \
- | --program-transform | --program-transfor \
- | --program-transfo | --program-transf \
- | --program-trans | --program-tran \
- | --progr-tra | --program-tr | --program-t)
- ac_prev=program_transform_name ;;
- -program-transform-name=* | --program-transform-name=* \
- | --program-transform-nam=* | --program-transform-na=* \
- | --program-transform-n=* | --program-transform-=* \
- | --program-transform=* | --program-transfor=* \
- | --program-transfo=* | --program-transf=* \
- | --program-trans=* | --program-tran=* \
- | --progr-tra=* | --program-tr=* | --program-t=*)
- program_transform_name=$ac_optarg ;;
-
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- silent=yes ;;
-
- -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
- ac_prev=sbindir ;;
- -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
- | --sbi=* | --sb=*)
- sbindir=$ac_optarg ;;
-
- -sharedstatedir | --sharedstatedir | --sharedstatedi \
- | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
- | --sharedst | --shareds | --shared | --share | --shar \
- | --sha | --sh)
- ac_prev=sharedstatedir ;;
- -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
- | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
- | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
- | --sha=* | --sh=*)
- sharedstatedir=$ac_optarg ;;
-
- -site | --site | --sit)
- ac_prev=site ;;
- -site=* | --site=* | --sit=*)
- site=$ac_optarg ;;
-
- -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
- ac_prev=srcdir ;;
- -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
- srcdir=$ac_optarg ;;
-
- -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
- | --syscon | --sysco | --sysc | --sys | --sy)
- ac_prev=sysconfdir ;;
- -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
- | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
- sysconfdir=$ac_optarg ;;
-
- -target | --target | --targe | --targ | --tar | --ta | --t)
- ac_prev=target_alias ;;
- -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
- target_alias=$ac_optarg ;;
-
- -v | -verbose | --verbose | --verbos | --verbo | --verb)
- verbose=yes ;;
-
- -version | --version | --versio | --versi | --vers | -V)
- ac_init_version=: ;;
-
- -with-* | --with-*)
- ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid package name: $ac_package" >&2
- { (exit 1); exit 1; }; }
- ac_package=`echo $ac_package| sed 's/-/_/g'`
- case $ac_option in
- *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
- *) ac_optarg=yes ;;
- esac
- eval "with_$ac_package='$ac_optarg'" ;;
-
- -without-* | --without-*)
- ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
- # Reject names that are not valid shell variable names.
- expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid package name: $ac_package" >&2
- { (exit 1); exit 1; }; }
- ac_package=`echo $ac_package | sed 's/-/_/g'`
- eval "with_$ac_package=no" ;;
-
- --x)
- # Obsolete; use --with-x.
- with_x=yes ;;
-
- -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
- | --x-incl | --x-inc | --x-in | --x-i)
- ac_prev=x_includes ;;
- -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
- | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
- x_includes=$ac_optarg ;;
-
- -x-libraries | --x-libraries | --x-librarie | --x-librari \
- | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
- ac_prev=x_libraries ;;
- -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
- | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
- x_libraries=$ac_optarg ;;
-
- -*) { echo "$as_me: error: unrecognized option: $ac_option
-Try \`$0 --help' for more information." >&2
- { (exit 1); exit 1; }; }
- ;;
-
- *=*)
- ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
- # Reject names that are not valid shell variable names.
- expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
- { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
- { (exit 1); exit 1; }; }
- ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
- eval "$ac_envvar='$ac_optarg'"
- export $ac_envvar ;;
-
- *)
- # FIXME: should be removed in autoconf 3.0.
- echo "$as_me: WARNING: you should use --build, --host, --target" >&2
- expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
- echo "$as_me: WARNING: invalid host type: $ac_option" >&2
- : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
- ;;
-
- esac
-done
-
-if test -n "$ac_prev"; then
- ac_option=--`echo $ac_prev | sed 's/_/-/g'`
- { echo "$as_me: error: missing argument to $ac_option" >&2
- { (exit 1); exit 1; }; }
-fi
-
-# Be sure to have absolute paths.
-for ac_var in exec_prefix prefix
-do
- eval ac_val=$`echo $ac_var`
- case $ac_val in
- [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
- *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
- { (exit 1); exit 1; }; };;
- esac
-done
-
-# Be sure to have absolute paths.
-for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
- localstatedir libdir includedir oldincludedir infodir mandir
-do
- eval ac_val=$`echo $ac_var`
- case $ac_val in
- [\\/$]* | ?:[\\/]* ) ;;
- *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
- { (exit 1); exit 1; }; };;
- esac
-done
-
-# There might be people who depend on the old broken behavior: `$host'
-# used to hold the argument of --host etc.
-# FIXME: To remove some day.
-build=$build_alias
-host=$host_alias
-target=$target_alias
-
-# FIXME: To remove some day.
-if test "x$host_alias" != x; then
- if test "x$build_alias" = x; then
- cross_compiling=maybe
- echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
- If a cross compiler is detected then cross compile mode will be used." >&2
- elif test "x$build_alias" != "x$host_alias"; then
- cross_compiling=yes
- fi
-fi
-
-ac_tool_prefix=
-test -n "$host_alias" && ac_tool_prefix=$host_alias-
-
-test "$silent" = yes && exec 6>/dev/null
-
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
- ac_srcdir_defaulted=yes
- # Try the directory containing this script, then its parent.
- ac_confdir=`(dirname "$0") 2>/dev/null ||
-$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$0" : 'X\(//\)[^/]' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$0" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- srcdir=$ac_confdir
- if test ! -r $srcdir/$ac_unique_file; then
- srcdir=..
- fi
-else
- ac_srcdir_defaulted=no
-fi
-if test ! -r $srcdir/$ac_unique_file; then
- if test "$ac_srcdir_defaulted" = yes; then
- { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
- { (exit 1); exit 1; }; }
- else
- { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
- { (exit 1); exit 1; }; }
- fi
-fi
-(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
- { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
- { (exit 1); exit 1; }; }
-srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
-ac_env_build_alias_set=${build_alias+set}
-ac_env_build_alias_value=$build_alias
-ac_cv_env_build_alias_set=${build_alias+set}
-ac_cv_env_build_alias_value=$build_alias
-ac_env_host_alias_set=${host_alias+set}
-ac_env_host_alias_value=$host_alias
-ac_cv_env_host_alias_set=${host_alias+set}
-ac_cv_env_host_alias_value=$host_alias
-ac_env_target_alias_set=${target_alias+set}
-ac_env_target_alias_value=$target_alias
-ac_cv_env_target_alias_set=${target_alias+set}
-ac_cv_env_target_alias_value=$target_alias
-ac_env_CC_set=${CC+set}
-ac_env_CC_value=$CC
-ac_cv_env_CC_set=${CC+set}
-ac_cv_env_CC_value=$CC
-ac_env_CFLAGS_set=${CFLAGS+set}
-ac_env_CFLAGS_value=$CFLAGS
-ac_cv_env_CFLAGS_set=${CFLAGS+set}
-ac_cv_env_CFLAGS_value=$CFLAGS
-ac_env_LDFLAGS_set=${LDFLAGS+set}
-ac_env_LDFLAGS_value=$LDFLAGS
-ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
-ac_cv_env_LDFLAGS_value=$LDFLAGS
-ac_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_env_CPPFLAGS_value=$CPPFLAGS
-ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
-ac_cv_env_CPPFLAGS_value=$CPPFLAGS
-ac_env_CXX_set=${CXX+set}
-ac_env_CXX_value=$CXX
-ac_cv_env_CXX_set=${CXX+set}
-ac_cv_env_CXX_value=$CXX
-ac_env_CXXFLAGS_set=${CXXFLAGS+set}
-ac_env_CXXFLAGS_value=$CXXFLAGS
-ac_cv_env_CXXFLAGS_set=${CXXFLAGS+set}
-ac_cv_env_CXXFLAGS_value=$CXXFLAGS
-
-#
-# Report the --help message.
-#
-if test "$ac_init_help" = "long"; then
- # Omit some internal or obsolete options to make the list less imposing.
- # This message is too long to be a string in the A/UX 3.1 sh.
- cat <<_ACEOF
-\`configure' configures this package to adapt to many kinds of systems.
-
-Usage: $0 [OPTION]... [VAR=VALUE]...
-
-To assign environment variables (e.g., CC, CFLAGS...), specify them as
-VAR=VALUE. See below for descriptions of some of the useful variables.
-
-Defaults for the options are specified in brackets.
-
-Configuration:
- -h, --help display this help and exit
- --help=short display options specific to this package
- --help=recursive display the short help of all the included packages
- -V, --version display version information and exit
- -q, --quiet, --silent do not print \`checking...' messages
- --cache-file=FILE cache test results in FILE [disabled]
- -C, --config-cache alias for \`--cache-file=config.cache'
- -n, --no-create do not create output files
- --srcdir=DIR find the sources in DIR [configure dir or \`..']
-
-_ACEOF
-
- cat <<_ACEOF
-Installation directories:
- --prefix=PREFIX install architecture-independent files in PREFIX
- [$ac_default_prefix]
- --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
- [PREFIX]
-
-By default, \`make install' will install all the files in
-\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
-an installation prefix other than \`$ac_default_prefix' using \`--prefix',
-for instance \`--prefix=\$HOME'.
-
-For better control, use the options below.
-
-Fine tuning of the installation directories:
- --bindir=DIR user executables [EPREFIX/bin]
- --sbindir=DIR system admin executables [EPREFIX/sbin]
- --libexecdir=DIR program executables [EPREFIX/libexec]
- --datadir=DIR read-only architecture-independent data [PREFIX/share]
- --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
- --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
- --localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --libdir=DIR object code libraries [EPREFIX/lib]
- --includedir=DIR C header files [PREFIX/include]
- --oldincludedir=DIR C header files for non-gcc [/usr/include]
- --infodir=DIR info documentation [PREFIX/info]
- --mandir=DIR man documentation [PREFIX/man]
-_ACEOF
-
- cat <<\_ACEOF
-_ACEOF
-fi
-
-if test -n "$ac_init_help"; then
-
- cat <<\_ACEOF
-
-Some influential environment variables:
- CC C compiler command
- CFLAGS C compiler flags
- LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
- nonstandard directory <lib dir>
- CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
- headers in a nonstandard directory <include dir>
- CXX C++ compiler command
- CXXFLAGS C++ compiler flags
-
-Use these variables to override the choices made by `configure' or to help
-it to find libraries and programs with nonstandard names/locations.
-
-_ACEOF
-fi
-
-if test "$ac_init_help" = "recursive"; then
- # If there are subdirs, report their specific --help.
- ac_popdir=`pwd`
- for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
- test -d $ac_dir || continue
- ac_builddir=.
-
-if test "$ac_dir" != .; then
- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
- # A "../" for each directory in $ac_dir_suffix.
- ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
- ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
- .) # No --srcdir option. We are building in place.
- ac_srcdir=.
- if test -z "$ac_top_builddir"; then
- ac_top_srcdir=.
- else
- ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
- fi ;;
- [\\/]* | ?:[\\/]* ) # Absolute path.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir ;;
- *) # Relative path.
- ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
- case "$ac_dir" in
- .) ac_abs_builddir=`pwd`;;
- [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
- *) ac_abs_builddir=`pwd`/"$ac_dir";;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
- case ${ac_top_builddir}. in
- .) ac_abs_top_builddir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
- *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
- case $ac_srcdir in
- .) ac_abs_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
- *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
- case $ac_top_srcdir in
- .) ac_abs_top_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
- *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
- esac;;
-esac
-
- cd $ac_dir
- # Check for guested configure; otherwise get Cygnus style configure.
- if test -f $ac_srcdir/configure.gnu; then
- echo
- $SHELL $ac_srcdir/configure.gnu --help=recursive
- elif test -f $ac_srcdir/configure; then
- echo
- $SHELL $ac_srcdir/configure --help=recursive
- elif test -f $ac_srcdir/configure.ac ||
- test -f $ac_srcdir/configure.in; then
- echo
- $ac_configure --help
- else
- echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
- fi
- cd "$ac_popdir"
- done
-fi
-
-test -n "$ac_init_help" && exit 0
-if $ac_init_version; then
- cat <<\_ACEOF
-
-Copyright (C) 2003 Free Software Foundation, Inc.
-This configure script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it.
-_ACEOF
- exit 0
-fi
-exec 5>config.log
-cat >&5 <<_ACEOF
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-
-It was created by $as_me, which was
-generated by GNU Autoconf 2.59. Invocation command line was
-
- $ $0 $@
-
-_ACEOF
-{
-cat <<_ASUNAME
-## --------- ##
-## Platform. ##
-## --------- ##
-
-hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
-/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
-
-/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
-/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
-hostinfo = `(hostinfo) 2>/dev/null || echo unknown`
-/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
-/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
-/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
-
-_ASUNAME
-
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- echo "PATH: $as_dir"
-done
-
-} >&5
-
-cat >&5 <<_ACEOF
-
-
-## ----------- ##
-## Core tests. ##
-## ----------- ##
-
-_ACEOF
-
-
-# Keep a trace of the command line.
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Strip out --silent because we don't want to record it for future runs.
-# Also quote any args containing shell meta-characters.
-# Make two passes to allow for proper duplicate-argument suppression.
-ac_configure_args=
-ac_configure_args0=
-ac_configure_args1=
-ac_sep=
-ac_must_keep_next=false
-for ac_pass in 1 2
-do
- for ac_arg
- do
- case $ac_arg in
- -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil)
- continue ;;
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
- ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
- esac
- case $ac_pass in
- 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
- 2)
- ac_configure_args1="$ac_configure_args1 '$ac_arg'"
- if test $ac_must_keep_next = true; then
- ac_must_keep_next=false # Got value, back to normal.
- else
- case $ac_arg in
- *=* | --config-cache | -C | -disable-* | --disable-* \
- | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
- | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
- | -with-* | --with-* | -without-* | --without-* | --x)
- case "$ac_configure_args0 " in
- "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
- esac
- ;;
- -* ) ac_must_keep_next=true ;;
- esac
- fi
- ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
- # Get rid of the leading space.
- ac_sep=" "
- ;;
- esac
- done
-done
-$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
-$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
-
-# When interrupted or exit'd, cleanup temporary files, and complete
-# config.log. We remove comments because anyway the quotes in there
-# would cause problems or look ugly.
-# WARNING: Be sure not to use single quotes in there, as some shells,
-# such as our DU 5.0 friend, will then `close' the trap.
-trap 'exit_status=$?
- # Save into config.log some information that might help in debugging.
- {
- echo
-
- cat <<\_ASBOX
-## ---------------- ##
-## Cache variables. ##
-## ---------------- ##
-_ASBOX
- echo
- # The following way of writing the cache mishandles newlines in values,
-{
- (set) 2>&1 |
- case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
- *ac_space=\ *)
- sed -n \
- "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
- ;;
- *)
- sed -n \
- "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
- ;;
- esac;
-}
- echo
-
- cat <<\_ASBOX
-## ----------------- ##
-## Output variables. ##
-## ----------------- ##
-_ASBOX
- echo
- for ac_var in $ac_subst_vars
- do
- eval ac_val=$`echo $ac_var`
- echo "$ac_var='"'"'$ac_val'"'"'"
- done | sort
- echo
-
- if test -n "$ac_subst_files"; then
- cat <<\_ASBOX
-## ------------- ##
-## Output files. ##
-## ------------- ##
-_ASBOX
- echo
- for ac_var in $ac_subst_files
- do
- eval ac_val=$`echo $ac_var`
- echo "$ac_var='"'"'$ac_val'"'"'"
- done | sort
- echo
- fi
-
- if test -s confdefs.h; then
- cat <<\_ASBOX
-## ----------- ##
-## confdefs.h. ##
-## ----------- ##
-_ASBOX
- echo
- sed "/^$/d" confdefs.h | sort
- echo
- fi
- test "$ac_signal" != 0 &&
- echo "$as_me: caught signal $ac_signal"
- echo "$as_me: exit $exit_status"
- } >&5
- rm -f core *.core &&
- rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
- exit $exit_status
- ' 0
-for ac_signal in 1 2 13 15; do
- trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
-done
-ac_signal=0
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -rf conftest* confdefs.h
-# AIX cpp loses on an empty file, so make sure it contains at least a newline.
-echo >confdefs.h
-
-# Predefined preprocessor variables.
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_NAME "$PACKAGE_NAME"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_VERSION "$PACKAGE_VERSION"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_STRING "$PACKAGE_STRING"
-_ACEOF
-
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
-_ACEOF
-
-
-# Let the site file select an alternate cache file if it wants to.
-# Prefer explicitly selected file to automatically selected ones.
-if test -z "$CONFIG_SITE"; then
- if test "x$prefix" != xNONE; then
- CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
- else
- CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
- fi
-fi
-for ac_site_file in $CONFIG_SITE; do
- if test -r "$ac_site_file"; then
- { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
-echo "$as_me: loading site script $ac_site_file" >&6;}
- sed 's/^/| /' "$ac_site_file" >&5
- . "$ac_site_file"
- fi
-done
-
-if test -r "$cache_file"; then
- # Some versions of bash will fail to source /dev/null (special
- # files actually), so we avoid doing that.
- if test -f "$cache_file"; then
- { echo "$as_me:$LINENO: loading cache $cache_file" >&5
-echo "$as_me: loading cache $cache_file" >&6;}
- case $cache_file in
- [\\/]* | ?:[\\/]* ) . $cache_file;;
- *) . ./$cache_file;;
- esac
- fi
-else
- { echo "$as_me:$LINENO: creating cache $cache_file" >&5
-echo "$as_me: creating cache $cache_file" >&6;}
- >$cache_file
-fi
-
-# Check that the precious variables saved in the cache have kept the same
-# value.
-ac_cache_corrupted=false
-for ac_var in `(set) 2>&1 |
- sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
- eval ac_old_set=\$ac_cv_env_${ac_var}_set
- eval ac_new_set=\$ac_env_${ac_var}_set
- eval ac_old_val="\$ac_cv_env_${ac_var}_value"
- eval ac_new_val="\$ac_env_${ac_var}_value"
- case $ac_old_set,$ac_new_set in
- set,)
- { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,set)
- { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
-echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
- ac_cache_corrupted=: ;;
- ,);;
- *)
- if test "x$ac_old_val" != "x$ac_new_val"; then
- { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
-echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
- { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
-echo "$as_me: former value: $ac_old_val" >&2;}
- { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
-echo "$as_me: current value: $ac_new_val" >&2;}
- ac_cache_corrupted=:
- fi;;
- esac
- # Pass precious variables to config.status.
- if test "$ac_new_set" = set; then
- case $ac_new_val in
- *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
- ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
- *) ac_arg=$ac_var=$ac_new_val ;;
- esac
- case " $ac_configure_args " in
- *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
- *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
- esac
- fi
-done
-if $ac_cache_corrupted; then
- { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
-echo "$as_me: error: changes in the environment can compromise the build" >&2;}
- { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
-echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ac_config_headers="$ac_config_headers common/config.h"
-
-
-BUILD_PARSERS=true
-
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}gcc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="gcc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- CC=$ac_ct_CC
-else
- CC="$ac_cv_prog_CC"
-fi
-
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="${ac_tool_prefix}cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$ac_cv_prog_CC"; then
- ac_ct_CC=$CC
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- CC=$ac_ct_CC
-else
- CC="$ac_cv_prog_CC"
-fi
-
-fi
-if test -z "$CC"; then
- # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
- ac_prog_rejected=no
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
- ac_prog_rejected=yes
- continue
- fi
- ac_cv_prog_CC="cc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-if test $ac_prog_rejected = yes; then
- # We found a bogon in the path, so make sure we never use it.
- set dummy $ac_cv_prog_CC
- shift
- if test $# != 0; then
- # We chose a different compiler from the bogus one.
- # However, it has the same basename, so the bogon will be chosen
- # first if we set CC to just the basename; use the full file name.
- shift
- ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
- fi
-fi
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-fi
-if test -z "$CC"; then
- if test -n "$ac_tool_prefix"; then
- for ac_prog in cl
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CC"; then
- ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
- echo "$as_me:$LINENO: result: $CC" >&5
-echo "${ECHO_T}$CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$CC" && break
- done
-fi
-if test -z "$CC"; then
- ac_ct_CC=$CC
- for ac_prog in cl
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CC"; then
- ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CC="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
- echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
-echo "${ECHO_T}$ac_ct_CC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$ac_ct_CC" && break
-done
-
- CC=$ac_ct_CC
-fi
-
-fi
-
-
-test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&5
-echo "$as_me: error: no acceptable C compiler found in \$PATH
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-
-# Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
- "checking for C compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
- (eval $ac_compiler --version </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
- (eval $ac_compiler -v </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
- (eval $ac_compiler -V </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.exe b.out"
-# Try to create an executable without -o first, disregard a.out.
-# It will help us diagnose broken compilers, and finding out an intuition
-# of exeext.
-echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
-echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6
-ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
- (eval $ac_link_default) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # Find the output, starting from the most likely. This scheme is
-# not robust to junk in `.', hence go to wildcards (a.*) only as a last
-# resort.
-
-# Be careful to initialize this variable, since it used to be cached.
-# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
-ac_cv_exeext=
-# b.out is created by i960 compilers.
-for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
-do
- test -f "$ac_file" || continue
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
- ;;
- conftest.$ac_ext )
- # This is the source file.
- ;;
- [ab].out )
- # We found the default executable, but exeext='' is most
- # certainly right.
- break;;
- *.* )
- ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- # FIXME: I believe we export ac_cv_exeext for Libtool,
- # but it would be cool to find out if it's true. Does anybody
- # maintain Libtool? --akim.
- export ac_cv_exeext
- break;;
- * )
- break;;
- esac
-done
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
-See \`config.log' for more details." >&5
-echo "$as_me: error: C compiler cannot create executables
-See \`config.log' for more details." >&2;}
- { (exit 77); exit 77; }; }
-fi
-
-ac_exeext=$ac_cv_exeext
-echo "$as_me:$LINENO: result: $ac_file" >&5
-echo "${ECHO_T}$ac_file" >&6
-
-# Check the compiler produces executables we can run. If not, either
-# the compiler is broken, or we cross compile.
-echo "$as_me:$LINENO: checking whether the C compiler works" >&5
-echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
-# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
-# If not cross compiling, check that we can run a simple program.
-if test "$cross_compiling" != yes; then
- if { ac_try='./$ac_file'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- cross_compiling=no
- else
- if test "$cross_compiling" = maybe; then
- cross_compiling=yes
- else
- { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
- fi
- fi
-fi
-echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
-
-rm -f a.out a.exe conftest$ac_cv_exeext b.out
-ac_clean_files=$ac_clean_files_save
-# Check the compiler produces executables we can run. If not, either
-# the compiler is broken, or we cross compile.
-echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
-echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
-echo "$as_me:$LINENO: result: $cross_compiling" >&5
-echo "${ECHO_T}$cross_compiling" >&6
-
-echo "$as_me:$LINENO: checking for suffix of executables" >&5
-echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
-if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- # If both `conftest.exe' and `conftest' are `present' (well, observable)
-# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
-# work properly (i.e., refer to `conftest.exe'), while it won't with
-# `rm'.
-for ac_file in conftest.exe conftest conftest.*; do
- test -f "$ac_file" || continue
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
- *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
- export ac_cv_exeext
- break;;
- * ) break;;
- esac
-done
-else
- { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-rm -f conftest$ac_cv_exeext
-echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
-echo "${ECHO_T}$ac_cv_exeext" >&6
-
-rm -f conftest.$ac_ext
-EXEEXT=$ac_cv_exeext
-ac_exeext=$EXEEXT
-echo "$as_me:$LINENO: checking for suffix of object files" >&5
-echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
-if test "${ac_cv_objext+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.o conftest.obj
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; then
- for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
- case $ac_file in
- *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
- *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
- break;;
- esac
-done
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot compute suffix of object files: cannot compile
-See \`config.log' for more details." >&2;}
- { (exit 1); exit 1; }; }
-fi
-
-rm -f conftest.$ac_cv_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
-echo "${ECHO_T}$ac_cv_objext" >&6
-OBJEXT=$ac_cv_objext
-ac_objext=$OBJEXT
-echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
-if test "${ac_cv_c_compiler_gnu+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-#ifndef __GNUC__
- choke me
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_compiler_gnu=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_c_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
-GCC=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-CFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
-echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_g+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_g=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_cc_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
-if test "$ac_test_CFLAGS" = set; then
- CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
- if test "$GCC" = yes; then
- CFLAGS="-g -O2"
- else
- CFLAGS="-g"
- fi
-else
- if test "$GCC" = yes; then
- CFLAGS="-O2"
- else
- CFLAGS=
- fi
-fi
-echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
-echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
-if test "${ac_cv_prog_cc_stdc+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- ac_cv_prog_cc_stdc=no
-ac_save_CC=$CC
-cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-#include <stdarg.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
- char **p;
- int i;
-{
- return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
- char *s;
- va_list v;
- va_start (v,p);
- s = g (p, va_arg (v,int));
- va_end (v);
- return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
- function prototypes and stuff, but not '\xHH' hex character constants.
- These don't provoke an error unfortunately, instead are silently treated
- as 'x'. The following induces an error, until -std1 is added to get
- proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
- array size at least. It's necessary to write '\x00'==0 to get something
- that's true only with -std1. */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
- ;
- return 0;
-}
-_ACEOF
-# Don't try gcc -ansi; that turns off useful extensions and
-# breaks some systems' header files.
-# AIX -qlanglvl=ansi
-# Ultrix and OSF/1 -std1
-# HP-UX 10.20 and later -Ae
-# HP-UX older versions -Aa -D_HPUX_SOURCE
-# SVR4 -Xc -D__EXTENSIONS__
-for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
- CC="$ac_save_CC $ac_arg"
- rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cc_stdc=$ac_arg
-break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext
-done
-rm -f conftest.$ac_ext conftest.$ac_objext
-CC=$ac_save_CC
-
-fi
-
-case "x$ac_cv_prog_cc_stdc" in
- x|xno)
- echo "$as_me:$LINENO: result: none needed" >&5
-echo "${ECHO_T}none needed" >&6 ;;
- *)
- echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
-echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
- CC="$CC $ac_cv_prog_cc_stdc" ;;
-esac
-
-# Some people use a C++ compiler to compile C. Since we use `exit',
-# in C++ we need to declare it. In case someone uses the same compiler
-# for both compiling C and C++ we need to have the C++ compiler decide
-# the declaration of exit, since it's the most demanding environment.
-cat >conftest.$ac_ext <<_ACEOF
-#ifndef __cplusplus
- choke me
-#endif
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- for ac_declaration in \
- '' \
- 'extern "C" void std::exit (int) throw (); using std::exit;' \
- 'extern "C" void std::exit (int); using std::exit;' \
- 'extern "C" void exit (int) throw ();' \
- 'extern "C" void exit (int);' \
- 'void exit (int);'
-do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-#include <stdlib.h>
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
- echo '#ifdef __cplusplus' >>confdefs.h
- echo $ac_declaration >>confdefs.h
- echo '#endif' >>confdefs.h
-fi
-
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-cat >>confdefs.h <<_ACEOF
-#define CC $CC
-_ACEOF
-
-
-ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-if test -n "$ac_tool_prefix"; then
- for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
- do
- # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$CXX"; then
- ac_cv_prog_CXX="$CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-CXX=$ac_cv_prog_CXX
-if test -n "$CXX"; then
- echo "$as_me:$LINENO: result: $CXX" >&5
-echo "${ECHO_T}$CXX" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$CXX" && break
- done
-fi
-if test -z "$CXX"; then
- ac_ct_CXX=$CXX
- for ac_prog in $CCC g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$ac_ct_CXX"; then
- ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_ac_ct_CXX="$ac_prog"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
-if test -n "$ac_ct_CXX"; then
- echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5
-echo "${ECHO_T}$ac_ct_CXX" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
- test -n "$ac_ct_CXX" && break
-done
-test -n "$ac_ct_CXX" || ac_ct_CXX="g++"
-
- CXX=$ac_ct_CXX
-fi
-
-
-# Provide some information about the compiler.
-echo "$as_me:$LINENO:" \
- "checking for C++ compiler version" >&5
-ac_compiler=`set X $ac_compile; echo $2`
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
- (eval $ac_compiler --version </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
- (eval $ac_compiler -v </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
- (eval $ac_compiler -V </dev/null >&5) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }
-
-echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5
-echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6
-if test "${ac_cv_cxx_compiler_gnu+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-#ifndef __GNUC__
- choke me
-#endif
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_compiler_gnu=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_compiler_gnu=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
-
-fi
-echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5
-echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6
-GXX=`test $ac_compiler_gnu = yes && echo yes`
-ac_test_CXXFLAGS=${CXXFLAGS+set}
-ac_save_CXXFLAGS=$CXXFLAGS
-CXXFLAGS="-g"
-echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5
-echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6
-if test "${ac_cv_prog_cxx_g+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-
-int
-main ()
-{
-
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_prog_cxx_g=yes
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-ac_cv_prog_cxx_g=no
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5
-echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6
-if test "$ac_test_CXXFLAGS" = set; then
- CXXFLAGS=$ac_save_CXXFLAGS
-elif test $ac_cv_prog_cxx_g = yes; then
- if test "$GXX" = yes; then
- CXXFLAGS="-g -O2"
- else
- CXXFLAGS="-g"
- fi
-else
- if test "$GXX" = yes; then
- CXXFLAGS="-O2"
- else
- CXXFLAGS=
- fi
-fi
-for ac_declaration in \
- '' \
- 'extern "C" void std::exit (int) throw (); using std::exit;' \
- 'extern "C" void std::exit (int); using std::exit;' \
- 'extern "C" void exit (int) throw ();' \
- 'extern "C" void exit (int);' \
- 'void exit (int);'
-do
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-#include <stdlib.h>
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- :
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-continue
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
- cat >conftest.$ac_ext <<_ACEOF
-/* confdefs.h. */
-_ACEOF
-cat confdefs.h >>conftest.$ac_ext
-cat >>conftest.$ac_ext <<_ACEOF
-/* end confdefs.h. */
-$ac_declaration
-int
-main ()
-{
-exit (42);
- ;
- return 0;
-}
-_ACEOF
-rm -f conftest.$ac_objext
-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
- (eval $ac_compile) 2>conftest.er1
- ac_status=$?
- grep -v '^ *+' conftest.er1 >conftest.err
- rm -f conftest.er1
- cat conftest.err >&5
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); } &&
- { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; } &&
- { ac_try='test -s conftest.$ac_objext'
- { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:$LINENO: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- break
-else
- echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-fi
-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest*
-if test -n "$ac_declaration"; then
- echo '#ifdef __cplusplus' >>confdefs.h
- echo $ac_declaration >>confdefs.h
- echo '#endif' >>confdefs.h
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-cat >>confdefs.h <<_ACEOF
-#define CXX $CXX
-_ACEOF
-
-
-ac_ext=cc
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-
-
-echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
-echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6
-set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'`
-if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- cat >conftest.make <<\_ACEOF
-all:
- @echo 'ac_maketemp="$(MAKE)"'
-_ACEOF
-# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
-eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`
-if test -n "$ac_maketemp"; then
- eval ac_cv_prog_make_${ac_make}_set=yes
-else
- eval ac_cv_prog_make_${ac_make}_set=no
-fi
-rm -f conftest.make
-fi
-if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
- echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
- SET_MAKE=
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
- SET_MAKE="MAKE=${MAKE-make}"
-fi
-
-
-if test $BUILD_PARSERS = true; then
-
-# Extract the first word of "flex", so it can be a program name with args.
-set dummy flex; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_FLEX+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$FLEX"; then
- ac_cv_prog_FLEX="$FLEX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_FLEX="flex"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-FLEX=$ac_cv_prog_FLEX
-if test -n "$FLEX"; then
- echo "$as_me:$LINENO: result: $FLEX" >&5
-echo "${ECHO_T}$FLEX" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-if test -z "$FLEX"; then
- echo
- echo "error: flex is required to compile ragel"
- echo
- exit 1
-fi
-
-# Extract the first word of "gperf", so it can be a program name with args.
-set dummy gperf; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_GPERF+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$GPERF"; then
- ac_cv_prog_GPERF="$GPERF" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_GPERF="gperf"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-GPERF=$ac_cv_prog_GPERF
-if test -n "$GPERF"; then
- echo "$as_me:$LINENO: result: $GPERF" >&5
-echo "${ECHO_T}$GPERF" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-if test -z "$GPERF"; then
- echo
- echo "error: gperf is required to compile ragel"
- echo
- exit 1
-fi
-
-# Extract the first word of "bison", so it can be a program name with args.
-set dummy bison; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_BISON+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$BISON"; then
- ac_cv_prog_BISON="$BISON" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_BISON="bison"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-BISON=$ac_cv_prog_BISON
-if test -n "$BISON"; then
- echo "$as_me:$LINENO: result: $BISON" >&5
-echo "${ECHO_T}$BISON" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-if test -z "$BISON"; then
- echo
- echo "error: bison is required to compile ragel"
- echo
- exit 1
-fi
-
-if "$BISON" --version | grep 'bison++'; then
- echo
- echo "error: sorry, ragel cannot be compiled with bison++"
- echo
- exit 1
-fi
-
-fi # BUILD_PARSERS
-
-# Extract the first word of "gdc", so it can be a program name with args.
-set dummy gdc; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_GDC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$GDC"; then
- ac_cv_prog_GDC="$GDC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_GDC="gdc"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-GDC=$ac_cv_prog_GDC
-if test -n "$GDC"; then
- echo "$as_me:$LINENO: result: $GDC" >&5
-echo "${ECHO_T}$GDC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-if test -n "$GDC"; then
- cat >>confdefs.h <<_ACEOF
-#define GDC $GDC
-_ACEOF
-
-fi
-
-echo "$as_me:$LINENO: checking for the Objective-C compiler" >&5
-echo $ECHO_N "checking for the Objective-C compiler... $ECHO_C" >&6
-cat > conftest.m <<EOF
-int main() { return 0; }
-EOF
-GOBJC=""
-if gcc -x objective-c conftest.m -o conftest.bin 2>/dev/null; then
- GOBJC="gcc -x objective-c"
- echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
- cat >>confdefs.h <<_ACEOF
-#define GOBJC $GOBJC
-_ACEOF
-
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-
-# Extract the first word of "javac", so it can be a program name with args.
-set dummy javac; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_JAVAC+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$JAVAC"; then
- ac_cv_prog_JAVAC="$JAVAC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_JAVAC="javac"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-JAVAC=$ac_cv_prog_JAVAC
-if test -n "$JAVAC"; then
- echo "$as_me:$LINENO: result: $JAVAC" >&5
-echo "${ECHO_T}$JAVAC" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-if test -n "$JAVAC"; then
- cat >>confdefs.h <<_ACEOF
-#define JAVAC $JAVAC
-_ACEOF
-
-fi
-
-# Extract the first word of "txl", so it can be a program name with args.
-set dummy txl; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_prog_TXL+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test -n "$TXL"; then
- ac_cv_prog_TXL="$TXL" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_prog_TXL="txl"
- echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-
-fi
-fi
-TXL=$ac_cv_prog_TXL
-if test -n "$TXL"; then
- echo "$as_me:$LINENO: result: $TXL" >&5
-echo "${ECHO_T}$TXL" >&6
-else
- echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
-if test -n "$TXL"; then
- cat >>confdefs.h <<_ACEOF
-#define TXL $TXL
-_ACEOF
-
-fi
-
- ac_config_files="$ac_config_files Makefile common/Makefile ragel/Makefile rlcodegen/Makefile doc/Makefile test/Makefile"
-cat >confcache <<\_ACEOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs, see configure's option --config-cache.
-# It is not useful on other systems. If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
-
-_ACEOF
-
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, don't put newlines in cache variables' values.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-{
- (set) 2>&1 |
- case `(ac_space=' '; set | grep ac_space) 2>&1` in
- *ac_space=\ *)
- # `set' does not quote correctly, so add quotes (double-quote
- # substitution turns \\\\ into \\, and sed turns \\ into \).
- sed -n \
- "s/'/'\\\\''/g;
- s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
- ;;
- *)
- # `set' quotes correctly as required by POSIX, so do not add quotes.
- sed -n \
- "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
- ;;
- esac;
-} |
- sed '
- t clear
- : clear
- s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
- t end
- /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
- : end' >>confcache
-if diff $cache_file confcache >/dev/null 2>&1; then :; else
- if test -w $cache_file; then
- test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
- cat confcache >$cache_file
- else
- echo "not updating unwritable cache $cache_file"
- fi
-fi
-rm -f confcache
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# VPATH may cause trouble with some makes, so we remove $(srcdir),
-# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
- ac_vpsub='/^[ ]*VPATH[ ]*=/{
-s/:*\$(srcdir):*/:/;
-s/:*\${srcdir}:*/:/;
-s/:*@srcdir@:*/:/;
-s/^\([^=]*=[ ]*\):*/\1/;
-s/:*$//;
-s/^[^=]*=[ ]*$//;
-}'
-fi
-
-DEFS=-DHAVE_CONFIG_H
-
-ac_libobjs=
-ac_ltlibobjs=
-for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
- # 1. Remove the extension, and $U if already installed.
- ac_i=`echo "$ac_i" |
- sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
- # 2. Add them.
- ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
- ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
-done
-LIBOBJS=$ac_libobjs
-
-LTLIBOBJS=$ac_ltlibobjs
-
-
-
-: ${CONFIG_STATUS=./config.status}
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
-echo "$as_me: creating $CONFIG_STATUS" >&6;}
-cat >$CONFIG_STATUS <<_ACEOF
-#! $SHELL
-# Generated by $as_me.
-# Run this file to recreate the current configuration.
-# Compiler output produced by configure, useful for debugging
-# configure, is in config.log if it exists.
-
-debug=false
-ac_cs_recheck=false
-ac_cs_silent=false
-SHELL=\${CONFIG_SHELL-$SHELL}
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-## --------------------- ##
-## M4sh Initialization. ##
-## --------------------- ##
-
-# Be Bourne compatible
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
- emulate sh
- NULLCMD=:
- # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
- # is contrary to our usage. Disable this feature.
- alias -g '${1+"$@"}'='"$@"'
-elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
- set -o posix
-fi
-DUALCASE=1; export DUALCASE # for MKS sh
-
-# Support unset when possible.
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
- as_unset=unset
-else
- as_unset=false
-fi
-
-
-# Work around bugs in pre-3.0 UWIN ksh.
-$as_unset ENV MAIL MAILPATH
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-for as_var in \
- LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
- LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
- LC_TELEPHONE LC_TIME
-do
- if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
- eval $as_var=C; export $as_var
- else
- $as_unset $as_var
- fi
-done
-
-# Required to use basename.
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
- as_basename=basename
-else
- as_basename=false
-fi
-
-
-# Name of the executable.
-as_me=`$as_basename "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
- X"$0" : 'X\(//\)$' \| \
- X"$0" : 'X\(/\)$' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X/"$0" |
- sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
- /^X\/\(\/\/\)$/{ s//\1/; q; }
- /^X\/\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
-
-
-# PATH needs CR, and LINENO needs CR and PATH.
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
- echo "#! /bin/sh" >conf$$.sh
- echo "exit 0" >>conf$$.sh
- chmod +x conf$$.sh
- if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
- PATH_SEPARATOR=';'
- else
- PATH_SEPARATOR=:
- fi
- rm -f conf$$.sh
-fi
-
-
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" || {
- # Find who we are. Look in the path if we contain no path at all
- # relative or not.
- case $0 in
- *[\\/]* ) as_myself=$0 ;;
- *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-done
-
- ;;
- esac
- # We did not find ourselves, most probably we were run as `sh COMMAND'
- # in which case we are not to be found in the path.
- if test "x$as_myself" = x; then
- as_myself=$0
- fi
- if test ! -f "$as_myself"; then
- { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
-echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
- { (exit 1); exit 1; }; }
- fi
- case $CONFIG_SHELL in
- '')
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for as_base in sh bash ksh sh5; do
- case $as_dir in
- /*)
- if ("$as_dir/$as_base" -c '
- as_lineno_1=$LINENO
- as_lineno_2=$LINENO
- as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
- test "x$as_lineno_1" != "x$as_lineno_2" &&
- test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
- $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
- $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
- CONFIG_SHELL=$as_dir/$as_base
- export CONFIG_SHELL
- exec "$CONFIG_SHELL" "$0" ${1+"$@"}
- fi;;
- esac
- done
-done
-;;
- esac
-
- # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
- # uniformly replaced by the line number. The first 'sed' inserts a
- # line-number line before each line; the second 'sed' does the real
- # work. The second script uses 'N' to pair each line-number line
- # with the numbered line, and appends trailing '-' during
- # substitution so that $LINENO is not a special case at line end.
- # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
- # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
- sed '=' <$as_myself |
- sed '
- N
- s,$,-,
- : loop
- s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
- t loop
- s,-$,,
- s,^['$as_cr_digits']*\n,,
- ' >$as_me.lineno &&
- chmod +x $as_me.lineno ||
- { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
-echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
- { (exit 1); exit 1; }; }
-
- # Don't try to exec as it changes $[0], causing all sort of problems
- # (the dirname of $[0] is not the place where we might find the
- # original and so on. Autoconf is especially sensible to this).
- . ./$as_me.lineno
- # Exit status is that of the last command.
- exit
-}
-
-
-case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
- *c*,-n*) ECHO_N= ECHO_C='
-' ECHO_T=' ' ;;
- *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
- *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
-esac
-
-if expr a : '\(a\)' >/dev/null 2>&1; then
- as_expr=expr
-else
- as_expr=false
-fi
-
-rm -f conf$$ conf$$.exe conf$$.file
-echo >conf$$.file
-if ln -s conf$$.file conf$$ 2>/dev/null; then
- # We could just check for DJGPP; but this test a) works b) is more generic
- # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
- if test -f conf$$.exe; then
- # Don't use ln at all; we don't have any links
- as_ln_s='cp -p'
- else
- as_ln_s='ln -s'
- fi
-elif ln conf$$.file conf$$ 2>/dev/null; then
- as_ln_s=ln
-else
- as_ln_s='cp -p'
-fi
-rm -f conf$$ conf$$.exe conf$$.file
-
-if mkdir -p . 2>/dev/null; then
- as_mkdir_p=:
-else
- test -d ./-p && rmdir ./-p
- as_mkdir_p=false
-fi
-
-as_executable_p="test -f"
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.
-as_nl='
-'
-IFS=" $as_nl"
-
-# CDPATH.
-$as_unset CDPATH
-
-exec 6>&1
-
-# Open the log real soon, to keep \$[0] and so on meaningful, and to
-# report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling. Logging --version etc. is OK.
-exec 5>>config.log
-{
- echo
- sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
-} >&5
-cat >&5 <<_CSEOF
-
-This file was extended by $as_me, which was
-generated by GNU Autoconf 2.59. Invocation command line was
-
- CONFIG_FILES = $CONFIG_FILES
- CONFIG_HEADERS = $CONFIG_HEADERS
- CONFIG_LINKS = $CONFIG_LINKS
- CONFIG_COMMANDS = $CONFIG_COMMANDS
- $ $0 $@
-
-_CSEOF
-echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
-echo >&5
-_ACEOF
-
-# Files that config.status was made for.
-if test -n "$ac_config_files"; then
- echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_headers"; then
- echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_links"; then
- echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
-fi
-
-if test -n "$ac_config_commands"; then
- echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
-fi
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-ac_cs_usage="\
-\`$as_me' instantiates files from templates according to the
-current configuration.
-
-Usage: $0 [OPTIONS] [FILE]...
-
- -h, --help print this help, then exit
- -V, --version print version number, then exit
- -q, --quiet do not print progress messages
- -d, --debug don't remove temporary files
- --recheck update $as_me by reconfiguring in the same conditions
- --file=FILE[:TEMPLATE]
- instantiate the configuration file FILE
- --header=FILE[:TEMPLATE]
- instantiate the configuration header FILE
-
-Configuration files:
-$config_files
-
-Configuration headers:
-$config_headers
-
-Report bugs to <bug-autoconf@gnu.org>."
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-ac_cs_version="\\
-config.status
-configured by $0, generated by GNU Autoconf 2.59,
- with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
-
-Copyright (C) 2003 Free Software Foundation, Inc.
-This config.status script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it."
-srcdir=$srcdir
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-# If no file are specified by the user, then we need to provide default
-# value. By we need to know if files were specified by the user.
-ac_need_defaults=:
-while test $# != 0
-do
- case $1 in
- --*=*)
- ac_option=`expr "x$1" : 'x\([^=]*\)='`
- ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
- ac_shift=:
- ;;
- -*)
- ac_option=$1
- ac_optarg=$2
- ac_shift=shift
- ;;
- *) # This is not an option, so the user has probably given explicit
- # arguments.
- ac_option=$1
- ac_need_defaults=false;;
- esac
-
- case $ac_option in
- # Handling of the options.
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
- -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
- ac_cs_recheck=: ;;
- --version | --vers* | -V )
- echo "$ac_cs_version"; exit 0 ;;
- --he | --h)
- # Conflict between --help and --header
- { { echo "$as_me:$LINENO: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: ambiguous option: $1
-Try \`$0 --help' for more information." >&2;}
- { (exit 1); exit 1; }; };;
- --help | --hel | -h )
- echo "$ac_cs_usage"; exit 0 ;;
- --debug | --d* | -d )
- debug=: ;;
- --file | --fil | --fi | --f )
- $ac_shift
- CONFIG_FILES="$CONFIG_FILES $ac_optarg"
- ac_need_defaults=false;;
- --header | --heade | --head | --hea )
- $ac_shift
- CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
- ac_need_defaults=false;;
- -q | -quiet | --quiet | --quie | --qui | --qu | --q \
- | -silent | --silent | --silen | --sile | --sil | --si | --s)
- ac_cs_silent=: ;;
-
- # This is an error.
- -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&5
-echo "$as_me: error: unrecognized option: $1
-Try \`$0 --help' for more information." >&2;}
- { (exit 1); exit 1; }; } ;;
-
- *) ac_config_targets="$ac_config_targets $1" ;;
-
- esac
- shift
-done
-
-ac_configure_extra_args=
-
-if $ac_cs_silent; then
- exec 6>/dev/null
- ac_configure_extra_args="$ac_configure_extra_args --silent"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
-if \$ac_cs_recheck; then
- echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
- exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
-fi
-
-_ACEOF
-
-
-
-
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-for ac_config_target in $ac_config_targets
-do
- case "$ac_config_target" in
- # Handling of arguments.
- "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
- "common/Makefile" ) CONFIG_FILES="$CONFIG_FILES common/Makefile" ;;
- "ragel/Makefile" ) CONFIG_FILES="$CONFIG_FILES ragel/Makefile" ;;
- "rlcodegen/Makefile" ) CONFIG_FILES="$CONFIG_FILES rlcodegen/Makefile" ;;
- "doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
- "test/Makefile" ) CONFIG_FILES="$CONFIG_FILES test/Makefile" ;;
- "common/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS common/config.h" ;;
- *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
-echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
- { (exit 1); exit 1; }; };;
- esac
-done
-
-# If the user did not use the arguments to specify the items to instantiate,
-# then the envvar interface is used. Set only those that are not.
-# We use the long form for the default assignment because of an extremely
-# bizarre bug on SunOS 4.1.3.
-if $ac_need_defaults; then
- test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
- test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
-fi
-
-# Have a temporary directory for convenience. Make it in the build tree
-# simply because there is no reason to put it here, and in addition,
-# creating and moving files from /tmp can sometimes cause problems.
-# Create a temporary directory, and hook for its removal unless debugging.
-$debug ||
-{
- trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
- trap '{ (exit 1); exit 1; }' 1 2 13 15
-}
-
-# Create a (secure) tmp directory for tmp files.
-
-{
- tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
- test -n "$tmp" && test -d "$tmp"
-} ||
-{
- tmp=./confstat$$-$RANDOM
- (umask 077 && mkdir $tmp)
-} ||
-{
- echo "$me: cannot create a temporary directory in ." >&2
- { (exit 1); exit 1; }
-}
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<_ACEOF
-
-#
-# CONFIG_FILES section.
-#
-
-# No need to generate the scripts if there are no CONFIG_FILES.
-# This happens for instance when ./config.status config.h
-if test -n "\$CONFIG_FILES"; then
- # Protect against being on the right side of a sed subst in config.status.
- sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
- s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
-s,@SHELL@,$SHELL,;t t
-s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
-s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
-s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
-s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
-s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
-s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
-s,@exec_prefix@,$exec_prefix,;t t
-s,@prefix@,$prefix,;t t
-s,@program_transform_name@,$program_transform_name,;t t
-s,@bindir@,$bindir,;t t
-s,@sbindir@,$sbindir,;t t
-s,@libexecdir@,$libexecdir,;t t
-s,@datadir@,$datadir,;t t
-s,@sysconfdir@,$sysconfdir,;t t
-s,@sharedstatedir@,$sharedstatedir,;t t
-s,@localstatedir@,$localstatedir,;t t
-s,@libdir@,$libdir,;t t
-s,@includedir@,$includedir,;t t
-s,@oldincludedir@,$oldincludedir,;t t
-s,@infodir@,$infodir,;t t
-s,@mandir@,$mandir,;t t
-s,@build_alias@,$build_alias,;t t
-s,@host_alias@,$host_alias,;t t
-s,@target_alias@,$target_alias,;t t
-s,@DEFS@,$DEFS,;t t
-s,@ECHO_C@,$ECHO_C,;t t
-s,@ECHO_N@,$ECHO_N,;t t
-s,@ECHO_T@,$ECHO_T,;t t
-s,@LIBS@,$LIBS,;t t
-s,@BUILD_PARSERS@,$BUILD_PARSERS,;t t
-s,@CC@,$CC,;t t
-s,@CFLAGS@,$CFLAGS,;t t
-s,@LDFLAGS@,$LDFLAGS,;t t
-s,@CPPFLAGS@,$CPPFLAGS,;t t
-s,@ac_ct_CC@,$ac_ct_CC,;t t
-s,@EXEEXT@,$EXEEXT,;t t
-s,@OBJEXT@,$OBJEXT,;t t
-s,@CXX@,$CXX,;t t
-s,@CXXFLAGS@,$CXXFLAGS,;t t
-s,@ac_ct_CXX@,$ac_ct_CXX,;t t
-s,@SET_MAKE@,$SET_MAKE,;t t
-s,@FLEX@,$FLEX,;t t
-s,@GPERF@,$GPERF,;t t
-s,@BISON@,$BISON,;t t
-s,@GDC@,$GDC,;t t
-s,@GOBJC@,$GOBJC,;t t
-s,@JAVAC@,$JAVAC,;t t
-s,@TXL@,$TXL,;t t
-s,@LIBOBJS@,$LIBOBJS,;t t
-s,@LTLIBOBJS@,$LTLIBOBJS,;t t
-CEOF
-
-_ACEOF
-
- cat >>$CONFIG_STATUS <<\_ACEOF
- # Split the substitutions into bite-sized pieces for seds with
- # small command number limits, like on Digital OSF/1 and HP-UX.
- ac_max_sed_lines=48
- ac_sed_frag=1 # Number of current file.
- ac_beg=1 # First line for current file.
- ac_end=$ac_max_sed_lines # Line after last line for current file.
- ac_more_lines=:
- ac_sed_cmds=
- while $ac_more_lines; do
- if test $ac_beg -gt 1; then
- sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
- else
- sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
- fi
- if test ! -s $tmp/subs.frag; then
- ac_more_lines=false
- else
- # The purpose of the label and of the branching condition is to
- # speed up the sed processing (if there are no `@' at all, there
- # is no need to browse any of the substitutions).
- # These are the two extra sed commands mentioned above.
- (echo ':t
- /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
- else
- ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
- fi
- ac_sed_frag=`expr $ac_sed_frag + 1`
- ac_beg=$ac_end
- ac_end=`expr $ac_end + $ac_max_sed_lines`
- fi
- done
- if test -z "$ac_sed_cmds"; then
- ac_sed_cmds=cat
- fi
-fi # test -n "$CONFIG_FILES"
-
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case $ac_file in
- - | *:- | *:-:* ) # input from stdin
- cat >$tmp/stdin
- ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- * ) ac_file_in=$ac_file.in ;;
- esac
-
- # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
- ac_dir=`(dirname "$ac_file") 2>/dev/null ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_file" : 'X\(//\)[^/]' \| \
- X"$ac_file" : 'X\(//\)$' \| \
- X"$ac_file" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$ac_file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- { if $as_mkdir_p; then
- mkdir -p "$ac_dir"
- else
- as_dir="$ac_dir"
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
- { (exit 1); exit 1; }; }; }
-
- ac_builddir=.
-
-if test "$ac_dir" != .; then
- ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
- # A "../" for each directory in $ac_dir_suffix.
- ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
-else
- ac_dir_suffix= ac_top_builddir=
-fi
-
-case $srcdir in
- .) # No --srcdir option. We are building in place.
- ac_srcdir=.
- if test -z "$ac_top_builddir"; then
- ac_top_srcdir=.
- else
- ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
- fi ;;
- [\\/]* | ?:[\\/]* ) # Absolute path.
- ac_srcdir=$srcdir$ac_dir_suffix;
- ac_top_srcdir=$srcdir ;;
- *) # Relative path.
- ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
- ac_top_srcdir=$ac_top_builddir$srcdir ;;
-esac
-
-# Do not use `cd foo && pwd` to compute absolute paths, because
-# the directories may not exist.
-case `pwd` in
-.) ac_abs_builddir="$ac_dir";;
-*)
- case "$ac_dir" in
- .) ac_abs_builddir=`pwd`;;
- [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
- *) ac_abs_builddir=`pwd`/"$ac_dir";;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_builddir=${ac_top_builddir}.;;
-*)
- case ${ac_top_builddir}. in
- .) ac_abs_top_builddir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
- *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_srcdir=$ac_srcdir;;
-*)
- case $ac_srcdir in
- .) ac_abs_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
- *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
- esac;;
-esac
-case $ac_abs_builddir in
-.) ac_abs_top_srcdir=$ac_top_srcdir;;
-*)
- case $ac_top_srcdir in
- .) ac_abs_top_srcdir=$ac_abs_builddir;;
- [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
- *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
- esac;;
-esac
-
-
-
- # Let's still pretend it is `configure' which instantiates (i.e., don't
- # use $as_me), people would be surprised to read:
- # /* config.h. Generated by config.status. */
- if test x"$ac_file" = x-; then
- configure_input=
- else
- configure_input="$ac_file. "
- fi
- configure_input=$configure_input"Generated from `echo $ac_file_in |
- sed 's,.*/,,'` by configure."
-
- # First look for the input files in the build tree, otherwise in the
- # src tree.
- ac_file_inputs=`IFS=:
- for f in $ac_file_in; do
- case $f in
- -) echo $tmp/stdin ;;
- [\\/$]*)
- # Absolute (can't be DOS-style, as IFS=:)
- test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- echo "$f";;
- *) # Relative
- if test -f "$f"; then
- # Build tree
- echo "$f"
- elif test -f "$srcdir/$f"; then
- # Source tree
- echo "$srcdir/$f"
- else
- # /dev/null tree
- { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- fi;;
- esac
- done` || { (exit 1); exit 1; }
-
- if test x"$ac_file" != x-; then
- { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
- rm -f "$ac_file"
- fi
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF
- sed "$ac_vpsub
-$extrasub
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-:t
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s,@configure_input@,$configure_input,;t t
-s,@srcdir@,$ac_srcdir,;t t
-s,@abs_srcdir@,$ac_abs_srcdir,;t t
-s,@top_srcdir@,$ac_top_srcdir,;t t
-s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
-s,@builddir@,$ac_builddir,;t t
-s,@abs_builddir@,$ac_abs_builddir,;t t
-s,@top_builddir@,$ac_top_builddir,;t t
-s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
-" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
- rm -f $tmp/stdin
- if test x"$ac_file" != x-; then
- mv $tmp/out $ac_file
- else
- cat $tmp/out
- rm -f $tmp/out
- fi
-
-done
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-#
-# CONFIG_HEADER section.
-#
-
-# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
-# NAME is the cpp macro being defined and VALUE is the value it is being given.
-#
-# ac_d sets the value in "#define NAME VALUE" lines.
-ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)'
-ac_dB='[ ].*$,\1#\2'
-ac_dC=' '
-ac_dD=',;t'
-# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
-ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
-ac_uB='$,\1#\2define\3'
-ac_uC=' '
-ac_uD=',;t'
-
-for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
- # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
- case $ac_file in
- - | *:- | *:-:* ) # input from stdin
- cat >$tmp/stdin
- ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
- ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
- * ) ac_file_in=$ac_file.in ;;
- esac
-
- test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
-
- # First look for the input files in the build tree, otherwise in the
- # src tree.
- ac_file_inputs=`IFS=:
- for f in $ac_file_in; do
- case $f in
- -) echo $tmp/stdin ;;
- [\\/$]*)
- # Absolute (can't be DOS-style, as IFS=:)
- test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- # Do quote $f, to prevent DOS paths from being IFS'd.
- echo "$f";;
- *) # Relative
- if test -f "$f"; then
- # Build tree
- echo "$f"
- elif test -f "$srcdir/$f"; then
- # Source tree
- echo "$srcdir/$f"
- else
- # /dev/null tree
- { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
-echo "$as_me: error: cannot find input file: $f" >&2;}
- { (exit 1); exit 1; }; }
- fi;;
- esac
- done` || { (exit 1); exit 1; }
- # Remove the trailing spaces.
- sed 's/[ ]*$//' $ac_file_inputs >$tmp/in
-
-_ACEOF
-
-# Transform confdefs.h into two sed scripts, `conftest.defines' and
-# `conftest.undefs', that substitutes the proper values into
-# config.h.in to produce config.h. The first handles `#define'
-# templates, and the second `#undef' templates.
-# And first: Protect against being on the right side of a sed subst in
-# config.status. Protect against being in an unquoted here document
-# in config.status.
-rm -f conftest.defines conftest.undefs
-# Using a here document instead of a string reduces the quoting nightmare.
-# Putting comments in sed scripts is not portable.
-#
-# `end' is used to avoid that the second main sed command (meant for
-# 0-ary CPP macros) applies to n-ary macro definitions.
-# See the Autoconf documentation for `clear'.
-cat >confdef2sed.sed <<\_ACEOF
-s/[\\&,]/\\&/g
-s,[\\$`],\\&,g
-t clear
-: clear
-s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
-t end
-s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
-: end
-_ACEOF
-# If some macros were called several times there might be several times
-# the same #defines, which is useless. Nevertheless, we may not want to
-# sort them, since we want the *last* AC-DEFINE to be honored.
-uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
-sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
-rm -f confdef2sed.sed
-
-# This sed command replaces #undef with comments. This is necessary, for
-# example, in the case of _POSIX_SOURCE, which is predefined and required
-# on some systems where configure will not decide to define it.
-cat >>conftest.undefs <<\_ACEOF
-s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
-_ACEOF
-
-# Break up conftest.defines because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
-echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
-echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
-echo ' :' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.defines >/dev/null
-do
- # Write a limited-size here document to $tmp/defines.sed.
- echo ' cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
- # Speed up: don't consider the non `#define' lines.
- echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS
- # Work around the forget-to-reset-the-flag bug.
- echo 't clr' >>$CONFIG_STATUS
- echo ': clr' >>$CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
- echo 'CEOF
- sed -f $tmp/defines.sed $tmp/in >$tmp/out
- rm -f $tmp/in
- mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
- rm -f conftest.defines
- mv conftest.tail conftest.defines
-done
-rm -f conftest.defines
-echo ' fi # grep' >>$CONFIG_STATUS
-echo >>$CONFIG_STATUS
-
-# Break up conftest.undefs because some shells have a limit on the size
-# of here documents, and old seds have small limits too (100 cmds).
-echo ' # Handle all the #undef templates' >>$CONFIG_STATUS
-rm -f conftest.tail
-while grep . conftest.undefs >/dev/null
-do
- # Write a limited-size here document to $tmp/undefs.sed.
- echo ' cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
- # Speed up: don't consider the non `#undef'
- echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS
- # Work around the forget-to-reset-the-flag bug.
- echo 't clr' >>$CONFIG_STATUS
- echo ': clr' >>$CONFIG_STATUS
- sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
- echo 'CEOF
- sed -f $tmp/undefs.sed $tmp/in >$tmp/out
- rm -f $tmp/in
- mv $tmp/out $tmp/in
-' >>$CONFIG_STATUS
- sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
- rm -f conftest.undefs
- mv conftest.tail conftest.undefs
-done
-rm -f conftest.undefs
-
-cat >>$CONFIG_STATUS <<\_ACEOF
- # Let's still pretend it is `configure' which instantiates (i.e., don't
- # use $as_me), people would be surprised to read:
- # /* config.h. Generated by config.status. */
- if test x"$ac_file" = x-; then
- echo "/* Generated by configure. */" >$tmp/config.h
- else
- echo "/* $ac_file. Generated by configure. */" >$tmp/config.h
- fi
- cat $tmp/in >>$tmp/config.h
- rm -f $tmp/in
- if test x"$ac_file" != x-; then
- if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
- { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
-echo "$as_me: $ac_file is unchanged" >&6;}
- else
- ac_dir=`(dirname "$ac_file") 2>/dev/null ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$ac_file" : 'X\(//\)[^/]' \| \
- X"$ac_file" : 'X\(//\)$' \| \
- X"$ac_file" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$ac_file" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- { if $as_mkdir_p; then
- mkdir -p "$ac_dir"
- else
- as_dir="$ac_dir"
- as_dirs=
- while test ! -d "$as_dir"; do
- as_dirs="$as_dir $as_dirs"
- as_dir=`(dirname "$as_dir") 2>/dev/null ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
- X"$as_dir" : 'X\(//\)[^/]' \| \
- X"$as_dir" : 'X\(//\)$' \| \
- X"$as_dir" : 'X\(/\)' \| \
- . : '\(.\)' 2>/dev/null ||
-echo X"$as_dir" |
- sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
- /^X\(\/\/\)[^/].*/{ s//\1/; q; }
- /^X\(\/\/\)$/{ s//\1/; q; }
- /^X\(\/\).*/{ s//\1/; q; }
- s/.*/./; q'`
- done
- test ! -n "$as_dirs" || mkdir $as_dirs
- fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
-echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
- { (exit 1); exit 1; }; }; }
-
- rm -f $ac_file
- mv $tmp/config.h $ac_file
- fi
- else
- cat $tmp/config.h
- rm -f $tmp/config.h
- fi
-done
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF
-
-{ (exit 0); exit 0; }
-_ACEOF
-chmod +x $CONFIG_STATUS
-ac_clean_files=$ac_clean_files_save
-
-
-# configure is writing to config.log, and then calls config.status.
-# config.status does its own redirection, appending to config.log.
-# Unfortunately, on DOS this fails, as config.log is still kept open
-# by configure, so config.status won't be able to write to it; its
-# output is simply discarded. So we exec the FD to /dev/null,
-# effectively closing config.log, so it can be properly (re)opened and
-# appended to by config.status. When coming back to configure, we
-# need to make the FD available again.
-if test "$no_create" != yes; then
- ac_cs_success=:
- ac_config_status_args=
- test "$silent" = yes &&
- ac_config_status_args="$ac_config_status_args --quiet"
- exec 5>/dev/null
- $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
- exec 5>>config.log
- # Use ||, not &&, to avoid exiting from the if with $? = 1, which
- # would make configure fail if this is the last instruction.
- $ac_cs_success || { (exit 1); exit 1; }
-fi
-
-
-echo "configuration of ragel complete"
+++ /dev/null
-#
-# Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
-#
-
-# This file is part of Ragel.
-#
-# Ragel is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Ragel is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ragel; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-INPUT = version.tex ragel-guide.tex
-
-# Pick up all the figures in the current dir.
-FIGURES = $(wildcard *.fig)
-PDFFIGS = $(FIGURES:%.fig=%.pdf)
-
-# Get the version info.
-include ../version.mk
-
-# Install prefix.
-PREFIX = @prefix@
-
-# Rules.
-all: ragel-guide.pdf ragel.1 rlcodegen.1
-
-ragel-guide.pdf: $(PDFFIGS) $(INPUT)
-
-%.pdf: %.fig
- fig2dev -L pdf $< $@
-
-%.pdf: %.tex
- pdflatex -interaction=nonstopmode $< >/dev/null
- pdflatex -interaction=nonstopmode $< >/dev/null
- pdflatex -interaction=nonstopmode $< >/dev/null
-
-version.tex: ../version.mk
- echo '\def\version{$(VERSION)}' > version.tex
- echo '\def\pubdate{$(PUBDATE)}' >> version.tex
-
-ragel.1: ragel.1.in ../version.mk
- cat ragel.1.in | sed 's/@PUBDATE@/$(PUBDATE)/' \
- | sed 's/@VERSION@/$(VERSION)/' > ragel.1
-
-rlcodegen.1: rlcodegen.1.in ../version.mk
- cat rlcodegen.1.in | sed 's/@PUBDATE@/$(PUBDATE)/' \
- | sed 's/@VERSION@/$(VERSION)/' > rlcodegen.1
-
-clean:
- rm -f ragel.1 rlcodegen.1 \
- *.bak *.aux *.dvi *.log *.toc *.pdf
-
-distclean: clean
- rm -f Makefile
-
-install: all
- install -d $(PREFIX)/man/man1
- install -m 644 ragel.1 $(PREFIX)/man/man1/ragel.1
- install -m 644 rlcodegen.1 $(PREFIX)/man/man1/rlcodegen.1
- install -d $(PREFIX)/share/doc/ragel
- install -m 644 ragel-guide.pdf $(PREFIX)/share/doc/ragel/ragel-guide.pdf
- gzip -c ../ChangeLog > ChangeLog.gz
- install -m 644 ChangeLog.gz $(PREFIX)/share/doc/ragel/ChangeLog.gz
- rm ChangeLog.gz
+++ /dev/null
-<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
-<!ENTITY docbook.dsl PUBLIC
- "-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN" CDATA dsssl>
-]>
-
-<style-sheet>
-<style-specification use="docbook">
-<style-specification-body>
-
-;; your stuff goes here...
-
-(define %generate-article-titlepage% #t)
-(define %generate-article-toc% #t)
-(define %generate-article-titlepage-on-separate-page% #t)
-(define %generate-article-toc-on-titlepage% #f)
-(define %article-page-number-restart% #t)
-
-(define %chapter-autolabel% #t)
-(define %section-autolabel% #t)
-(define (toc-depth nd) 3)
-
-; === Media objects ===
-(define preferred-mediaobject-extensions ;; this magic allows to use different graphical
- (list "eps")) ;; formats for printing and putting online
-(define acceptable-mediaobject-extensions
- '())
-(define preferred-mediaobject-notations
- (list "EPS"))
-(define acceptable-mediaobject-notations
- (list "linespecific"))
-
-; === Rendering ===
-(define %head-after-factor% 0.2) ;; not much whitespace after orderedlist head
-(define ($paragraph$) ;; more whitespace after paragraph than before
- (make paragraph
- first-line-start-indent: (if (is-first-para)
- %para-indent-firstpara%
- %para-indent%)
- space-before: (* %para-sep% 4)
- space-after: (/ %para-sep% 4)
- quadding: %default-quadding%
- hyphenate?: %hyphenation%
- language: (dsssl-language-code)
- (process-children)))
-
-</style-specification-body>
-</style-specification>
-<external-specification id="docbook" document="docbook.dsl">
-</style-sheet>
+++ /dev/null
-#FIG 3.2
-Landscape
-Center
-Metric
-A4
-100.00
-Single
--2
-1200 2
-5 1 0 2 0 7 50 0 -1 0.000 0 0 1 0 630.000 825.000 540 945 630 675 720 945
- 1 1 2.00 60.00 60.00
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 630 1035 135 135 630 1035 765 1035
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 1305 1035 135 135 1305 1035 1440 1035
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 1980 1035 135 135 1980 1035 2115 1035
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 2655 1035 135 135 2655 1035 2790 1035
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 2655 1035 90 90 2655 1035 2745 1035
-2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 1 1 2.00 60.00 60.00
- 765 1035 1170 1035
-2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 1 1 2.00 60.00 60.00
- 1440 1035 1845 1035
-2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 1 1 2.00 60.00 60.00
- 2115 1035 2520 1035
-3 0 0 2 0 7 50 0 -1 0.000 0 1 0 6
- 1 1 2.00 60.00 60.00
- 90 1080 180 945 270 1215 360 1035 405 1035 495 1035
- 0.000 1.000 1.000 1.000 1.000 0.000
-4 0 0 50 0 12 10 0.0000 4 105 180 540 630 df\001
-4 0 0 50 0 0 10 0.0000 4 105 90 900 990 F\001
-4 0 0 50 0 0 10 0.0000 4 105 60 1575 990 I\001
-4 0 0 50 0 0 10 0.0000 4 105 120 2250 990 N\001
+++ /dev/null
-#FIG 3.2
-Landscape
-Center
-Metric
-A4
-100.00
-Single
--2
-1200 2
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 630 1035 135 135 630 1035 765 1035
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 1305 1035 135 135 1305 1035 1440 1035
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 1980 1035 135 135 1980 1035 2115 1035
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 2655 1035 135 135 2655 1035 2790 1035
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 2655 1035 90 90 2655 1035 2745 1035
-2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 1 1 2.00 60.00 60.00
- 765 1035 1170 1035
-2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 1 1 2.00 60.00 60.00
- 1440 1035 1845 1035
-2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 1 1 2.00 60.00 60.00
- 2115 1035 2520 1035
-3 0 0 2 0 7 50 0 -1 0.000 0 1 0 6
- 1 1 2.00 60.00 60.00
- 90 1080 180 945 270 1215 360 1035 405 1035 495 1035
- 0.000 1.000 1.000 1.000 1.000 0.000
-3 0 0 2 0 7 50 0 -1 0.000 0 1 0 4
- 1 1 2.00 60.00 60.00
- 1215 1125 1080 1305 855 1305 720 1125
- 0.000 1.000 1.000 0.000
-3 0 0 2 0 7 50 0 -1 0.000 0 1 0 6
- 1 1 2.00 60.00 60.00
- 1890 1125 1755 1350 1305 1485 810 1485 675 1350 630 1170
- 0.000 1.000 1.000 1.000 1.000 0.000
-3 0 0 2 0 7 50 0 -1 0.000 0 1 0 6
- 1 1 2.00 60.00 60.00
- 585 900 585 765 585 630 675 630 675 765 675 900
- 0.000 1.000 1.000 1.000 1.000 0.000
-3 0 0 2 0 7 50 0 -1 0.000 0 1 0 6
- 1 1 2.00 60.00 60.00
- 1260 900 1260 765 1260 630 1350 630 1350 765 1350 900
- 0.000 1.000 1.000 1.000 1.000 0.000
-3 0 0 2 0 7 50 0 -1 0.000 0 1 0 4
- 1 1 2.00 60.00 60.00
- 1890 945 1755 765 1530 765 1395 945
- 0.000 1.000 1.000 0.000
-4 0 0 50 0 0 10 0.0000 4 105 90 900 990 F\001
-4 0 0 50 0 0 10 0.0000 4 105 120 2250 990 N\001
-4 0 0 50 0 12 10 0.0000 4 105 180 855 1215 df\001
-4 0 0 50 0 12 10 0.0000 4 105 180 1215 1395 df\001
-4 0 0 50 0 12 10 0.0000 4 105 180 540 585 df\001
-4 0 0 50 0 0 10 0.0000 4 105 90 1260 585 F\001
-4 0 0 50 0 0 10 0.0000 4 105 90 1620 720 F\001
-4 0 0 50 0 0 10 0.0000 4 105 60 1620 990 I\001
+++ /dev/null
-#FIG 3.2 Produced by xfig version 3.2.5-alpha5
-Landscape
-Center
-Metric
-A4
-100.00
-Single
--2
-1200 2
-5 1 0 2 0 7 50 0 -1 0.000 0 0 1 0 1665.000 400.500 1575 495 1665 270 1755 495
- 1 1 2.00 60.00 60.00
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 2565 585 90 90 2565 585 2655 585
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 2565 585 135 135 2565 585 2700 585
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 765 585 135 135 765 585 900 585
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 1665 585 135 135 1665 585 1800 585
-2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 1 1 2.00 60.00 60.00
- 900 585 1530 585
-2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 1 1 2.00 60.00 60.00
- 1800 585 2430 585
-3 0 0 2 0 7 50 0 -1 0.000 0 1 0 6
- 1 1 2.00 60.00 60.00
- 225 630 315 495 405 765 495 585 540 585 630 585
- 0.000 1.000 1.000 1.000 1.000 0.000
-4 0 0 50 0 12 10 0.0000 4 105 180 1980 540 nl\001
-4 0 0 50 0 0 10 0.0000 4 105 165 2160 540 /A\001
-4 0 0 50 0 0 10 0.0000 4 75 195 1080 540 a-z\001
-4 0 0 50 0 0 10 0.0000 4 75 195 1575 225 a-z\001
+++ /dev/null
-#FIG 3.2 Produced by xfig version 3.2.5-alpha5
-Landscape
-Center
-Metric
-A4
-100.00
-Single
--2
-1200 2
-5 1 0 2 0 7 50 0 -1 0.000 0 0 1 0 1665.000 378.000 1530 450 1665 225 1800 450
- 1 1 2.00 60.00 60.00
-5 1 0 2 0 7 50 0 -1 0.000 0 1 1 0 1174.891 998.804 1485 540 945 495 630 900
- 1 1 2.00 60.00 60.00
-5 1 0 2 0 7 50 0 -1 0.000 0 0 1 0 1237.500 992.500 1485 1575 990 1575 630 1170
- 1 1 2.00 60.00 60.00
-5 1 0 2 0 7 50 0 -1 0.000 0 0 1 0 1665.000 1323.000 1530 1395 1665 1170 1800 1395
- 1 1 2.00 60.00 60.00
-6 720 225 1125 540
-4 0 0 50 0 0 10 0.3840 4 105 165 931 418 /A\001
-4 0 0 50 0 12 10 0.3840 4 105 180 763 485 sp\001
--6
-6 855 1350 1215 1575
-4 0 0 50 0 12 10 5.8294 4 105 180 871 1429 sp\001
-4 0 0 50 0 0 10 5.8294 4 105 135 1033 1508 /B\001
--6
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 1665 585 135 135 1665 585 1800 585
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 1665 585 180 180 1665 585 1845 585
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 1665 1530 180 180 1665 1530 1845 1530
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 1665 1530 135 135 1665 1530 1800 1530
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 630 1035 135 135 630 1035 765 1035
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 630 1035 90 90 630 1035 720 1035
-2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 1 1 2.00 60.00 60.00
- 720 945 1485 630
-2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 1 1 2.00 60.00 60.00
- 717 1118 1485 1485
-3 0 0 2 0 7 50 0 -1 0.000 0 1 0 6
- 1 1 2.00 60.00 60.00
- 90 1080 180 945 270 1215 360 1035 405 1035 495 1035
- 0.000 1.000 1.000 1.000 1.000 0.000
-3 0 0 2 0 7 50 0 -1 0.000 0 1 0 6
- 1 1 2.00 60.00 60.00
- 495 990 360 855 270 765 360 675 450 765 585 900
- 0.000 1.000 1.000 1.000 1.000 0.000
-3 2 0 2 0 7 44 0 -1 0.000 0 1 0 4
- 1 1 2.00 60.00 60.00
- 1845 1530 2160 1305 2160 810 1845 585
- 0.000 -1.000 -1.000 0.000
-4 0 0 50 0 12 10 0.0000 4 105 180 270 630 sp\001
-4 0 0 50 0 0 10 5.8818 4 105 210 1035 1215 0-9\001
-4 0 0 50 0 0 10 0.3840 4 75 195 945 810 a-z\001
-4 0 0 50 0 0 10 0.0000 4 120 450 1440 180 a-z,0-9\001
-4 0 0 50 0 0 10 0.0000 4 105 210 1530 1125 0-9\001
-4 0 0 50 0 0 10 0.0000 4 105 330 2295 1035 a-z/B\001
+++ /dev/null
-#FIG 3.2
-Landscape
-Center
-Metric
-A4
-100.00
-Single
--2
-1200 2
-5 1 0 2 0 7 50 0 -1 0.000 0 0 1 0 630.000 825.000 540 945 630 675 720 945
- 1 1 2.00 60.00 60.00
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 630 1035 135 135 630 1035 765 1035
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 1305 1035 135 135 1305 1035 1440 1035
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 1980 1035 135 135 1980 1035 2115 1035
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 2655 1035 135 135 2655 1035 2790 1035
-1 3 0 2 0 7 50 0 -1 0.000 1 0.0000 2655 1035 90 90 2655 1035 2745 1035
-2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 1 1 2.00 60.00 60.00
- 765 1035 1170 1035
-2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 1 1 2.00 60.00 60.00
- 1440 1035 1845 1035
-2 1 0 2 0 7 50 0 -1 0.000 0 0 -1 1 0 2
- 1 1 2.00 60.00 60.00
- 2115 1035 2520 1035
-3 0 0 2 0 7 50 0 -1 0.000 0 1 0 6
- 1 1 2.00 60.00 60.00
- 90 1080 180 945 270 1215 360 1035 405 1035 495 1035
- 0.000 1.000 1.000 1.000 1.000 0.000
-4 0 0 50 0 12 10 0.0000 4 105 180 540 630 df\001
-4 0 0 50 0 0 10 0.0000 4 105 90 900 990 F\001
-4 0 0 50 0 0 10 0.0000 4 105 60 1575 990 I\001
-4 0 0 50 0 0 10 0.0000 4 105 120 2250 990 N\001
+++ /dev/null
-.\"
-.\" Copyright 2001 Adrian Thurston <thurston@cs.queensu.ca>
-.\"
-
-.\" This file is part of Ragel.
-.\"
-.\" Ragel is free software; you can redistribute it and/or modify
-.\" it under the terms of the GNU General Public License as published by
-.\" the Free Software Foundation; either version 2 of the License, or
-.\" (at your option) any later version.
-.\"
-.\" Ragel is distributed in the hope that it will be useful,
-.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
-.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-.\" GNU General Public License for more details.
-.\"
-.\" You should have received a copy of the GNU General Public License
-.\" along with Ragel; if not, write to the Free Software
-.\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-.\" Process this file with
-.\" groff -man -Tascii rlcodegen.1
-.\"
-.TH RAGEL 1 "@PUBDATE@" "Ragel @VERSION@" "Ragel State Machine Compiler"
-.SH NAME
-rlcodegen \- code generator for Ragel State Machine Compiler
-.SH SYNOPSIS
-.B rlcodegen
-.RI [ options ]
-.I file
-.SH DESCRIPTION
-.B Note:
-this is the backend component of Ragel. This program accepts a machine
-compiled by the frontend program ragel(1) and generates either code or a
-graphviz dot file.
-
-.SH OPTIONS
-.TP
-.BR \-h ", " \-H ", " \-? ", " \-\-help
-Display help and exit.
-.TP
-.B \-o " file"
-Write output to file. If -o is not given, a default file name is chosen by
-replacing the suffix of the input. For source files ending in .rh the suffix .h
-is used. For all other source files a suffix based on the output language
-is used (.c, .cpp, .m, .dot)
-.TP
-.B \-V
-Generate a Graphviz dotfile instead of code. By default this option writes the
-dotfile to standard output. The frontend options -M and -S can be used
-to specify a subset of the grammar to write.
-.TP
-.B \-p
-Print printable characters in Graphviz output.
-.TP
-.B \-T0
-Generate a table driven FSM. This is the default code style. The table driven
-FSM represents the state machine as static data. There are tables of states,
-transitions, indicies and actions. The current state is stored in a variable.
-The execution is a loop that looks that given the current state and current
-character to process looks up the transition to take using a binary search,
-executes any actions and moves to the target state. In general, the table
-driven FSM produces a smaller binary and requires a less expensive host language
-compile but results in slower running code. The table driven FSM is suitable
-for any FSM.
-.TP
-.B \-T1
-Generate a faster table driven FSM by expanding action lists in the action
-execute code.
-.TP
-.B \-F0
-Generate a flat table driven FSM. Transitions are represented as an array
-indexed by the current alphabet character. This eliminates the need for a
-binary search to locate transitions and produces faster code, however it is
-only suitable for small alphabets.
-.TP
-.B \-F1
-Generate a faster flat table driven FSM by expanding action lists in the action
-execute code.
-.TP
-.B \-G0
-Generate a goto driven FSM. The goto driven FSM represents the state machine
-as a series of goto statements. While in the machine, the current state is
-stored by the processor's instruction pointer. The execution is a flat function
-where control is passed from state to state using gotos. In general, the goto
-FSM produces faster code but results in a larger binary and a more expensive
-host language compile.
-.TP
-.B \-G1
-Generate a faster goto driven FSM by expanding action lists in the action
-execute code.
-.TP
-.B \-G2
-Generate a really fast goto driven FSM by embedding action lists in the state
-machine control code.
-.SH BUGS
-Ragel is still under development and has not yet matured. There are probably
-many bugs.
-.SH CREDITS
-Ragel was written by Adrian Thurston <thurston@cs.queensu.ca>. Objective-C
-output contributed by Eric Ocean. D output contributed by Alan West.
-.SH "SEE ALSO"
-.BR ragel (1),
-.BR re2c (1),
-.BR flex (1)
-
-Homepage: http://www.cs.queensu.ca/home/thurston/ragel/
+++ /dev/null
-#
-# Copyright 2002-2003 Adrian Thurston <thurston@cs.queensu.ca>
-#
-
-# This file is part of Ragel.
-#
-# Ragel is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Ragel is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ragel; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-SUBDIRS = \
- atoi awkemu clang concurrent format gotocallret mailbox params rlscan \
- statechart cppscan
-
-all:
- @for dir in $(SUBDIRS); do cd $$dir; $(MAKE) || exit 1; cd ..; done
-
-ps:
- @for dir in $(SUBDIRS); do cd $$dir; $(MAKE) ps || exit 1; cd ..; done
-
-clean:
- @for dir in $(SUBDIRS); do cd $$dir; $(MAKE) clean || exit 1; cd ..; done
-
-distclean:
- @for dir in $(SUBDIRS); do cd $$dir; $(MAKE) distclean || exit 1; cd ..; done
-
+++ /dev/null
-RAGEL = ../../ragel/ragel
-RLCODEGEN = ../../rlcodegen/rlcodegen
-
-all: atoi
-
-ps: atoi.ps
-
-atoi: atoi.o
- g++ -g -o atoi atoi.o
-
-atoi.cpp: atoi.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) atoi.rl | $(RLCODEGEN) -G2 -o atoi.cpp
-
-atoi.o: atoi.cpp
- g++ -Wall -g -c -O3 -o $@ $<
-
-atoi.ps: atoi.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) atoi.rl | $(RLCODEGEN) -V | dot -Tps > atoi.ps
-
-distclean clean:
- rm -Rf *.o atoi.cpp atoi atoi.ps
+++ /dev/null
-/*
- * Convert a string to an integer.
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <stdio.h>
-
-using namespace std;
-
-%%{
- machine atoi;
- write data noerror;
-}%%
-
-int atoi( char *str )
-{
- char *p = str;
- int cs, val = 0;
- bool neg = false;;
-
- %%{
- action see_neg {
- neg = true;
- }
-
- action add_digit {
- val = val * 10 + (fc - '0');
- }
-
- main :=
- ( '-'@see_neg | '+' )? ( digit @add_digit )+
- '\n' @{ fbreak; };
-
- # Inintialize and execute.
- write init;
- write exec noend;
- }%%
-
- if ( neg )
- val = -1 * val;
-
- if ( cs < atoi_first_final )
- cerr << "atoi: there was an error" << endl;
-
- return val;
-};
-
-
-#define BUFSIZE 1024
-
-int main()
-{
- char buf[BUFSIZE];
- while ( fgets( buf, sizeof(buf), stdin ) != 0 ) {
- int value = atoi( buf );
- cout << value << endl;
- }
- return 0;
-}
+++ /dev/null
-RAGEL = ../../ragel/ragel
-RLCODEGEN = ../../rlcodegen/rlcodegen
-
-all: awkemu
-
-ps: awkemu.ps
-
-awkemu: awkemu.o
- gcc -g -o awkemu awkemu.o
-
-awkemu.c: awkemu.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) awkemu.rl | $(RLCODEGEN) -G2 -o awkemu.c
-
-awkemu.ps: awkemu.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) awkemu.rl | $(RLCODEGEN) -V | dot -Tps > awkemu.ps
-
-%.o: %.c
- gcc -pedantic -Wall -g -c -O3 -o $@ $<
-
-distclean clean:
- rm -Rf *.o awkemu.c awkemu awkemu.ps
+++ /dev/null
-/*
- * Perform the basic line parsing of input performed by awk.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-%%{
- machine awkemu;
-
- action start_word {
- ws[nwords] = fpc;
- }
-
- action end_word {
- we[nwords++] = fpc;
- }
-
- action start_line {
- nwords = 0;
- ls = fpc;
- }
-
- action end_line {
- printf("endline(%i): ", nwords );
- fwrite( ls, 1, p - ls, stdout );
- printf("\n");
-
- for ( i = 0; i < nwords; i++ ) {
- printf(" word: ");
- fwrite( ws[i], 1, we[i] - ws[i], stdout );
- printf("\n");
- }
- }
-
- # Words in a line.
- word = ^[ \t\n]+;
-
- # The whitespace separating words in a line.
- whitespace = [ \t];
-
- # The components in a line to break up. Either a word or a single char of
- # whitespace. On the word capture characters.
- blineElements = word >start_word %end_word | whitespace;
-
- # Star the break line elements. Just be careful to decrement the leaving
- # priority as we don't want multiple character identifiers to be treated as
- # multiple single char identifiers.
- line = ( blineElements** '\n' ) >start_line @end_line;
-
- # Any number of lines.
- main := line*;
-}%%
-
-%% write data noerror nofinal;
-
-#define MAXWORDS 256
-#define BUFSIZE 4096
-char buf[BUFSIZE];
-
-int main()
-{
- int i, nwords = 0;
- char *ls = 0;
- char *ws[MAXWORDS];
- char *we[MAXWORDS];
-
- int cs;
- int have = 0;
-
- %% write init;
-
- while ( 1 ) {
- char *p, *pe, *data = buf + have;
- int len, space = BUFSIZE - have;
- /* fprintf( stderr, "space: %i\n", space ); */
-
- if ( space == 0 ) {
- fprintf(stderr, "buffer out of space\n");
- exit(1);
- }
-
- len = fread( data, 1, space, stdin );
- /* fprintf( stderr, "len: %i\n", len ); */
- if ( len == 0 )
- break;
-
- /* Find the last newline by searching backwards. This is where
- * we will stop processing on this iteration. */
- p = buf;
- pe = buf + have + len - 1;
- while ( *pe != '\n' && pe >= buf )
- pe--;
- pe += 1;
-
- /* fprintf( stderr, "running on: %i\n", pe - p ); */
-
- %% write exec;
-
- /* How much is still in the buffer. */
- have = data + len - pe;
- if ( have > 0 )
- memmove( buf, pe, have );
-
- /* fprintf(stderr, "have: %i\n", have ); */
-
- if ( len < space )
- break;
- }
-
- if ( have > 0 )
- fprintf(stderr, "input not newline terminated\n");
- return 0;
-}
+++ /dev/null
-#!/usr/bin/awk -f
-#
-
-
-{
- print "endline(" NF "): " $0
- for ( i = 1; i <= NF; i++ ) {
- print " word: " $i
- }
-}
+++ /dev/null
-RAGEL = ../../ragel/ragel
-RLCODEGEN = ../../rlcodegen/rlcodegen
-
-all: clang
-
-ps: clang.ps
-
-clang: clang.o
- gcc -g -o clang clang.o
-
-clang.c: clang.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) clang.rl | $(RLCODEGEN) -G2 -o clang.c
-
-clang.ps: clang.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) clang.rl | $(RLCODEGEN) -V | dot -Tps > clang.ps
-
-%.o: %.c
- gcc -pedantic -Wall -O3 -g -c -o $@ $<
-
-distclean clean:
- rm -Rf *.o clang.c clang clang.ps
+++ /dev/null
-/*
- * A mini C-like language scanner.
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-%%{
- machine clang;
-
- newline = '\n' @{curline += 1;};
- any_count_line = any | newline;
-
- # Consume a C comment.
- c_comment := any_count_line* :>> '*/' @{fgoto main;};
-
- main := |*
-
- # Alpha numberic characters or underscore.
- alnum_u = alnum | '_';
-
- # Alpha charactres or underscore.
- alpha_u = alpha | '_';
-
- # Symbols. Upon entering clear the buffer. On all transitions
- # buffer a character. Upon leaving dump the symbol.
- ( punct - [_'"] ) {
- printf( "symbol(%i): %c\n", curline, tokstart[0] );
- };
-
- # Identifier. Upon entering clear the buffer. On all transitions
- # buffer a character. Upon leaving, dump the identifier.
- alpha_u alnum_u* {
- printf( "ident(%i): ", curline );
- fwrite( tokstart, 1, tokend-tokstart, stdout );
- printf("\n");
- };
-
- # Single Quote.
- sliteralChar = [^'\\] | newline | ( '\\' . any_count_line );
- '\'' . sliteralChar* . '\'' {
- printf( "single_lit(%i): ", curline );
- fwrite( tokstart, 1, tokend-tokstart, stdout );
- printf("\n");
- };
-
- # Double Quote.
- dliteralChar = [^"\\] | newline | ( '\\' any_count_line );
- '"' . dliteralChar* . '"' {
- printf( "double_lit(%i): ", curline );
- fwrite( tokstart, 1, tokend-tokstart, stdout );
- printf("\n");
- };
-
- # Whitespace is standard ws, newlines and control codes.
- any_count_line - 0x21..0x7e;
-
- # Describe both c style comments and c++ style comments. The
- # priority bump on tne terminator of the comments brings us
- # out of the extend* which matches everything.
- '//' [^\n]* newline;
-
- '/*' { fgoto c_comment; };
-
- # Match an integer. We don't bother clearing the buf or filling it.
- # The float machine overlaps with int and it will do it.
- digit+ {
- printf( "int(%i): ", curline );
- fwrite( tokstart, 1, tokend-tokstart, stdout );
- printf("\n");
- };
-
- # Match a float. Upon entering the machine clear the buf, buffer
- # characters on every trans and dump the float upon leaving.
- digit+ '.' digit+ {
- printf( "float(%i): ", curline );
- fwrite( tokstart, 1, tokend-tokstart, stdout );
- printf("\n");
- };
-
- # Match a hex. Upon entering the hex part, clear the buf, buffer characters
- # on every trans and dump the hex on leaving transitions.
- '0x' xdigit+ {
- printf( "hex(%i): ", curline );
- fwrite( tokstart, 1, tokend-tokstart, stdout );
- printf("\n");
- };
-
- *|;
-}%%
-
-%% write data nofinal;
-
-#define BUFSIZE 128
-
-void scanner()
-{
- static char buf[BUFSIZE];
- int cs, act, have = 0, curline = 1;
- char *tokstart, *tokend = 0;
- int done = 0;
-
- %% write init;
-
- while ( !done ) {
- char *p = buf + have, *pe;
- int len, space = BUFSIZE - have;
-
- if ( space == 0 ) {
- /* We've used up the entire buffer storing an already-parsed token
- * prefix that must be preserved. */
- fprintf(stderr, "OUT OF BUFFER SPACE\n" );
- exit(1);
- }
-
- len = fread( p, 1, space, stdin );
-
- /* If this is the last buffer, tack on an EOF. */
- if ( len < space ) {
- p[len++] = 0;
- done = 1;
- }
-
- pe = p + len;
- %% write exec;
-
- if ( cs == clang_error ) {
- fprintf(stderr, "PARSE ERROR\n" );
- break;
- }
-
- if ( tokstart == 0 )
- have = 0;
- else {
- /* There is a prefix to preserve, shift it over. */
- have = pe - tokstart;
- memmove( buf, tokstart, have );
- tokend = buf + (tokend-tokstart);
- tokstart = buf;
- }
- }
-}
-
-int main()
-{
- scanner();
- return 0;
-}
-
+++ /dev/null
-RAGEL = ../../ragel/ragel
-RLCODEGEN = ../../rlcodegen/rlcodegen
-
-all: concurrent
-
-ps: concurrent.ps
-
-concurrent: concurrent.o
- g++ -g -o concurrent concurrent.o
-
-concurrent.cpp: concurrent.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) concurrent.rl | $(RLCODEGEN) -G2 -o concurrent.cpp
-
-concurrent.ps: concurrent.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) concurrent.rl | $(RLCODEGEN) -V | dot -Tps > concurrent.ps
-
-%.o: %.cpp
- g++ -Wall -g -c -O3 -o $@ $<
-
-distclean clean:
- rm -Rf *.o concurrent.cpp concurrent concurrent.ps
+++ /dev/null
-/*
- * Show off concurrent abilities.
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <stdio.h>
-
-using namespace std;
-
-#define BUFSIZE 2048
-
-struct Concurrent
-{
- int cur_char;
- int start_word;
- int start_comment;
- int start_literal;
-
- int cs;
-
- int init( );
- int execute( const char *data, int len );
- int finish( );
-};
-
-%%{
- machine Concurrent;
-
- action next_char {
- cur_char += 1;
- }
-
- action start_word {
- start_word = cur_char;
- }
- action end_word {
- cout << "word: " << start_word <<
- " " << cur_char-1 << endl;
- }
-
- action start_comment {
- start_comment = cur_char;
- }
- action end_comment {
- cout << "comment: " << start_comment <<
- " " << cur_char-1 << endl;
- }
-
- action start_literal {
- start_literal = cur_char;
- }
- action end_literal {
- cout << "literal: " << start_literal <<
- " " << cur_char-1 << endl;
- }
-
- # Count characters.
- chars = ( any @next_char )*;
-
- # Words are non-whitespace.
- word = ( any-space )+ >start_word %end_word;
- words = ( ( word | space ) $1 %0 )*;
-
- # Finds C style comments.
- comment = ( '/*' any* :>> '*/' ) >start_comment %end_comment;
- comments = ( comment | any )**;
-
- # Finds single quoted strings.
- literalChar = ( any - ['\\] ) | ( '\\' . any );
- literal = ('\'' literalChar* '\'' ) >start_literal %end_literal;
- literals = ( ( literal | (any-'\'') ) $1 %0 )*;
-
- main := chars | words | comments | literals;
-}%%
-
-%% write data;
-
-int Concurrent::init( )
-{
- %% write init;
- cur_char = 0;
- return 1;
-}
-
-int Concurrent::execute( const char *data, int len )
-{
- const char *p = data;
- const char *pe = data + len;
-
- %% write exec;
-
- if ( cs == Concurrent_error )
- return -1;
- if ( cs >= Concurrent_first_final )
- return 1;
- return 0;
-}
-
-int Concurrent::finish( )
-{
- %% write eof;
- if ( cs == Concurrent_error )
- return -1;
- if ( cs >= Concurrent_first_final )
- return 1;
- return 0;
-}
-
-Concurrent concurrent;
-char buf[BUFSIZE];
-
-int main()
-{
- concurrent.init();
- while ( 1 ) {
- int len = fread( buf, 1, BUFSIZE, stdin );
- concurrent.execute( buf, len );
- if ( len != BUFSIZE )
- break;
- }
-
- if ( concurrent.finish() <= 0 )
- cerr << "concurrent: error parsing input" << endl;
- return 0;
-}
+++ /dev/null
-RAGEL = ../../ragel/ragel
-RLCODEGEN = ../../rlcodegen/rlcodegen
-FLEX = flex
-RE2C = re2c
-
-CFLAGS = -Wall -g -O3
-
-all: cppscan lex-cppscan re2c-cppscan
-
-ps: cppscan.ps
-
-cppscan: cppscan.o
- g++ -g -o $@ $<
-
-lex-cppscan: lex-cppscan.o
- g++ -g -o $@ $<
-
-re2c-cppscan: re2c-cppscan.o
- g++ -g -o $@ $<
-
-cppscan.cpp: cppscan.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) cppscan.rl | $(RLCODEGEN) -G2 -o $@
-
-lex-cppscan.cpp: cppscan.lex
- $(FLEX) -f -o $@ $<
-
-re2c-cppscan.cpp: cppscan.rec
- $(RE2C) -s $< > $@
-
-example.cpp: example.rec
- $(RE2C) -s $< > $@
-
-%.o: %.cpp
- g++ $(CFLAGS) -c -o $@ $<
-
-cppscan.ps: cppscan.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) cppscan.rl | $(RLCODEGEN) -V | dot -Tps > cppscan.ps
-
-distclean clean:
- rm -Rf *.o cppscan.cpp cppscan cppscan.ps \
- lex-cppscan lex-cppscan.cpp re2c-cppscan re2c-cppscan.cpp
+++ /dev/null
-/*
- * flex equivalent to cppscan.rl
- */
-
-%{
-
-#include <stdio.h>
-
-#define TK_Dlit 256
-#define TK_Slit 257
-#define TK_Float 258
-#define TK_Id 259
-#define TK_NameSep 260
-#define TK_Arrow 261
-#define TK_PlusPlus 262
-#define TK_MinusMinus 263
-#define TK_ArrowStar 264
-#define TK_DotStar 265
-#define TK_ShiftLeft 266
-#define TK_ShiftRight 267
-#define TK_IntegerDecimal 268
-#define TK_IntegerOctal 269
-#define TK_IntegerHex 270
-#define TK_EqualsEquals 271
-#define TK_NotEquals 272
-#define TK_AndAnd 273
-#define TK_OrOr 274
-#define TK_MultAssign 275
-#define TK_DivAssign 276
-#define TK_PercentAssign 277
-#define TK_PlusAssign 278
-#define TK_MinusAssign 279
-#define TK_AmpAssign 280
-#define TK_CaretAssign 281
-#define TK_BarAssign 282
-#define TK_DotDotDot 283
-#define TK_Whitespace 284
-#define TK_Comment 285
-
-int line = 1, col = 1;
-
-void token( int tok, char *data, int len )
-{
- printf( "<%i> ", tok );
- for ( int i = 0; i < len; i++ )
- fputc( data[i], stdout );
- fputc( '\n', stdout );
-
- /* Count newlines and columns. This code is here mainly for having some
- * code in the token routine when commenting out the above output during
- * performance testing. */
- for ( int i = 0; i < len; i ++ ) {
- if ( data[i] == '\n' ) {
- line += 1;
- col = 1;
- }
- else {
- col += 1;
- }
- }
-}
-
-
-%}
-
-%x COMMENT
-
-FRACT_CONST [0-9]*\.[0-9]+|[0-9]+\.
-EXPONENT [eE][+\-]?[0-9]+
-FLOAT_SUFFIX [flFL]
-
-%%
-
- /* Single and double literals. */
-L?\'([^\'\\\n]|\\.)*\' {
- token( TK_Slit, yytext, yyleng );
-}
-
-L?\"([^\"\\\n]|\\.)*\" {
- token( TK_Dlit, yytext, yyleng );
-}
-
-[a-zA-Z_][a-zA-Z0-9_]* {
- token( TK_Id, yytext, yyleng );
-}
-
-{FRACT_CONST}{EXPONENT}?{FLOAT_SUFFIX}?|[0-9]+{EXPONENT}{FLOAT_SUFFIX}? {
- token( TK_Float, yytext, yyleng );
-}
-
-(0|[1-9][0-9]*)[ulUL]{0,3} {
- token( TK_IntegerDecimal, yytext, yyleng );
-}
-
-0[0-9]+[ulUL]{0,2} {
- token( TK_IntegerOctal, yytext, yyleng );
-}
-
-0x[0-9a-fA-F]+[ulUL]{0,2} {
- token( TK_IntegerHex, yytext, yyleng );
-}
-
-:: token( TK_NameSep, yytext, yyleng );
-== token( TK_EqualsEquals, yytext, yyleng );
-!= token( TK_NotEquals, yytext, yyleng );
-&& token( TK_AndAnd, yytext, yyleng );
-\|\| token( TK_OrOr, yytext, yyleng );
-\*= token( TK_MultAssign, yytext, yyleng );
-\/= token( TK_DivAssign, yytext, yyleng );
-%= token( TK_PercentAssign, yytext, yyleng );
-\+= token( TK_PlusAssign, yytext, yyleng );
--= token( TK_MinusAssign, yytext, yyleng );
-&= token( TK_AmpAssign, yytext, yyleng );
-^= token( TK_CaretAssign, yytext, yyleng );
-\|= token( TK_BarAssign, yytext, yyleng );
-\+\+ token( TK_PlusPlus, yytext, yyleng );
--- token( TK_MinusMinus, yytext, yyleng );
--> token( TK_Arrow, yytext, yyleng );
-->\* token( TK_ArrowStar, yytext, yyleng );
-\.\* token( TK_DotStar, yytext, yyleng );
-\.\.\. token( TK_DotDotDot, yytext, yyleng );
-
-\/\* BEGIN(COMMENT);
-<COMMENT>\*\/ BEGIN(INITIAL);
-<COMMENT>(.|\n) { }
-
-\/\/.*\n {}
-[^!-~]+ {}
-
-[!-/:-@\[-`{-~] token( yytext[0], yytext, yyleng );
-
-%%
-
-int yywrap()
-{
- /* Once the input is done, no more. */
- return 1;
-}
-
-int main()
-{
- yylex();
-}
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#define TK_Dlit 256
-#define TK_Slit 257
-#define TK_Float 258
-#define TK_Id 259
-#define TK_NameSep 260
-#define TK_Arrow 261
-#define TK_PlusPlus 262
-#define TK_MinusMinus 263
-#define TK_ArrowStar 264
-#define TK_DotStar 265
-#define TK_ShiftLeft 266
-#define TK_ShiftRight 267
-#define TK_IntegerDecimal 268
-#define TK_IntegerOctal 269
-#define TK_IntegerHex 270
-#define TK_EqualsEquals 271
-#define TK_NotEquals 272
-#define TK_AndAnd 273
-#define TK_OrOr 274
-#define TK_MultAssign 275
-#define TK_DivAssign 276
-#define TK_PercentAssign 277
-#define TK_PlusAssign 278
-#define TK_MinusAssign 279
-#define TK_AmpAssign 280
-#define TK_CaretAssign 281
-#define TK_BarAssign 282
-#define TK_DotDotDot 283
-#define TK_Whitespace 284
-#define TK_Comment 285
-
-int line = 1, col = 1;
-
-void token( int tok, char *data, int len )
-{
- printf( "<%i> ", tok );
- for ( int i = 0; i < len; i++ )
- fputc( data[i], stdout );
- fputc( '\n', stdout );
-
- /* Count newlines and columns. This code is here mainly for having some
- * code in the token routine when commenting out the above output during
- * performance testing. */
- for ( int i = 0; i < len; i ++ ) {
- if ( data[i] == '\n' ) {
- line += 1;
- col = 1;
- }
- else {
- col += 1;
- }
- }
-}
-
-#define BUFSIZE 8192
-char buf[BUFSIZE];
-
-void fill( int n )
-{
- printf("fill(%i)\n", n);
- exit(1);
-}
-
-int main()
-{
- char *start, *p = buf, *lim = buf, *marker;
- int len, have, want, shift;
- int done = 0;
-
-#define YYCTYPE char
-
-#define YYCURSOR p
-#define YYLIMIT lim
-#define YYMARKER marker
-
-#define YYFILL(n) { \
- if ( ! done ) { \
- have = lim-start; \
- if ( start > buf ) { \
- shift = start-buf; \
- memmove( buf, start, have ); \
- start -= shift; \
- p -= shift; \
- lim -= shift; \
- marker -= shift; \
- } \
- want = BUFSIZE - have - 1; \
- len = fread( lim, 1, want, stdin ); \
- lim += len; \
- if ( len < want ) { \
- *lim++ = 0; \
- done = 1; \
- } \
- } \
- }
-
-again:
- start = p;
-
-/*!re2c
-
-ANY = [\000-\377];
-FRACTCONST = ( [0-9]* "." [0-9]+ ) | [0-9]+ ".";
-EXPONENT = [eE] [+\-]? [0-9]+;
-FLOATSUFFIX = [flFL];
-
- "L"? "\'" ( ANY \ [\'\\\n] | "\\" ANY )* "\'" {
- token( TK_Slit, start, p-start );
- goto again;
- }
-
- "L"? "\"" ( ANY \ [\"\\\n] | "\\" ANY )* "\"" {
- token( TK_Dlit, start, p-start );
- goto again;
- }
-
- [a-zA-Z_][a-zA-Z0-9_]* {
- token( TK_Id, start, p-start );
- goto again;
- }
-
- ( FRACTCONST EXPONENT? FLOATSUFFIX? ) | ( [0-9]+ EXPONENT FLOATSUFFIX? ) {
- token( TK_Float, start, p-start );
- goto again;
- }
-
-
- ( "0" | [1-9][0-9]* ) [ulUL]* {
- token( TK_IntegerDecimal, start, p-start );
- goto again;
- }
-
- "0" [0-9]+ [ulUL]* {
- token( TK_IntegerOctal, start, p-start );
- goto again;
- }
-
- "0x" [0-9a-fA-F]+[ulUL]* {
- token( TK_IntegerHex, start, p-start );
- goto again;
- }
-
- "::" { token( TK_NameSep, start, p-start ); goto again; }
- "==" { token( TK_EqualsEquals, start, p-start ); goto again; }
- "!=" { token( TK_NotEquals, start, p-start ); goto again; }
- "&&" { token( TK_AndAnd, start, p-start ); goto again; }
- "||" { token( TK_OrOr, start, p-start ); goto again; }
- "*=" { token( TK_MultAssign, start, p-start ); goto again; }
- "/=" { token( TK_DivAssign, start, p-start ); goto again; }
- "%=" { token( TK_PercentAssign, start, p-start ); goto again; }
- "+=" { token( TK_PlusAssign, start, p-start ); goto again; }
- "-=" { token( TK_MinusAssign, start, p-start ); goto again; }
- "&=" { token( TK_AmpAssign, start, p-start ); goto again; }
- "^=" { token( TK_CaretAssign, start, p-start ); goto again; }
- "|=" { token( TK_BarAssign, start, p-start ); goto again; }
- "++" { token( TK_PlusPlus, start, p-start ); goto again; }
- "--" { token( TK_MinusMinus, start, p-start ); goto again; }
- "->" { token( TK_Arrow, start, p-start ); goto again; }
- "->*" { token( TK_ArrowStar, start, p-start ); goto again; }
- ".*" { token( TK_DotStar, start, p-start ); goto again; }
- "..." { token( TK_DotDotDot, start, p-start ); goto again; }
-
- "/*" { goto comment; }
- "//" (ANY\"\n")* "\n" { goto again; }
- [\001-\040\177]+ { goto again; }
-
- [\041-\057\072-\100\133-\140\173-\176] {
- token( *start, start, p-start );
- goto again;
- }
- "\000" { return 0; }
-*/
-
-comment:
-/*!re2c
- "*/" { goto again; }
- ANY { goto comment; }
-*/
-}
+++ /dev/null
-/*
- * A C++ scanner. Uses the longest match construction.
- * << <= <<= >> >= >>= are left out since angle brackets are used in templates.
- */
-
-#include <string.h>
-#include <stdlib.h>
-#include <iostream>
-
-#define TK_Dlit 256
-#define TK_Slit 257
-#define TK_Float 258
-#define TK_Id 259
-#define TK_NameSep 260
-#define TK_Arrow 261
-#define TK_PlusPlus 262
-#define TK_MinusMinus 263
-#define TK_ArrowStar 264
-#define TK_DotStar 265
-#define TK_ShiftLeft 266
-#define TK_ShiftRight 267
-#define TK_IntegerDecimal 268
-#define TK_IntegerOctal 269
-#define TK_IntegerHex 270
-#define TK_EqualsEquals 271
-#define TK_NotEquals 272
-#define TK_AndAnd 273
-#define TK_OrOr 274
-#define TK_MultAssign 275
-#define TK_DivAssign 276
-#define TK_PercentAssign 277
-#define TK_PlusAssign 278
-#define TK_MinusAssign 279
-#define TK_AmpAssign 280
-#define TK_CaretAssign 281
-#define TK_BarAssign 282
-#define TK_DotDotDot 283
-#define TK_Whitespace 284
-#define TK_Comment 285
-
-#define BUFSIZE 16384
-
-/* EOF char used to flush out that last token. This should be a whitespace
- * token. */
-
-#define LAST_CHAR 0
-
-using std::cerr;
-using std::cout;
-using std::cin;
-using std::endl;
-
-static char buf[BUFSIZE];
-static int line = 1, col = 1;
-static char *tokstart, *tokend;
-static int act, have = 0;
-static int cs;
-
-%%{
- machine Scanner;
- write data nofinal;
-
- # Floating literals.
- fract_const = digit* '.' digit+ | digit+ '.';
- exponent = [eE] [+\-]? digit+;
- float_suffix = [flFL];
-
- c_comment :=
- any* :>> '*/'
- @{ fgoto main; };
-
- main := |*
-
- # Single and double literals.
- ( 'L'? "'" ( [^'\\\n] | /\\./ )* "'" )
- {token( TK_Slit );};
- ( 'L'? '"' ( [^"\\\n] | /\\./ )* '"' )
- {token( TK_Dlit );};
-
- # Identifiers
- ( [a-zA-Z_] [a-zA-Z0-9_]* )
- {token( TK_Id );};
-
- # Floating literals.
- ( fract_const exponent? float_suffix? | digit+ exponent float_suffix? )
- {token( TK_Float );};
-
- # Integer decimal. Leading part buffered by float.
- ( ( '0' | [1-9] [0-9]* ) [ulUL]{0,3} )
- {token( TK_IntegerDecimal );};
-
- # Integer octal. Leading part buffered by float.
- ( '0' [0-9]+ [ulUL]{0,2} )
- {token( TK_IntegerOctal );};
-
- # Integer hex. Leading 0 buffered by float.
- ( '0' ( 'x' [0-9a-fA-F]+ [ulUL]{0,2} ) )
- {token( TK_IntegerHex );};
-
- # Only buffer the second item, first buffered by symbol. */
- '::' {token( TK_NameSep );};
- '==' {token( TK_EqualsEquals );};
- '!=' {token( TK_NotEquals );};
- '&&' {token( TK_AndAnd );};
- '||' {token( TK_OrOr );};
- '*=' {token( TK_MultAssign );};
- '/=' {token( TK_DivAssign );};
- '%=' {token( TK_PercentAssign );};
- '+=' {token( TK_PlusAssign );};
- '-=' {token( TK_MinusAssign );};
- '&=' {token( TK_AmpAssign );};
- '^=' {token( TK_CaretAssign );};
- '|=' {token( TK_BarAssign );};
- '++' {token( TK_PlusPlus );};
- '--' {token( TK_MinusMinus );};
- '->' {token( TK_Arrow );};
- '->*' {token( TK_ArrowStar );};
- '.*' {token( TK_DotStar );};
-
- # Three char compounds, first item already buffered. */
- '...' {token( TK_DotDotDot );};
-
- # Single char symbols.
- ( punct - [_"'] ) {token( tokstart[0] );};
-
- # Comments and whitespace.
- '/*' { fgoto c_comment; };
- '//' [^\n]* '\n';
- ( any - 33..126 )+;
-
- *|;
-}%%
-
-void token( int tok )
-{
- char *data = tokstart;
- int len = tokend - tokstart;
-
- cout << '<' << tok << "> ";
- cout.write( data, len );
- cout << '\n';
-
- /* Count newlines and columns. This code is here mainly for having some
- * code in the token routine when commenting out the above output during
- * performance testing. */
- for ( int i = 0; i < len; i ++ ) {
- if ( data[i] == '\n' ) {
- line += 1;
- col = 1;
- }
- else {
- col += 1;
- }
- }
-}
-
-int main()
-{
- std::ios::sync_with_stdio(false);
-
- %% write init;
-
- /* Do the first read. */
- bool done = false;
- while ( !done ) {
- char *p = buf + have;
- int space = BUFSIZE - have;
-
- if ( space == 0 ) {
- /* We filled up the buffer trying to scan a token. */
- cerr << "OUT OF BUFFER SPACE" << endl;
- exit(1);
- }
-
- cin.read( p, space );
- int len = cin.gcount();
-
- /* If we see eof then append the EOF char. */
- if ( len == 0 ) {
- p[0] = LAST_CHAR, len++;
- done = true;
- }
-
- char *pe = p + len;
- %% write exec;
-
- /* Check if we failed. */
- if ( cs == Scanner_error ) {
- /* Machine failed before finding a token. */
- cerr << "PARSE ERROR" << endl;
- exit(1);
- }
-
- /* Now set up the prefix. */
- if ( tokstart == 0 )
- have = 0;
- else {
- /* There is data that needs to be shifted over. */
- have = pe - tokstart;
- memmove( buf, tokstart, have );
- tokend -= (tokstart-buf);
- tokstart = buf;
- }
- }
-
- return 0;
-}
+++ /dev/null
-RAGEL = ../../ragel/ragel
-RLCODEGEN = ../../rlcodegen/rlcodegen
-
-all: format
-
-ps: format.ps
-
-format: format.o
- gcc -g -o format format.o
-
-format.c: format.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) format.rl | $(RLCODEGEN) -G2 -o format.c
-
-format.ps: format.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) format.rl | $(RLCODEGEN) -V | dot -Tps > format.ps
-
-%.o: %.c
- gcc -Wall -O3 -g -c -o $@ $<
-
-distclean clean:
- rm -Rf *.o format.c format format.ps
+++ /dev/null
-/*
- * Partial printf implementation.
- */
-
-#define BUFLEN 1024
-#include <stdio.h>
-
-typedef void (*WriteFunc)( char *data, int len );
-
-struct format
-{
- char buf[BUFLEN+1];
- int buflen;
- WriteFunc write;
-
- int flags;
- int width;
- int prec;
- int cs;
-};
-
-void do_conv( struct format *fsm, char c )
-{
- printf( "flags: %x\n", fsm->flags );
- printf( "width: %i\n", fsm->width );
- printf( "prec: %i\n", fsm->prec );
- printf( "conv: %c\n", c );
- printf( "\n" );
-}
-
-#define FL_HASH 0x01
-#define FL_ZERO 0x02
-#define FL_DASH 0x04
-#define FL_SPACE 0x08
-#define FL_PLUS 0x10
-
-#define FL_HAS_WIDTH 0x0100
-#define FL_WIDTH_ARG 0x0200
-#define FL_HAS_PREC 0x0400
-#define FL_PREC_ARG 0x0800
-
-#define FL_LEN_H 0x010000
-#define FL_LEN_HH 0x020000
-#define FL_LEN_L 0x040000
-#define FL_LEN_LL 0x080000
-
-%%{
- machine format;
- access fsm->;
-
- action clear {
- fsm->flags = 0;
- fsm->width = 0;
- fsm->prec = 0;
- }
-
- # A non-zero number.
- nznum = [1-9] [0-9]*;
-
- # Width
- action width_num { fsm->width = 10 * fsm->width + (fc-'0'); }
- action width_arg { fsm->flags |= FL_WIDTH_ARG; }
- action width { fsm->flags |= FL_HAS_WIDTH; }
- width = ( ( nznum $width_num | '*' @width_arg ) %width )?;
-
- # Precision
- action prec_num { fsm->prec = 10 * fsm->prec + (fc-'0'); }
- action prec_arg { fsm->flags |= FL_PREC_ARG; }
- action prec { fsm->flags |= FL_HAS_PREC; }
- precision = ( '.' ( digit* $prec_num %prec | '*' @prec_arg ) )?;
-
- # Flags
- action flags_hash { fsm->flags |= FL_HASH; }
- action flags_zero { fsm->flags |= FL_ZERO; }
- action flags_dash { fsm->flags |= FL_DASH; }
- action flags_space { fsm->flags |= FL_SPACE; }
- action flags_plus { fsm->flags |= FL_PLUS; }
-
- flags = (
- '#' @flags_hash |
- '0' @flags_zero |
- '-' @flags_dash |
- ' ' @flags_space |
- '+' @flags_plus )*;
-
- action length_h { fsm->flags |= FL_LEN_H; }
- action length_l { fsm->flags |= FL_LEN_L; }
- action length_hh { fsm->flags |= FL_LEN_HH; }
- action length_ll { fsm->flags |= FL_LEN_LL; }
-
- # Must use leaving transitions on 'h' and 'l' because they are
- # prefixes for 'hh' and 'll'.
- length = (
- 'h' %length_h |
- 'l' %length_l |
- 'hh' @length_hh |
- 'll' @length_ll )?;
-
- action conversion {
- do_conv( fsm, fc );
- }
-
- conversion = [diouxXcsp] @conversion;
-
- fmt_spec =
- '%' @clear
- flags
- width
- precision
- length
- conversion;
-
- action emit {
- if ( fsm->buflen == BUFLEN ) {
- fsm->write( fsm->buf, fsm->buflen );
- fsm->buflen = 0;
- }
- fsm->buf[fsm->buflen++] = fc;
- }
-
- action finish_ok {
- if ( fsm->buflen > 0 )
- fsm->write( fsm->buf, fsm->buflen );
- }
- action finish_err {
- printf("EOF IN FORMAT\n");
- }
- action err_char {
- printf("ERROR ON CHAR: 0x%x\n", fc );
- }
-
- main := (
- [^%] @emit |
- '%%' @emit |
- fmt_spec
- )* @/finish_err %/finish_ok $!err_char;
-}%%
-
-%% write data;
-
-void format_init( struct format *fsm )
-{
- fsm->buflen = 0;
- %% write init;
-}
-
-void format_execute( struct format *fsm, const char *data, int len )
-{
- const char *p = data;
- const char *pe = data + len;
-
- %% write exec;
-}
-
-int format_finish( struct format *fsm )
-{
- %% write eof;
-
- if ( fsm->cs == format_error )
- return -1;
- if ( fsm->cs >= format_first_final )
- return 1;
- return 0;
-}
-
-
-#define INPUT_BUFSIZE 2048
-
-struct format fsm;
-char buf[INPUT_BUFSIZE];
-
-void write(char *data, int len )
-{
- fwrite( data, 1, len, stdout );
-}
-
-int main()
-{
- fsm.write = write;
- format_init( &fsm );
- while ( 1 ) {
- int len = fread( buf, 1, INPUT_BUFSIZE, stdin );
- format_execute( &fsm, buf, len );
- if ( len != INPUT_BUFSIZE )
- break;
- }
- if ( format_finish( &fsm ) <= 0 )
- printf("FAIL\n");
- return 0;
-}
-
+++ /dev/null
-RAGEL = ../../ragel/ragel
-RLCODEGEN = ../../rlcodegen/rlcodegen
-
-all: gotocallret
-
-ps: gotocallret.ps
-
-gotocallret: gotocallret.o
- g++ -g -o gotocallret gotocallret.o
-
-gotocallret.cpp: gotocallret.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) gotocallret.rl | $(RLCODEGEN) -G2 -o gotocallret.cpp
-
-gotocallret.o: gotocallret.cpp
- g++ -Wall -g -c -O3 -o $@ $<
-
-gotocallret.ps: gotocallret.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) gotocallret.rl | $(RLCODEGEN) -V | dot -Tps > gotocallret.ps
-
-distclean clean:
- rm -Rf *.o gotocallret.cpp gotocallret gotocallret.ps
+++ /dev/null
-/*
- * Demonstrate the use of goto, call and return. This machine expects either a
- * lower case char or a digit as a command then a space followed by the command
- * arg. If the command is a char, then the arg must be an a string of chars.
- * If the command is a digit, then the arg must be a string of digits. This
- * choice is determined by action code, rather than though transition
- * desitinations.
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <stdio.h>
-
-using namespace std;
-
-struct GotoCallRet
-{
- char comm;
- int cs, top, stack[32];
-
- int init( );
- int execute( const char *data, int len );
- int finish( );
-};
-
-%%{
- machine GotoCallRet;
-
- # Error machine, consumes to end of
- # line, then starts the main line over.
- garble_line := (
- (any-'\n')*'\n'
- ) >{cout << "error: garbling line" << endl;} @{fgoto main;};
-
- # Look for a string of alphas or of digits,
- # on anything else, hold the character and return.
- alp_comm := alpha+ $!{fhold;fret;};
- dig_comm := digit+ $!{fhold;fret;};
-
- # Choose which to machine to call into based on the command.
- action comm_arg {
- if ( comm >= 'a' )
- fcall alp_comm;
- else
- fcall dig_comm;
- }
-
- # Specifies command string. Note that the arg is left out.
- command = (
- [a-z0-9] @{comm = fc;} ' ' @comm_arg '\n'
- ) @{cout << "correct command" << endl;};
-
- # Any number of commands. If there is an
- # error anywhere, garble the line.
- main := command* $!{fhold;fgoto garble_line;};
-}%%
-
-%% write data;
-
-int GotoCallRet::init( )
-{
- %% write init;
- return 1;
-}
-
-int GotoCallRet::execute( const char *data, int len )
-{
- const char *p = data;
- const char *pe = data + len;
-
- %% write exec;
- if ( cs == GotoCallRet_error )
- return -1;
- if ( cs >= GotoCallRet_first_final )
- return 1;
- return 0;
-}
-
-int GotoCallRet::finish( )
-{
- %% write eof;
- if ( cs == GotoCallRet_error )
- return -1;
- if ( cs >= GotoCallRet_first_final )
- return 1;
- return 0;
-}
-
-#define BUFSIZE 1024
-
-int main()
-{
- char buf[BUFSIZE];
-
- GotoCallRet gcr;
- gcr.init();
- while ( fgets( buf, sizeof(buf), stdin ) != 0 ) {
- gcr.execute( buf, strlen(buf) );
- }
- if ( gcr.finish() <= 0 )
- cerr << "gotocallret: error: parsing input" << endl;
- return 0;
-}
+++ /dev/null
-RAGEL = ../../ragel/ragel
-RLCODEGEN = ../../rlcodegen/rlcodegen
-
-all: mailbox
-
-mailbox: mailbox.o
- g++ -g -o mailbox mailbox.o
-
-mailbox.cpp: mailbox.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) mailbox.rl | $(RLCODEGEN) -G2 -o mailbox.cpp
-
-%.o: %.cpp
- g++ -Wall -g -c -O3 -o $@ $<
-
-distclean clean:
- rm -Rf *.o mailbox.cpp mailbox mailbox.ps
+++ /dev/null
-/*
- * Parses unix mail boxes into headers and bodies.
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <stdio.h>
-
-using namespace std;
-
-#define BUFSIZE 2048
-
-/* A growable buffer for collecting headers. */
-struct Buffer
-{
- Buffer() : data(0), allocated(0), length(0) { }
- ~Buffer() { empty(); }
-
- void append( char p ) {
- if ( ++length > allocated )
- upAllocate( length*2 );
- data[length-1] = p;
- }
-
- void clear() { length = 0; }
- void upAllocate( int len );
- void empty();
-
- char *data;
- int allocated;
- int length;
-};
-
-
-struct MailboxScanner
-{
- Buffer headName;
- Buffer headContent;
-
- int cs, top, stack[1];
-
- int init( );
- int execute( const char *data, int len );
- int finish( );
-};
-
-%%{
- machine MailboxScanner;
-
- # Buffer the header names.
- action bufHeadName { headName.append(fc); }
-
- # Prints a blank line after the end of the headers of each message.
- action blankLine { cout << endl; }
-
- # Helpers we will use in matching the date section of the from line.
- day = /[A-Z][a-z][a-z]/;
- month = /[A-Z][a-z][a-z]/;
- year = /[0-9][0-9][0-9][0-9]/;
- time = /[0-9][0-9]:[0-9][0-9]/ . ( /:[0-9][0-9]/ | '' );
- letterZone = /[A-Z][A-Z][A-Z]/;
- numZone = /[+\-][0-9][0-9][0-9][0-9]/;
- zone = letterZone | numZone;
- dayNum = /[0-9 ][0-9]/;
-
- # These are the different formats of the date minus an obscure
- # type that has a funny string 'remote from xxx' on the end. Taken
- # from c-client in the imap-2000 distribution.
- date = day . ' ' . month . ' ' . dayNum . ' ' . time . ' ' .
- ( year | year . ' ' . zone | zone . ' ' . year );
-
- # From lines separate messages. We will exclude fromLine from a message
- # body line. This will cause us to stay in message line up until an
- # entirely correct from line is matched.
- fromLine = 'From ' . (any-'\n')* . ' ' . date . '\n';
-
- # The types of characters that can be used as a header name.
- hchar = print - [ :];
-
- # Simply eat up an uninteresting header. Return at the first non-ws
- # character following a newline.
- consumeHeader := (
- [^\n] |
- '\n' [ \t] |
- '\n' [^ \t] @{fhold; fret;}
- )*;
-
- action hchar {headContent.append(fc);}
- action hspace {headContent.append(' ');}
-
- action hfinish {
- headContent.append(0);
- cout << headContent.data << endl;
- headContent.clear();
- fhold;
- fret;
- }
-
- # Display the contents of a header as it is consumed. Collapses line
- # continuations to a single space.
- printHeader := (
- [^\n] @hchar |
- ( '\n' ( [ \t]+ '\n' )* [ \t]+ ) %hspace
- )** $!hfinish;
-
- action onHeader
- {
- headName.append(0);
- if ( strcmp( headName.data, "From" ) == 0 ||
- strcmp( headName.data, "To" ) == 0 ||
- strcmp( headName.data, "Subject" ) == 0 )
- {
- /* Print the header name, then jump to a machine the will display
- * the contents. */
- cout << headName.data << ":";
- headName.clear();
- fcall printHeader;
- }
-
- headName.clear();
- fcall consumeHeader;
- }
-
- header = hchar+ $bufHeadName ':' @onHeader;
-
- # Exclude fromLine from a messageLine, otherwise when encountering a
- # fromLine we will be simultaneously matching the old message and a new
- # message.
- messageLine = ( [^\n]* '\n' - fromLine );
-
- # An entire message.
- message = ( fromLine . header* . '\n' @blankLine . messageLine* );
-
- # File is a series of messages.
- main := message*;
-}%%
-
-%% write data;
-
-int MailboxScanner::init( )
-{
- %% write init;
- return 1;
-}
-
-int MailboxScanner::execute( const char *data, int len )
-{
- const char *p = data;
- const char *pe = data + len;
-
- %% write exec;
-
- if ( cs == MailboxScanner_error )
- return -1;
- if ( cs >= MailboxScanner_first_final )
- return 1;
- return 0;
-}
-
-int MailboxScanner::finish( )
-{
- %% write eof;
- if ( cs == MailboxScanner_error )
- return -1;
- if ( cs >= MailboxScanner_first_final )
- return 1;
- return 0;
-}
-
-
-void Buffer::empty()
-{
- if ( data != 0 ) {
- free( data );
-
- data = 0;
- length = 0;
- allocated = 0;
- }
-}
-
-void Buffer::upAllocate( int len )
-{
- if ( data == 0 )
- data = (char*) malloc( len );
- else
- data = (char*) realloc( data, len );
- allocated = len;
-}
-
-MailboxScanner mailbox;
-char buf[BUFSIZE];
-
-int main()
-{
- mailbox.init();
- while ( 1 ) {
- int len = fread( buf, 1, BUFSIZE, stdin );
- mailbox.execute( buf, len );
- if ( len != BUFSIZE )
- break;
- }
- if ( mailbox.finish() <= 0 )
- cerr << "mailbox: error parsing input" << endl;
- return 0;
-}
+++ /dev/null
-RAGEL = ../../ragel/ragel
-RLCODEGEN = ../../rlcodegen/rlcodegen
-
-all: params
-
-ps: params.ps
-
-params: params.o
- gcc -g -o params params.o
-
-params.c: params.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) params.rl | $(RLCODEGEN) -G2 -o params.c
-
-params.ps: params.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) params.rl | $(RLCODEGEN) -V | dot -Tps > params.ps
-
-%.o: %.c
- gcc -Wall -O3 -g -c -o $@ $<
-
-distclean clean:
- rm -Rf *.o params.c params params.ps
+++ /dev/null
-/*
- * Parse command line arguments.
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#define BUFLEN 1024
-
-struct params
-{
- char buffer[BUFLEN+1];
- int buflen;
- int cs;
-};
-
-%%{
- machine params;
- access fsm->;
-
- # A buffer to collect argurments
-
- # Append to the buffer.
- action append {
- if ( fsm->buflen < BUFLEN )
- fsm->buffer[fsm->buflen++] = fc;
- }
-
- # Terminate a buffer.
- action term {
- if ( fsm->buflen < BUFLEN )
- fsm->buffer[fsm->buflen++] = 0;
- }
-
- # Clear out the buffer
- action clear { fsm->buflen = 0; }
-
- action help { printf("help\n"); }
- action version { printf("version\n"); }
- action output { printf("output: \"%s\"\n", fsm->buffer); }
- action spec { printf("spec: \"%s\"\n", fsm->buffer); }
- action mach { printf("machine: \"%s\"\n", fsm->buffer); }
-
- # Helpers that collect strings
- string = [^\0]+ >clear $append %term;
-
- # Different arguments.
- help = ( '-h' | '-H' | '-?' | '--help' ) 0 @help;
- version = ( '-v' | '--version' ) 0 @version;
- output = '-o' 0? string 0 @output;
- spec = '-S' 0? string 0 @spec;
- mach = '-M' 0? string 0 @mach;
-
- main := (
- help |
- version |
- output |
- spec |
- mach
- )*;
-}%%
-
-%% write data;
-
-void params_init( struct params *fsm )
-{
- fsm->buflen = 0;
- %% write init;
-}
-
-void params_execute( struct params *fsm, const char *data, int len )
-{
- const char *p = data;
- const char *pe = data + len;
-
- %% write exec;
-}
-
-int params_finish( struct params *fsm )
-{
- %% write eof;
-
- if ( fsm->cs == params_error )
- return -1;
- if ( fsm->cs >= params_first_final )
- return 1;
- return 0;
-}
-
-#define BUFSIZE 2048
-
-int main( int argc, char **argv )
-{
- int a;
- struct params params;
-
- params_init( ¶ms );
- for ( a = 1; a < argc; a++ )
- params_execute( ¶ms, argv[a], strlen(argv[a])+1 );
- if ( params_finish( ¶ms ) != 1 )
- fprintf( stderr, "params: error processing arguments\n" );
-
- return 0;
-}
+++ /dev/null
-RAGEL = ../../ragel/ragel
-RLCODEGEN = ../../rlcodegen/rlcodegen
-
-CFLAGS = -Wall -g -O3
-
-all: pullscan
-
-ps: pullscan.ps
-
-pullscan: pullscan.o
- g++ -g -o $@ $<
-
-pullscan.c: pullscan.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) pullscan.rl | $(RLCODEGEN) -G2 -o $@
-
-%.o: %.c
- gcc $(CFLAGS) -c -o $@ $<
-
-pullscan.ps: pullscan.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) pullscan.rl | $(RLCODEGEN) -V | dot -Tps > pullscan.ps
-
-distclean clean:
- rm -Rf *.o pullscan.c pullscan pullscan.ps
+++ /dev/null
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define BUFSIZE 4096
-
-typedef struct _Scanner {
- /* Scanner state. */
- int cs;
- int act;
- int have;
- int curline;
- char *tokstart;
- char *tokend;
- char *p;
- char *pe;
- FILE *file;
- int done;
-
- /* Token data */
- char *data;
- int len;
- int value;
-
- char buf[BUFSIZE];
-} Scanner;
-
-
-void scan_init( Scanner *s, FILE *file )
-{
- memset (s, '\0', sizeof(Scanner));
- s->curline = 1;
- s->file = file;
-}
-
-#define TK_NO_TOKEN (-1)
-#define TK_ERR 128
-#define TK_EOF 129
-#define TK_Identifier 130
-#define TK_Number 131
-
-
-%%{
- machine Scanner;
- write data;
-}%%
-
-#define ret_tok( _tok ) token = _tok; s->data = s->tokstart
-
-int scan( Scanner *s )
-{
- char *p = s->p;
- char *pe = s->pe;
- int token = TK_NO_TOKEN;
- int space, readlen;
-
- while ( 1 ) {
- if ( p == pe ) {
- printf("scanner: need more data\n");
-
- if ( s->tokstart == 0 )
- s->have = 0;
- else {
- /* There is data that needs to be shifted over. */
- printf("scanner: buffer broken mid token\n");
- s->have = pe - s->tokstart;
- memmove( s->buf, s->tokstart, s->have );
- s->tokend -= (s->tokstart-s->buf);
- s->tokstart = s->buf;
- }
-
- p = s->buf + s->have;
- space = BUFSIZE - s->have;
-
- if ( space == 0 ) {
- /* We filled up the buffer trying to scan a token. */
- printf("scanner: out of buffer space\n");
- return TK_ERR;
- }
-
- if ( s->done ) {
- printf("scanner: end of file\n");
- p[0] = 0;
- readlen = 1;
- }
- else {
- readlen = fread( p, 1, space, s->file );
- if ( readlen < space )
- s->done = 1;
- }
-
- pe = p + readlen;
- }
-
- %%{
- machine Scanner;
- access s->;
-
- main := |*
-
- # Identifiers
- ( [a-zA-Z_] [a-zA-Z0-9_]* ) =>
- { ret_tok( TK_Identifier ); fbreak; };
-
- # Whitespace
- [ \t\n];
-
- # Number
- digit+ =>
- { ret_tok( TK_Number ); fbreak; };
-
- # EOF
- 0 =>
- { ret_tok( TK_EOF ); fbreak; };
-
- # Anything else
- any =>
- { ret_tok( *p ); fbreak; };
-
- *|;
-
- write exec;
- }%%
-
- if ( s->cs == Scanner_error )
- return TK_ERR;
-
- if ( token != TK_NO_TOKEN ) {
- /* Save p and pe. fbreak does not advance p. */
- s->p = p + 1;
- s->pe = pe;
- s->len = s->p - s->data;
- return token;
- }
- }
-}
-
-
-int main (int argc, char** argv)
-{
- Scanner ss;
- int tok;
-
- scan_init(&ss, stdin);
-
- while ( 1 ) {
- tok = scan (&ss);
- if ( tok == TK_EOF ) {
- printf ("parser: EOF\n");
- break;
- }
- else if ( tok == TK_ERR ) {
- printf ("parser: ERR\n");
- break;
- }
- else {
- printf ("parser: %d \"", tok);
- fwrite ( ss.data, 1, ss.len, stdout );
- printf ("\"\n" );
- }
- }
-
- return 0;
-}
-
-
+++ /dev/null
-RAGEL = ../../ragel/ragel
-RLCODEGEN = ../../rlcodegen/rlcodegen
-
-all: rlscan
-
-ps: rlscan.ps
-
-rlscan: rlscan.o
- g++ -g -o rlscan rlscan.o
-
-rlscan.cpp: rlscan.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) rlscan.rl | $(RLCODEGEN) -G2 -o rlscan.cpp
-
-%.o: %.cpp
- g++ -Wall -g -c -O3 -o $@ $<
-
-rlscan.ps: rlscan.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) rlscan.rl | $(RLCODEGEN) -V | dot -Tps > rlscan.ps
-
-distclean clean:
- rm -Rf *.o rlscan.cpp rlscan rlscan.ps
+++ /dev/null
-/*
- * Lexes Ragel input files.
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <stdio.h>
-
-using namespace std;
-
-void escapeXML( char *data )
-{
- while ( *data != 0 ) {
- switch ( *data ) {
- case '<': cout << "<"; break;
- case '>': cout << ">"; break;
- case '&': cout << "&"; break;
- default: cout << *data; break;
- }
- data += 1;
- }
-}
-
-void escapeXML( char c )
-{
- switch ( c ) {
- case '<': cout << "<"; break;
- case '>': cout << ">"; break;
- case '&': cout << "&"; break;
- default: cout << c; break;
- }
-}
-
-void escapeXML( char *data, int len )
-{
- for ( char *end = data + len; data != end; data++ ) {
- switch ( *data ) {
- case '<': cout << "<"; break;
- case '>': cout << ">"; break;
- case '&': cout << "&"; break;
- default: cout << *data; break;
- }
- }
-}
-
-inline void write( char *data )
-{
- cout << data;
-}
-
-inline void write( char c )
-{
- cout << c;
-}
-
-inline void write( char *data, int len )
-{
- cout.write( data, len );
-}
-
-
-%%{
- machine RagelScan;
-
- word = [a-zA-Z_][a-zA-Z_0-9]*;
- integer = [0-9]+;
- hex = '0x' [0-9a-fA-F] [0-9a-fA-F]*;
-
- default = ^0;
- EOF = 0;
-
- # Handles comments in outside code and inline blocks.
- c_comment :=
- ( default* :>> '*/' )
- ${ escapeXML( fc ); }
- @{ fret; };
-
- action emit {
- escapeXML( tokstart, tokend-tokstart );
- }
-
- #
- # Inline action code
- #
-
- ilscan := |*
-
- "'" ( [^'\\] | /\\./ )* "'" => emit;
- '"' ( [^"\\] | /\\./ )* '"' => emit;
- '/*' {
- write( "/*" );
- fcall c_comment;
- };
- '//' [^\n]* '\n' => emit;
-
- '{' {
- write( '{' );
- inline_depth += 1;
- };
-
- '}' {
- write( '}' );
- /* If dropping down to the last } then return
- * to ragel code. */
- if ( --inline_depth == 0 ) {
- write( "</inline>\n" );
- fgoto rlscan;
- }
- };
-
- default => { escapeXML( *tokstart ); };
- *|;
-
- #
- # Ragel Tokens
- #
-
- rlscan := |*
- '}%%' {
- if ( !single_line ) {
- write( "</section>\n" );
- fgoto main;
- }
- };
-
- '\n' {
- if ( single_line ) {
- write( "</section>\n" );
- fgoto main;
- }
- };
-
- # Word
- word {
- write( "<word>" );
- write( tokstart, tokend-tokstart );
- write( "</word>\n" );
- };
-
- # Decimal integer.
- integer {
- write( "<int>" );
- write( tokstart, tokend-tokstart );
- write( "</int>\n" );
- };
-
- # Hexidecimal integer.
- hex {
- write( "<hex>" );
- write( tokstart, tokend-tokstart );
- write( "</hex>\n" );
- };
-
- # Consume comments.
- '#' [^\n]* '\n';
-
- # Single literal string.
- "'" ( [^'\\] | /\\./ )* "'" {
- write( "<single_lit>" );
- escapeXML( tokstart, tokend-tokstart );
- write( "</single_lit>\n" );
- };
-
- # Double literal string.
- '"' ( [^"\\] | /\\./ )* '"' {
- write( "<double_lit>" );
- escapeXML( tokstart, tokend-tokstart );
- write( "</double_lit>\n" );
- };
-
- # Or literal.
- '[' ( [^\]\\] | /\\./ )* ']' {
- write( "<or_lit>" );
- escapeXML( tokstart, tokend-tokstart );
- write( "</or_lit>\n" );
- };
-
- # Regex Literal.
- '/' ( [^/\\] | /\\./ ) * '/' {
- write( "<re_lit>" );
- escapeXML( tokstart, tokend-tokstart );
- write( "</re_lit>\n" );
- };
-
- # Open an inline block
- '{' {
- inline_depth = 1;
- write( "<inline>{" );
- fgoto ilscan;
- };
-
- punct {
- write( "<symbol>" );
- escapeXML( fc );
- write( "</symbol>\n" );
- };
-
- default;
- *|;
-
- #
- # Outside code.
- #
-
- main := |*
-
- "'" ( [^'\\] | /\\./ )* "'" => emit;
- '"' ( [^"\\] | /\\./ )* '"' => emit;
-
- '/*' {
- escapeXML( tokstart, tokend-tokstart );
- fcall c_comment;
- };
-
- '//' [^\n]* '\n' => emit;
-
- '%%{' {
- write( "<section>\n" );
- single_line = false;
- fgoto rlscan;
- };
-
- '%%' {
- write( "<section>\n" );
- single_line = true;
- fgoto rlscan;
- };
-
- default {
- escapeXML( *tokstart );
- };
-
- # EOF.
- EOF;
- *|;
-}%%
-
-%% write data nofinal;
-
-#define BUFSIZE 2048
-
-int main()
-{
- std::ios::sync_with_stdio(false);
-
- int cs, act;
- char *tokstart, *tokend;
- int stack[1], top;
-
- static char inbuf[BUFSIZE];
- bool single_line = false;
- int inline_depth = 0;
-
- %% write init;
-
- bool done = false;
- int have = 0;
- while ( !done ) {
- /* How much space is in the buffer? */
- int space = BUFSIZE - have;
- if ( space == 0 ) {
- /* Buffer is full. */
- cerr << "TOKEN TOO BIG" << endl;
- exit(1);
- }
-
- /* Read in a block. */
- char *p = inbuf + have;
- cin.read( p, space );
- int len = cin.gcount();
-
- /* Check for EOF. */
- if ( len == 0 ) {
- p[0] = 0, len++;
- done = true;
- }
-
- char *pe = p + len;
- %% write exec;
-
- if ( cs == RagelScan_error ) {
- /* Machine failed before finding a token. */
- cerr << "PARSE ERROR" << endl;
- exit(1);
- }
-
- if ( tokstart == 0 )
- have = 0;
- else {
- /* There is a prefix to preserve, shift it over. */
- have = pe - tokstart;
- memmove( inbuf, tokstart, have );
- tokend = inbuf + (tokend-tokstart);
- tokstart = inbuf;
- }
- }
- return 0;
-}
+++ /dev/null
-RAGEL = ../../ragel/ragel
-RLCODEGEN = ../../rlcodegen/rlcodegen
-
-all: statechart
-
-ps: statechart.ps
-
-statechart: statechart.o
- g++ -g -o statechart statechart.o
-
-statechart.cpp: statechart.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) statechart.rl | $(RLCODEGEN) -G2 -o statechart.cpp
-
-statechart.o: statechart.cpp
- g++ -Wall -g -c -O3 -o $@ $<
-
-statechart.ps: statechart.rl $(RAGEL) $(RLCODEGEN)
- $(RAGEL) statechart.rl | $(RLCODEGEN) -V | dot -Tps > statechart.ps
-
-distclean clean:
- rm -Rf *.o statechart.cpp statechart statechart.ps
+++ /dev/null
-/*
- * Demonstrate the use of labels, the epsilon operator, and the join operator
- * for creating machines using the named state and transition list paradigm.
- * This implementes the same machine as the atoi example.
- */
-
-#include <iostream>
-#include <stdlib.h>
-#include <stdio.h>
-
-using namespace std;
-
-struct StateChart
-{
- bool neg;
- int val;
- int cs;
-
- int init( );
- int execute( const char *data, int len );
- int finish( );
-};
-
-%%{
- machine StateChart;
-
- action begin {
- neg = false;
- val = 0;
- }
-
- action see_neg {
- neg = true;
- }
-
- action add_digit {
- val = val * 10 + (fc - '0');
- }
-
- action finish {
- if ( neg )
- val = -1 * val;
- }
-
- atoi = (
- start: (
- '-' @see_neg ->om_num |
- '+' ->om_num |
- [0-9] @add_digit ->more_nums
- ),
-
- # One or more nums.
- om_num: (
- [0-9] @add_digit ->more_nums
- ),
-
- # Zero ore more nums.
- more_nums: (
- [0-9] @add_digit ->more_nums |
- '' -> final
- )
- ) >begin %finish;
-
- main := ( atoi '\n' @{ cout << val << endl; } )*;
-}%%
-
-%% write data;
-
-int StateChart::init( )
-{
- %% write init;
- return 1;
-}
-
-int StateChart::execute( const char *data, int len )
-{
- const char *p = data;
- const char *pe = data + len;
-
- %% write exec;
-
- if ( cs == StateChart_error )
- return -1;
- if ( cs >= StateChart_first_final )
- return 1;
- return 0;
-}
-
-int StateChart::finish( )
-{
- %% write eof;
- if ( cs == StateChart_error )
- return -1;
- if ( cs >= StateChart_first_final )
- return 1;
- return 0;
-}
-
-
-#define BUFSIZE 1024
-
-int main()
-{
- char buf[BUFSIZE];
-
- StateChart atoi;
- atoi.init();
- while ( fgets( buf, sizeof(buf), stdin ) != 0 ) {
- atoi.execute( buf, strlen(buf) );
- }
- if ( atoi.finish() <= 0 )
- cerr << "statechart: error: parsing input" << endl;
- return 0;
-}
+++ /dev/null
-%%{
- machine uri;
-
- action scheme {}
- action loc {}
- action item {}
- action query {}
- action last {}
- action nothing {}
-
- main :=
- # Scheme machine. This is ambiguous with the item machine. We commit
- # to the scheme machine on colon.
- ( [^:/?#]+ ':' @(colon,1) @scheme )?
-
- # Location machine. This is ambiguous with the item machine. We remain
- # ambiguous until a second slash, at that point and all points after
- # we place a higher priority on staying in the location machine over
- # moving into the item machine.
- ( ( '/' ( '/' [^/?#]* ) $(loc,1) ) %loc %/loc )?
-
- # Item machine. Ambiguous with both scheme and location, which both
- # get a higher priority on the characters causing ambiguity.
- ( ( [^?#]+ ) $(loc,0) $(colon,0) %item %/item )?
-
- # Last two components, the characters that initiate these machines are
- # not supported in any previous components, therefore there are no
- # ambiguities introduced by these parts.
- ( '?' [^#]* %query %/query)?
- ( '#' any* %/last )?;
-}%%
+++ /dev/null
-Summary: Ragel State Machine Compiler
-Name: ragel
-Version: 5.16
-Release: 1
-
-URL: http://www.cs.queensu.ca/home/thurston/ragel/
-Vendor: Adrian Thurston
-Packager: Adrian Thurston
-Distribution: Any
-Group: Development/Other
-License: GPL
-
-Source0: http://www.cs.queensu.ca/home/thurston/ragel/%{name}-%{version}.tar.gz
-
-Prefix: /usr
-BuildRoot: %_tmppath/%name-%version-root
-BuildPreReq: gcc, make
-
-%description
-Ragel compiles finite state machines from regular languages into executable C,
-C++, Objective-C or D code. Ragel state machines can not only recognize byte
-sequences as regular expression machines do, but can also execute code at
-arbitrary points in the recognition of a regular language. Using custom
-operators, Ragel allows the user to embed code into a regular language in
-arbitrary places without disrupting the regular language syntax. Ragel also
-provides operators for controlling nondeterminism, constructing machines using
-state charts and building scanners.
-
-%prep
-%setup -q -n %{name}-%{version}
-
-%build
-./configure --prefix=%{prefix}
-make CFLAGS="-O2 -Wall"
-cd doc && make ragel.1 rlcodegen.1
-
-%install
-# Rather than 'make install', let RPM choose where
-# things are kept on this system:
-install -d $RPM_BUILD_ROOT%_bindir
-install -s ragel/ragel $RPM_BUILD_ROOT%_bindir/ragel
-install -s rlcodegen/rlcodegen $RPM_BUILD_ROOT%_bindir/rlcodegen
-install -d $RPM_BUILD_ROOT%_mandir/man1
-install doc/ragel.1 $RPM_BUILD_ROOT%_mandir/man1/ragel.1
-install doc/rlcodegen.1 $RPM_BUILD_ROOT%_mandir/man1/rlcodegen.1
-
-%files
-%defattr(-,root,root)
-%_bindir/ragel
-%_bindir/rlcodegen
-%_mandir/man1/ragel.1
-%_mandir/man1/rlcodegen.1
-
-%clean
- rm -rf $RPM_BUILD_ROOT
+++ /dev/null
-#
-# Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
-#
-
-# This file is part of Ragel.
-#
-# Ragel is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Ragel is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ragel; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-INCS += -I../common -I../aapl
-DEFS +=
-
-CFLAGS += -g -Wall
-LDFLAGS +=
-
-CC_SRCS = \
- main.cpp parsetree.cpp parsedata.cpp fsmstate.cpp fsmbase.cpp \
- fsmattach.cpp fsmmin.cpp fsmgraph.cpp fsmap.cpp xmlcodegen.cpp \
- rlscan.cpp rlparse.cpp
-
-GEN_SRC = rlscan.cpp rlparse.h rlparse.cpp
-
-LIBS += @LIBS@
-PREFIX = @prefix@
-
-BUILD_PARSERS = @BUILD_PARSERS@
-
-#*************************************
-
-# Programs
-CXX = @CXX@
-
-# Get objects and dependencies from sources.
-OBJS = $(CC_SRCS:%.cpp=%.o)
-DEPS = $(CC_SRCS:%.cpp=.%.d)
-
-# Rules.
-all: ragel
-
-ragel: $(GEN_SRC) $(OBJS)
- $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
-
-ifeq ($(BUILD_PARSERS),true)
-
-rlparse.h: rlparse.kh
- kelbt -o $@ $<
-
-rlparse.cpp: rlparse.kl rlparse.kh
- kelbt -o $@ $<
-
-rlscan.cpp: rlscan.rl
- ragel $< | rlcodegen -G2 -o $@
-
-endif
-
-%.o: %.cpp
- @$(CXX) -M $(DEFS) $(INCS) $< > .$*.d
- $(CXX) -c $(CFLAGS) $(DEFS) $(INCS) -o $@ $<
-
-distclean: clean
- rm -f Makefile
-
-ifeq ($(BUILD_PARSERS),true)
-EXTRA_CLEAN = $(GEN_SRC)
-endif
-
-clean:
- rm -f tags .*.d *.o ragel $(EXTRA_CLEAN)
-
-install: all
- install -d $(PREFIX)/bin
- install -s ragel $(PREFIX)/bin/ragel
-
--include $(DEPS)
+++ /dev/null
-/*
- * Copyright 2001-2005 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-%{
-
-#include <iostream>
-#include <stdlib.h>
-#include <limits.h>
-#include <errno.h>
-#include "ragel.h"
-#include "parsetree.h"
-#include "rlparse.h"
-
-using std::cerr;
-using std::endl;
-
-InputData *id = 0;
-int includeDepth = 0;
-
-extern bool inlineWhitespace;
-
-/* These come from the scanner and point back into the parser. We will borrow
- * them for error reporting. */
-extern YYSTYPE *yylval;
-extern YYLTYPE *yylloc;
-
-/* The include stack pointer from the scanner. Used to determine if we are
- * currently processing an included file. */
-extern int inc_stack_ptr;
-
-/* Try to do a definition, common to assignment and instantiation. */
-void tryMachineDef( const YYLTYPE &loc, char *name,
- JoinOrLm *joinOrLm, bool isInstance );
-void beginOutsideCode();
-void doInclude( const InputLoc &loc, char *sectionName, char *inputFile );
-int yylex( YYSTYPE *yylval, YYLTYPE *yylloc );
-
-bool sectionOpened;
-void openSection();
-
-#define WO_NOEND 0x01
-
-%}
-
-%pure-parser
-
-%union {
- /* General data types. */
- char c;
- TokenData data;
- int integer;
- Literal *literal;
-
- /* Tree nodes. */
- Term *term;
- FactorWithAug *factorWithAug;
- FactorWithRep *factorWithRep;
- FactorWithNeg *factorWithNeg;
- Factor *factor;
- Expression *expression;
- Join *join;
- JoinOrLm *joinOrLm;
- LmPartList *longestMatchList;
- LongestMatchPart *longestMatchPart;
-
- /* Priorities and actions. */
- AugType augType;
- StateAugType stateAugType;
- Action *action;
- PriorDesc *priorDesc;
-
- /* Regular expression items. */
- RegExpr *regExp;
- ReItem *reItem;
- ReOrBlock *reOrBlock;
- ReOrItem *reOrItem;
-
- /* Inline parse tree items. */
- InlineItem *ilitem;
- InlineList *illist;
-}
-
-%token TK_Section
-%token TK_SectionNL
-
-/* General tokens. */
-%token <data> TK_UInt
-%token <data> TK_Hex
-%token <data> TK_Word
-%token <data> TK_Literal
-%token <data> TK_CiLiteral
-%token <data> TK_BaseClause
-%token TK_DotDot
-%token TK_ColonGt
-%token TK_ColonGtGt
-%token TK_LtColon
-%token TK_Arrow
-%token TK_DoubleArrow
-%token TK_StarStar
-%token TK_ColonEquals
-%token TK_NameSep
-%token TK_BarStar
-%token TK_RepOpOpen
-%token TK_DashDash
-
-%token TK_StartCond
-%token TK_AllCond
-%token TK_LeavingCond
-
-%token TK_Middle
-
-/* Global error actions. */
-%token TK_StartGblError
-%token TK_AllGblError
-%token TK_FinalGblError
-%token TK_NotFinalGblError
-%token TK_NotStartGblError
-%token TK_MiddleGblError
-
-/* Local error actions. */
-%token TK_StartLocalError
-%token TK_AllLocalError
-%token TK_FinalLocalError
-%token TK_NotFinalLocalError
-%token TK_NotStartLocalError
-%token TK_MiddleLocalError
-
-/* EOF Action embedding. */
-%token TK_StartEOF
-%token TK_AllEOF
-%token TK_FinalEOF
-%token TK_NotFinalEOF
-%token TK_NotStartEOF
-%token TK_MiddleEOF
-
-/* To State Actions. */
-%token TK_StartToState
-%token TK_AllToState
-%token TK_FinalToState
-%token TK_NotFinalToState
-%token TK_NotStartToState
-%token TK_MiddleToState
-
-/* In State Actions. */
-%token TK_StartFromState
-%token TK_AllFromState
-%token TK_FinalFromState
-%token TK_NotFinalFromState
-%token TK_NotStartFromState
-%token TK_MiddleFromState
-
-/* Regular expression tokens. */
-%token <data> RE_Slash
-%token RE_SqOpen
-%token RE_SqOpenNeg
-%token RE_SqClose
-%token RE_Dot
-%token RE_Star
-%token RE_Dash
-%token <data> RE_Char
-
-/* Tokens specific to inline code. */
-%token <data> IL_WhiteSpace
-%token <data> IL_Comment
-%token <data> IL_Literal
-%token <data> IL_Symbol
-
-/* Keywords. */
-%token KW_Action
-%token KW_AlphType
-%token KW_Range
-%token KW_GetKey
-%token KW_Include
-%token KW_Write
-%token KW_Machine
-%token KW_When
-%token KW_Eof
-%token KW_Err
-%token KW_Lerr
-%token KW_To
-%token KW_From
-
-/* Specials in code blocks. */
-%token KW_Break
-%token KW_Exec
-%token KW_Hold
-%token KW_PChar
-%token KW_Char
-%token KW_Goto
-%token KW_Call
-%token KW_Ret
-%token KW_CurState
-%token KW_TargState
-%token KW_Entry
-%token KW_Next
-%token KW_Exec
-%token<data> KW_Variable
-%token KW_Access
-
-/* Special token for terminating semi-terminated code blocks. Needed because
- * semi is sent as a token in the code block rather than as a generic symbol. */
-%token TK_Semi
-
-/* Symbols. In ragel lexical space, the scanner does not pass
- * any data along with the symbols, in inline code lexical
- * space it does. */
-%token '*' '?' '+' '!' '^' '(' ')' ';' ',' '='
-%token ':' '@' '%' '$' '-' '|' '&' '.' '>'
-
-/* Precedence information. Lower is a higher precedence. We need only two
- * precedence groups. Shifting the minus sign in front of a literal number
- * conflicts with the reduction of Expression and the subsequent shifting of a
- * subtraction operator when a '-' is seen. Since we want subtraction to take
- * precedence, we give EXPR_MINUS the higher priority. */
-%nonassoc '-'
-%nonassoc EXPR_MINUS
-
-%type <augType> AugTypeBase
-%type <augType> AugTypeGblError
-%type <augType> AugTypeLocalError
-%type <augType> AugTypeEOF
-%type <augType> AugTypeToState
-%type <augType> AugTypeFromState
-%type <augType> AugTypeCond
-%type <integer> PriorityAug
-%type <data> PriorityAugNum
-%type <action> ActionEmbed
-%type <action> ActionEmbedWord
-%type <action> ActionEmbedBlock
-%type <action> OptLmPartAction
-%type <longestMatchList> LmPartList
-%type <longestMatchPart> LongestMatchPart
-%type <join> Join
-%type <joinOrLm> JoinOrLm
-%type <expression> Expression
-%type <term> Term
-%type <factorWithAug> FactorWithLabel
-%type <factorWithAug> FactorWithEp
-%type <factorWithAug> FactorWithAug
-%type <factorWithAug> FactorWithTransAction
-%type <factorWithAug> FactorWithPriority
-%type <factorWithAug> FactorWithCond
-%type <factorWithAug> FactorWithToStateAction
-%type <factorWithAug> FactorWithFromStateAction
-%type <factorWithAug> FactorWithEOFAction
-%type <factorWithAug> FactorWithGblErrorAction
-%type <factorWithAug> FactorWithLocalErrorAction
-%type <factorWithRep> FactorWithRep
-%type <integer> FactorRepNum
-%type <factorWithNeg> FactorWithNeg
-%type <factor> Factor
-%type <literal> RangeLit
-%type <data> AlphabetNum
-%type <data> MachineName
-%type <integer> PriorityName
-%type <integer> LocalErrName
-%type <data> SectionName
-%type <data> OptSection
-%type <data> OptFileName
-%type <integer> EndSection
-
-%type <illist> InlineBlock
-%type <ilitem> InlineBlockItem
-%type <ilitem> InlineBlockInterpret
-%type <data> InlineBlockAny
-%type <data> InlineBlockSymbol
-
-%type <illist> InlineExpr
-%type <ilitem> InlineExprItem
-%type <ilitem> InlineExprInterpret
-%type <data> InlineExprSymbol
-%type <data> InlineExprAny
-
-%type <regExp> RegularExpr
-%type <reItem> RegularExprItem
-%type <reItem> RegularExprChar
-%type <reOrBlock> RegularExprOrData
-%type <reOrItem> RegularExprOrChar
-
-%%
-
-/* Input is any number of input sections. An empty file is accepted. */
-input: FsmSpecList;
-FsmSpecList:
- FsmSpecList FsmSpec |
- /* Nothing */;
-
-/* Fsm Specification. Fsms are begin with '%%' and may be a {} delimited
- * list of Fsm statements or may be a single statement. If no name is
- * given the last name given in a machine is used. */
-FsmSpec:
- StartSection SectionName StatementList EndSection {
- if ( includeDepth == 0 ) {
- if ( sectionOpened )
- *outStream << "</ragel_def>\n";
-
- if ( machineSpec == 0 && machineName == 0 ) {
- /* The end section may include a newline on the end, so
- * we use the last line, which will count the newline. */
- *outStream << "<host line=\"" << $4 << "\">";
- }
- }
- };
-
-StartSection:
- TK_Section {
- id->sectionLoc = InputLoc(@1);
-
- if ( includeDepth == 0 ) {
- if ( machineSpec == 0 && machineName == 0 )
- *outStream << "</host>\n";
- sectionOpened = false;
- }
- };
-
-SectionName:
- KW_Machine TK_Word ';' {
- /* By default active until found not active. */
- id->active = true;
- id->sectionName = $2.data;
-
- if ( id->includeSpec != 0 ) {
- if ( strcmp( id->sectionName, id->includeSpec ) == 0 )
- id->sectionName = id->includeTo;
- else
- id->active = false;
- }
-
- /* Lookup the parse data, if it is not there then create it. */
- SectionMapEl *sectionMapEl = sectionMap.find( id->sectionName );
- if ( sectionMapEl == 0 ) {
- ParseData *newPd = new ParseData( id->fileName, id->sectionName,
- id->sectionLoc );
- sectionMapEl = sectionMap.insert( id->sectionName, newPd );
- }
- id->pd = sectionMapEl->value;
- } |
- /* Empty */ {
- /* No machine name. Just use the previous section setup. Report an
- * error if there is no previous section */
- if ( id->pd == 0 ) {
- error(id->sectionLoc) << "the first ragel section does not have a name" << endl;
- id->pd = new ParseData( id->fileName, "<DUMMY>", id->sectionLoc );
- }
- };
-
-EndSection:
- TK_Section { $$ = @1.last_line; } |
- TK_SectionNL { $$ = @1.last_line + 1; };
-
-/* A NonEmpty list of statements in a fsm. */
-StatementList:
- StatementList Statement |
- /* Nothing */;
-
-/* The differnt types of statements in a fsm spec. */
-Statement:
- Assignment |
- Instantiation |
- ActionSpec |
- AlphSpec |
- GetKeySpec |
- RangeSpec |
- Include |
- Write |
- Access |
- Variable;
-
-/* Garble up to the next ; */
-Statement: error ';' { yyerrok; };
-
-/* Allow the user to create a named fsm action that can be referenced when
- * building a machine. */
-ActionSpec:
- KW_Action TK_Word '{' InlineBlock '}' {
- if ( id->active ) {
- if ( id->pd->actionDict.find( $2.data ) ) {
- /* Recover by just ignoring the duplicate. */
- error(@2) << "action \"" << $2.data << "\" already defined" << endl;
- }
- else {
- /* Add the action to the list of actions. */
- Action *newAction = new Action( InputLoc(@3), $2.data, $4, id->nameRefList );
-
- /* Insert to list and dict. */
- id->pd->actionList.append( newAction );
- id->pd->actionDict.insert( newAction );
- }
- }
- };
-
-/* Specifies the data type of the input alphabet. One or two words
- * followed by a semi-colon. */
-AlphSpec:
- KW_AlphType TK_Word TK_Word TK_Semi {
- if ( id->active ) {
- if ( ! id->pd->setAlphType( $2.data, $3.data ) ) {
- // Recover by ignoring the alphtype statement.
- error(@2) << "\"" << $2.data <<
- " " << $3.data << "\" is not a valid alphabet type" << endl;
- }
- }
- } |
- KW_AlphType TK_Word TK_Semi {
- if ( id->active ) {
- if ( ! id->pd->setAlphType( $2.data ) ) {
- // Recover by ignoring the alphtype statement.
- error(@2) << "\"" << $2.data << "\" is not a valid alphabet type" << endl;
- }
- }
- };
-
-GetKeySpec:
- KW_GetKey InlineBlock TK_Semi {
- if ( id->active )
- id->pd->getKeyExpr = $2;
- };
-
-/* Specifies a range to assume that the input characters will fall into. */
-RangeSpec:
- KW_Range AlphabetNum AlphabetNum ';' {
- if ( id->active ) {
- // Save the upper and lower ends of the range and emit the line number.
- id->pd->lowerNum = $2.data;
- id->pd->upperNum = $3.data;
- id->pd->rangeLowLoc = InputLoc(@2);
- id->pd->rangeHighLoc = InputLoc(@3);
- }
- };
-
-
-Write:
- WriteOpen WriteOptions ';' {
- if ( id->active )
- *outStream << "</write>\n";
- };
-
-WriteOpen:
- KW_Write TK_Word {
- if ( id->active ) {
- openSection();
- if ( strcmp( $2.data, "data" ) != 0 &&
- strcmp( $2.data, "init" ) != 0 &&
- strcmp( $2.data, "exec" ) != 0 &&
- strcmp( $2.data, "eof" ) != 0 )
- {
- error( @2 ) << "unknown write command" << endl;
- }
- *outStream << " <write what=\"" << $2.data << "\">";
- }
- };
-
-WriteOptions:
- WriteOptions TK_Word {
- if ( id->active )
- *outStream << "<option>" << $2.data << "</option>";
- } |
- /* Nothing */;
-
-Access:
- KW_Access InlineBlock TK_Semi {
- if ( id->active )
- id->pd->accessExpr = $2;
- };
-
-Variable:
- KW_Variable InlineBlock TK_Semi {
- if ( id->active ) {
- if ( strcmp( $1.data, "curstate" ) == 0 ) {
- id->pd->curStateExpr = $2;
- }
- }
- };
-
-/* Include statements are processed by both the scanner and the parser. */
-Include:
- IncludeKeyword OptSection OptFileName ';' {
- if ( id->active )
- doInclude( @1, $2.data, $3.data );
- };
-
-IncludeKeyword:
- KW_Include {
- /* Do this immediately so that the scanner has a correct sense of the
- * value in id->active when it reaches the end of the statement before
- * the above action executes. */
- //getParseData( @1 );
- };
-
-OptSection: TK_Word { $$ = $1; } | { $$.data = 0; $$.length = 0; };
-OptFileName: TK_Literal { $$ = $1; } | { $$.data = 0; $$.length = 0; };
-
-/* An assignement statement. Assigns the definition of a machine to a variable name. */
-Assignment:
- MachineName '=' Join ';' {
- if ( id->active ) {
- /* Main machine must be an instance. */
- bool isInstance = false;
- if ( strcmp($1.data, machineMain) == 0 ) {
- warning(@1) << "main machine will be implicitly instantiated" << endl;
- isInstance = true;
- }
-
- /* Generic creation of machine for instantiation and assignment. */
- JoinOrLm *joinOrLm = new JoinOrLm( $3 );
- tryMachineDef( @1, $1.data, joinOrLm, isInstance );
- }
- };
-
-/* An instantiation statement. Instantiates a machine and assigns it to a
- * variable name. */
-Instantiation:
- MachineName TK_ColonEquals JoinOrLm ';' {
- /* Generic creation of machine for instantiation and assignment. */
- if ( id->active )
- tryMachineDef( @1, $1.data, $3, true );
- };
-
-/* Capture the machine name for making the machine's priority name. */
-MachineName:
- TK_Word {
- if ( id->active ) {
- /* Make/get the priority key. The name may have already been referenced
- * and therefore exist. */
- PriorDictEl *priorDictEl;
- if ( id->pd->priorDict.insert( $1.data, id->pd->nextPriorKey, &priorDictEl ) )
- id->pd->nextPriorKey += 1;
- id->pd->curDefPriorKey = priorDictEl->value;
-
- /* Make/get the local error key. */
- LocalErrDictEl *localErrDictEl;
- if ( id->pd->localErrDict.insert( $1.data, id->pd->nextLocalErrKey, &localErrDictEl ) )
- id->pd->nextLocalErrKey += 1;
- id->pd->curDefLocalErrKey = localErrDictEl->value;
- }
- };
-
-JoinOrLm:
- Join {
- $$ = new JoinOrLm( $1 );
- } |
- TK_BarStar LmPartList '*' '|' {
- /* Create a new factor going to a longest match structure. Record
- * in the parse data that we have a longest match. */
- LongestMatch *lm = new LongestMatch( @1, $2 );
- if ( id->active )
- id->pd->lmList.append( lm );
- for ( LmPartList::Iter lmp = *($2); lmp.lte(); lmp++ )
- lmp->longestMatch = lm;
- $$ = new JoinOrLm( lm );
- };
-
-Join:
- Join ',' Expression {
- /* Append the expression to the list and return it. */
- $1->exprList.append( $3 );
- $$ = $1;
- } |
- Expression {
- /* Create the expression list with the intial expression. */
- $$ = new Join( InputLoc(@1), $1 );
- };
-
-/* Top level production in the parse of a fsm. The lowest precedence
- * is the '|' (or), '&' (intersection), and '-' (subtraction) operators. */
-Expression:
- Expression '|' Term {
- $$ = new Expression( $1, $3, Expression::OrType );
- } %prec EXPR_MINUS |
- Expression '&' Term {
- $$ = new Expression( $1, $3, Expression::IntersectType );
- } %prec EXPR_MINUS |
- Expression '-' Term {
- $$ = new Expression( $1, $3, Expression::SubtractType );
- } %prec EXPR_MINUS |
- Expression TK_DashDash Term {
- $$ = new Expression( $1, $3, Expression::StrongSubtractType );
- } %prec EXPR_MINUS |
- Term {
- $$ = new Expression( $1 );
- } %prec EXPR_MINUS;
-
-Term:
- Term FactorWithLabel {
- $$ = new Term( $1, $2 );
- } |
- Term '.' FactorWithLabel {
- $$ = new Term( $1, $3 );
- } |
- Term TK_ColonGt FactorWithLabel {
- $$ = new Term( $1, $3, Term::RightStartType );
- } |
- Term TK_ColonGtGt FactorWithLabel {
- $$ = new Term( $1, $3, Term::RightFinishType );
- } |
- Term TK_LtColon FactorWithLabel {
- $$ = new Term( $1, $3, Term::LeftType );
- } |
- FactorWithLabel {
- $$ = new Term( $1 );
- };
-
-FactorWithLabel:
- TK_Word ':' FactorWithLabel {
- /* Add the label to the list and pass the factor up. */
- $3->labels.prepend( Label(@1, $1.data) );
- $$ = $3;
- } |
- FactorWithEp;
-
-FactorWithEp:
- FactorWithEp TK_Arrow LocalStateRef {
- /* Add the target to the list and return the factor object. */
- $1->epsilonLinks.append( EpsilonLink( InputLoc(@2), id->nameRef ) );
- $$ = $1;
- } |
- FactorWithAug;
-
-/* A local state reference. Qualified name witout :: prefix. */
-LocalStateRef:
- NoNameSep StateRefNames;
-
-/* Clear the name ref structure. */
-NoNameSep:
- /* Nothing */ {
- id->nameRef.empty();
- };
-
-/* A qualified state reference. */
-StateRef:
- OptNameSep StateRefNames;
-
-/* Optional leading name separator. */
-OptNameSep:
- TK_NameSep {
- /* Insert an inition null pointer val to indicate the existence of the
- * initial name seperator. */
- id->nameRef.setAs( 0 );
- } |
- /* Nothing. */ {
- id->nameRef.empty();
- };
-
-/* List of names separated by :: */
-StateRefNames:
- StateRefNames TK_NameSep TK_Word {
- id->nameRef.append( $3.data );
- } |
- TK_Word {
- id->nameRef.append( $1.data );
- };
-
-/* Third group up in precedence. Allow users to embed actions and priorities */
-FactorWithAug:
- FactorWithTransAction |
- FactorWithPriority |
- FactorWithCond |
- FactorWithToStateAction |
- FactorWithFromStateAction |
- FactorWithEOFAction |
- FactorWithGblErrorAction |
- FactorWithLocalErrorAction |
- FactorWithRep {
- $$ = new FactorWithAug( $1 );
- };
-
-FactorWithTransAction:
- FactorWithAug AugTypeBase ActionEmbed {
- /* Append the action to the factorWithAug, record the refernce from
- * factorWithAug to the action and pass up the factorWithAug. */
- $1->actions.append( ParserAction( @2, $2, 0, $3 ) );
- $$ = $1;
- };
-
-FactorWithPriority:
- FactorWithAug AugTypeBase PriorityAug {
- if ( id->active ) {
- /* Append the named priority to the factorWithAug and pass it up. */
- $1->priorityAugs.append( PriorityAug( $2, id->pd->curDefPriorKey, $3 ) );
- }
- $$ = $1;
- } |
- FactorWithAug AugTypeBase '(' PriorityName ',' PriorityAug ')' {
- /* Append the priority using a default name. */
- $1->priorityAugs.append( PriorityAug( $2, $4, $6 ) );
- $$ = $1;
- };
-
-FactorWithCond:
- FactorWithAug AugTypeCond ActionEmbed {
- $$->conditions.append( ParserAction( @2, $2, 0, $3 ) );
- $$ = $1;
- };
-
-AugTypeCond:
- TK_StartCond { $$ = at_start; } |
- '>' KW_When { $$ = at_start; } |
- TK_AllCond { $$ = at_all; } |
- '$' KW_When { $$ = at_all; } |
- TK_LeavingCond { $$ = at_leave; } |
- '%' KW_When { $$ = at_all; } |
- KW_When { $$ = at_all; };
-
-FactorWithToStateAction:
- FactorWithAug AugTypeToState ActionEmbed {
- /* Append the action, pass it up. */
- $1->actions.append( ParserAction( @2, $2, 0, $3 ) );
- $$ = $1;
- };
-
-FactorWithFromStateAction:
- FactorWithAug AugTypeFromState ActionEmbed {
- /* Append the action, pass it up. */
- $1->actions.append( ParserAction( @2, $2, 0, $3 ) );
- $$ = $1;
- };
-
-FactorWithEOFAction:
- FactorWithAug AugTypeEOF ActionEmbed {
- /* Append the action, pass it up. */
- $1->actions.append( ParserAction( @2, $2, 0, $3 ) );
- $$ = $1;
- };
-
-FactorWithGblErrorAction:
- FactorWithAug AugTypeGblError ActionEmbed {
- if ( id->active ) {
- /* Append the action to the factorWithAug, record the refernce from
- * factorWithAug to the action and pass up the factorWithAug. */
- $1->actions.append( ParserAction( @2, $2, id->pd->curDefLocalErrKey, $3 ) );
- }
- $$ = $1;
- };
-
-FactorWithLocalErrorAction:
- FactorWithAug AugTypeLocalError ActionEmbed {
- if ( id->active ) {
- /* Append the action to the factorWithAug, record the refernce from
- * factorWithAug to the action and pass up the factorWithAug. */
- $1->actions.append( ParserAction( @2, $2, id->pd->curDefLocalErrKey, $3 ) );
- }
- $$ = $1;
- } |
- FactorWithAug AugTypeLocalError '(' LocalErrName ',' ActionEmbed ')' {
- /* Append the action to the factorWithAug, record the refernce from
- * factorWithAug to the action and pass up the factorWithAug. */
- $1->actions.append( ParserAction( @2, $2, $4, $6 ) );
- $$ = $1;
- };
-
-/* A specified priority name. Looks up the name in the current priority
- * dictionary. */
-PriorityName:
- TK_Word {
- if ( id->active ) {
- // Lookup/create the priority key.
- PriorDictEl *priorDictEl;
- if ( id->pd->priorDict.insert( $1.data, id->pd->nextPriorKey, &priorDictEl ) )
- id->pd->nextPriorKey += 1;
-
- // Use the inserted/found priority key.
- $$ = priorDictEl->value;
- }
- };
-
-LocalErrName:
- TK_Word {
- if ( id->active ) {
- /* Lookup/create the priority key. */
- LocalErrDictEl *localErrDictEl;
- if ( id->pd->localErrDict.insert( $1.data, id->pd->nextLocalErrKey, &localErrDictEl ) )
- id->pd->nextLocalErrKey += 1;
-
- /* Use the inserted/found priority key. */
- $$ = localErrDictEl->value;
- }
- };
-
-/* Priority change specs. */
-PriorityAug:
- PriorityAugNum {
- // Convert the priority number to a long. Check for overflow.
- errno = 0;
- int aug = strtol( $1.data, 0, 10 );
- if ( errno == ERANGE && aug == LONG_MAX ) {
- // Priority number too large. Recover by setting the priority to 0.
- error(@1) << "priority number " << $1.data << " overflows" << endl;
- $$ = 0;
- }
- else if ( errno == ERANGE && aug == LONG_MIN ) {
- // Priority number too large in the neg. Recover by using 0.
- error(@1) << "priority number " << $1.data << " underflows" << endl;
- $$ = 0;
- }
- else {
- // No overflow or underflow.
- $$ = aug;
- }
- };
-
-PriorityAugNum:
- TK_UInt |
- '+' TK_UInt {
- $$ = $2;
- } |
- '-' TK_UInt {
- $$.data = "-";
- $$.length = 1;
- $$.append( $2 );
- };
-
-/* Classes of transtions on which to embed actions or change priorities. */
-AugTypeBase:
- '@' { $$ = at_finish; } |
- '%' { $$ = at_leave; } |
- '$' { $$ = at_all; } |
- '>' { $$ = at_start; };
-
-/* Global error actions. */
-AugTypeGblError:
- TK_StartGblError { $$ = at_start_gbl_error; } |
- '>' KW_Err { $$ = at_start_gbl_error; } |
-
- TK_NotStartGblError { $$ = at_not_start_gbl_error; } |
- '<' KW_Err { $$ = at_not_start_gbl_error; } |
-
- TK_AllGblError { $$ = at_all_gbl_error; } |
- '$' KW_Err { $$ = at_all_gbl_error; } |
-
- TK_FinalGblError { $$ = at_final_gbl_error; } |
- '%' KW_Err { $$ = at_final_gbl_error; } |
-
- TK_NotFinalGblError { $$ = at_not_final_gbl_error; } |
- '@' KW_Err { $$ = at_not_final_gbl_error; } |
-
- TK_MiddleGblError { $$ = at_middle_gbl_error; } |
- TK_Middle KW_Err { $$ = at_middle_gbl_error; };
-
-/* Local error actions. */
-AugTypeLocalError:
- TK_StartLocalError { $$ = at_start_local_error; } |
- '>' KW_Lerr { $$ = at_start_local_error; } |
-
- TK_NotStartLocalError { $$ = at_not_start_local_error; } |
- '<' KW_Lerr { $$ = at_not_start_local_error; } |
-
- TK_AllLocalError { $$ = at_all_local_error; } |
- '$' KW_Lerr { $$ = at_all_local_error; } |
-
- TK_FinalLocalError { $$ = at_final_local_error; } |
- '%' KW_Lerr { $$ = at_final_local_error; } |
-
- TK_NotFinalLocalError { $$ = at_not_final_local_error; } |
- '@' KW_Lerr { $$ = at_not_final_local_error; } |
-
- TK_MiddleLocalError { $$ = at_middle_local_error; } |
- TK_Middle KW_Lerr { $$ = at_middle_local_error; };
-
-/* Eof state actions. */
-AugTypeEOF:
- TK_StartEOF { $$ = at_start_eof; } |
- '>' KW_Eof { $$ = at_start_eof; } |
-
- TK_NotStartEOF { $$ = at_not_start_eof; } |
- '<' KW_Eof { $$ = at_not_start_eof; } |
-
- TK_AllEOF { $$ = at_all_eof; } |
- '$' KW_Eof { $$ = at_all_eof; } |
-
- TK_FinalEOF { $$ = at_final_eof; } |
- '%' KW_Eof { $$ = at_final_eof; } |
-
- TK_NotFinalEOF { $$ = at_not_final_eof; } |
- '@' KW_Eof { $$ = at_not_final_eof; } |
-
- TK_MiddleEOF { $$ = at_middle_eof; } |
- TK_Middle KW_Eof { $$ = at_middle_eof; };
-
-/* To state actions. */
-AugTypeToState:
- TK_StartToState { $$ = at_start_to_state; } |
- '>' KW_To { $$ = at_start_to_state; } |
-
- TK_NotStartToState { $$ = at_not_start_to_state; } |
- '<' KW_To { $$ = at_not_start_to_state; } |
-
- TK_AllToState { $$ = at_all_to_state; } |
- '$' KW_To { $$ = at_all_to_state; } |
-
- TK_FinalToState { $$ = at_final_to_state; } |
- '%' KW_To { $$ = at_final_to_state; } |
-
- TK_NotFinalToState { $$ = at_not_final_to_state; } |
- '@' KW_To { $$ = at_not_final_to_state; } |
-
- TK_MiddleToState { $$ = at_middle_to_state; } |
- TK_Middle KW_To { $$ = at_middle_to_state; };
-
-/* From state actions. */
-AugTypeFromState:
- TK_StartFromState { $$ = at_start_from_state; } |
- '>' KW_From { $$ = at_start_from_state; } |
-
- TK_NotStartFromState { $$ = at_not_start_from_state; } |
- '<' KW_From { $$ = at_not_start_from_state; } |
-
- TK_AllFromState { $$ = at_all_from_state; } |
- '$' KW_From { $$ = at_all_from_state; } |
-
- TK_FinalFromState { $$ = at_final_from_state; } |
- '%' KW_From { $$ = at_final_from_state; } |
-
- TK_NotFinalFromState { $$ = at_not_final_from_state; } |
- '@' KW_From { $$ = at_not_final_from_state; } |
-
- TK_MiddleFromState { $$ = at_middle_from_state; } |
- TK_Middle KW_From { $$ = at_middle_from_state; };
-
-
-/* Different ways to embed actions. A TK_Word is reference to an action given by
- * the user as a statement in the fsm specification. An action can also be
- * specified immediately. */
-ActionEmbed:
- ActionEmbedWord | ActionEmbedBlock;
-
-ActionEmbedWord:
- TK_Word {
- if ( id->active ) {
- /* Set the name in the actionDict. */
- Action *action = id->pd->actionDict.find( $1.data );
- if ( action != 0 ) {
- /* Pass up the action element */
- $$ = action;
- }
- else {
- /* Will recover by returning null as the action. */
- error(@1) << "action lookup of \"" << $1.data << "\" failed" << endl;
- $$ = 0;
- }
- }
- };
-
-ActionEmbedBlock:
- '{' InlineBlock '}' {
- if ( id->active ) {
- /* Create the action, add it to the list and pass up. */
- Action *newAction = new Action( InputLoc(@1), 0, $2, id->nameRefList );
- id->pd->actionList.append( newAction );
- $$ = newAction;
- }
- };
-
-/* The fourth level of precedence. These are the trailing unary operators that
- * allow for repetition. */
-FactorWithRep:
- FactorWithRep '*' {
- $$ = new FactorWithRep( InputLoc(@2), $1, 0, 0,
- FactorWithRep::StarType );
- } |
- FactorWithRep TK_StarStar {
- $$ = new FactorWithRep( InputLoc(@2), $1, 0, 0,
- FactorWithRep::StarStarType );
- } |
- FactorWithRep '?' {
- $$ = new FactorWithRep( InputLoc(@2), $1, 0, 0,
- FactorWithRep::OptionalType );
- } |
- FactorWithRep '+' {
- $$ = new FactorWithRep( InputLoc(@2), $1, 0, 0,
- FactorWithRep::PlusType );
- } |
- FactorWithRep TK_RepOpOpen FactorRepNum '}' {
- $$ = new FactorWithRep( InputLoc(@2), $1, $3, 0,
- FactorWithRep::ExactType );
- } |
- FactorWithRep TK_RepOpOpen ',' FactorRepNum '}' {
- $$ = new FactorWithRep( InputLoc(@2), $1, 0, $4,
- FactorWithRep::MaxType );
- } |
- FactorWithRep TK_RepOpOpen FactorRepNum ',' '}' {
- $$ = new FactorWithRep( InputLoc(@2), $1, $3, 0,
- FactorWithRep::MinType );
- } |
- FactorWithRep TK_RepOpOpen FactorRepNum ',' FactorRepNum '}' {
- $$ = new FactorWithRep( InputLoc(@2), $1, $3, $5,
- FactorWithRep::RangeType );
- } |
- FactorWithNeg {
- $$ = new FactorWithRep( InputLoc(@1), $1 );
- };
-
-FactorRepNum:
- TK_UInt {
- // Convert the priority number to a long. Check for overflow.
- errno = 0;
- int rep = strtol( $1.data, 0, 10 );
- if ( errno == ERANGE && rep == LONG_MAX ) {
- // Repetition too large. Recover by returing repetition 1. */
- error(@1) << "repetition number " << $1.data << " overflows" << endl;
- $$ = 1;
- }
- else {
- // Cannot be negative, so no overflow.
- $$ = rep;
- }
- };
-
-/* The fifth level up in precedence. Negation. */
-FactorWithNeg:
- '!' FactorWithNeg {
- $$ = new FactorWithNeg( InputLoc(@1), $2, FactorWithNeg::NegateType );
- } |
- '^' FactorWithNeg {
- $$ = new FactorWithNeg( InputLoc(@1), $2, FactorWithNeg::CharNegateType );
- } |
- Factor {
- $$ = new FactorWithNeg( InputLoc(@1), $1 );
- };
-
-/* The highest level in precedence. Atomic machines such as references to other
- * machines, literal machines, regular expressions or Expressions in side of
- * parenthesis. */
-Factor:
- TK_Literal {
- // Create a new factor node going to a concat literal. */
- $$ = new Factor( new Literal( InputLoc(@1), $1, Literal::LitString ) );
- } |
- TK_CiLiteral {
- // Create a new factor node going to a concat literal. */
- $$ = new Factor( new Literal( InputLoc(@1), $1, Literal::LitString ) );
- $$->literal->caseInsensitive = true;
- } |
- AlphabetNum {
- // Create a new factor node going to a literal number. */
- $$ = new Factor( new Literal( InputLoc(@1), $1, Literal::Number ) );
- } |
- TK_Word {
- if ( id->active ) {
- // Find the named graph.
- GraphDictEl *gdNode = id->pd->graphDict.find( $1.data );
- if ( gdNode == 0 ) {
- // Recover by returning null as the factor node.
- error(@1) << "graph lookup of \"" << $1.data << "\" failed" << endl;
- $$ = 0;
- }
- else if ( gdNode->isInstance ) {
- // Recover by retuning null as the factor node.
- error(@1) << "references to graph instantiations not allowed "
- "in expressions" << endl;
- $$ = 0;
- }
- else {
- // Create a factor node that is a lookup of an expression.
- $$ = new Factor( InputLoc(@1), gdNode->value );
- }
- }
- } |
- RE_SqOpen RegularExprOrData RE_SqClose {
- // Create a new factor node going to an OR expression. */
- $$ = new Factor( new ReItem( InputLoc(@1), $2, ReItem::OrBlock ) );
- } |
- RE_SqOpenNeg RegularExprOrData RE_SqClose {
- // Create a new factor node going to a negated OR expression. */
- $$ = new Factor( new ReItem( InputLoc(@1), $2, ReItem::NegOrBlock ) );
- } |
- RE_Slash RegularExpr RE_Slash {
- if ( $3.length > 1 ) {
- for ( char *p = $3.data; *p != 0; p++ ) {
- if ( *p == 'i' )
- $2->caseInsensitive = true;
- }
- }
-
- // Create a new factor node going to a regular exp.
- $$ = new Factor( $2 );
- } |
- RangeLit TK_DotDot RangeLit {
- // Create a new factor node going to a range. */
- $$ = new Factor( new Range( $1, $3 ) );
- } |
- '(' Join ')' {
- /* Create a new factor going to a parenthesized join. */
- $$ = new Factor( $2 );
- };
-
-/* Garble up to the closing brace of a parenthesized expression. */
-Factor: '(' error ')' { $$ = 0; yyerrok; };
-
-LmPartList:
- LmPartList LongestMatchPart {
- if ( $2 != 0 )
- $1->append( $2 );
- $$ = $1;
- } |
- LongestMatchPart {
- /* Create a new list with the part. */
- $$ = new LmPartList;
- if ( $1 != 0 )
- $$->append( $1 );
- };
-
-LongestMatchPart:
- ActionSpec { $$ = 0; } |
- Assignment { $$ = 0; } |
- Join OptLmPartAction ';' {
- $$ = 0;
- if ( id->active ) {
- Action *action = $2;
- if ( action != 0 )
- action->isLmAction = true;
- $$ = new LongestMatchPart( $1, action, id->pd->nextLongestMatchId++ );
- }
- };
-
-OptLmPartAction:
- TK_DoubleArrow ActionEmbed { $$ = $2; } |
- ActionEmbedBlock { $$ = $1; } |
- /* Nothing */ { $$ = 0; };
-
-
-/* Any form of a number that can be used as a basic machine. */
-AlphabetNum:
- TK_UInt |
- '-' TK_UInt {
- $$.data = "-";
- $$.length = 1;
- $$.append( $2 );
- } |
- TK_Hex;
-
-InlineBlock:
- InlineBlock InlineBlockItem {
- /* Append the item to the list, return the list. */
- $1->append( $2 );
- $$ = $1;
- } |
- /* Empty */ {
- /* Start with empty list. */
- $$ = new InlineList;
- };
-
-/* Items in a struct block. */
-InlineBlockItem:
- InlineBlockAny {
- /* Add a text segment. */
- $$ = new InlineItem( @1, $1.data, InlineItem::Text );
- } |
- InlineBlockSymbol {
- /* Add a text segment, need string on heap. */
- $$ = new InlineItem( @1, strdup($1.data), InlineItem::Text );
- } |
- InlineBlockInterpret {
- /* Pass the inline item up. */
- $$ = $1;
- };
-
-/* Uninteresting tokens in a struct block. Data allocated by scanner. */
-InlineBlockAny:
- IL_WhiteSpace | IL_Comment | IL_Literal | IL_Symbol |
- TK_UInt | TK_Hex | TK_Word;
-
-/* Symbols in a struct block, no data allocated. */
-InlineBlockSymbol:
- ',' { $$.data = ","; $$.length = 1; } |
- ';' { $$.data = ";"; $$.length = 1; } |
- '(' { $$.data = "("; $$.length = 1; } |
- ')' { $$.data = ")"; $$.length = 1; } |
- '*' { $$.data = "*"; $$.length = 1; } |
- TK_NameSep { $$.data = "::"; $$.length = 2; };
-
-/* Interpreted statements in a struct block. */
-InlineBlockInterpret:
- InlineExprInterpret {
- /* Pass up interpreted items of inline expressions. */
- $$ = $1;
- } |
- KW_Hold SetNoWs ';' SetWs {
- $$ = new InlineItem( @1, InlineItem::Hold );
- } |
- KW_Exec SetNoWs InlineExpr ';' SetWs {
- $$ = new InlineItem( @1, InlineItem::Exec );
- $$->children = $3;
- } |
- KW_Goto SetNoWs StateRef ';' SetWs {
- $$ = new InlineItem( @1, new NameRef(id->nameRef), InlineItem::Goto );
- } |
- KW_Goto SetNoWs '*' SetWs InlineExpr ';' {
- $$ = new InlineItem( @1, InlineItem::GotoExpr );
- $$->children = $5;
- } |
- KW_Next SetNoWs StateRef ';' SetWs {
- $$ = new InlineItem( @1, new NameRef(id->nameRef), InlineItem::Next );
- } |
- KW_Next SetNoWs '*' SetWs InlineExpr ';' {
- $$ = new InlineItem( @1, InlineItem::NextExpr );
- $$->children = $5;
- } |
- KW_Call SetNoWs StateRef ';' SetWs {
- $$ = new InlineItem( @1, new NameRef(id->nameRef), InlineItem::Call );
- } |
- KW_Call SetNoWs '*' SetWs InlineExpr ';' {
- $$ = new InlineItem( @1, InlineItem::CallExpr );
- $$->children = $5;
- } |
- KW_Ret SetNoWs ';' SetWs {
- $$ = new InlineItem( @1, InlineItem::Ret );
- } |
- KW_Break SetNoWs ';' SetWs {
- $$ = new InlineItem( @1, InlineItem::Break );
- };
-
-/* Turn off whitspace collecting when scanning inline blocks. */
-SetNoWs: { inlineWhitespace = false; };
-
-/* Turn on whitespace collecting when scanning inline blocks. */
-SetWs: { inlineWhitespace = true; };
-
-InlineExpr:
- InlineExpr InlineExprItem {
- $1->append( $2 );
- $$ = $1;
- } |
- /* Empty */ {
- /* Init the list used for this expr. */
- $$ = new InlineList;
- };
-
-InlineExprItem:
- InlineExprAny {
- /* Return a text segment. */
- $$ = new InlineItem( @1, $1.data, InlineItem::Text );
- } |
- InlineExprSymbol {
- /* Return a text segment, must heap alloc the text. */
- $$ = new InlineItem( @1, strdup($1.data), InlineItem::Text );
- } |
- InlineExprInterpret {
- /* Pass the inline item up. */
- $$ = $1;
- };
-
-InlineExprInterpret:
- KW_PChar {
- $$ = new InlineItem( @1, InlineItem::PChar );
- } |
- KW_Char {
- $$ = new InlineItem( @1, InlineItem::Char );
- } |
- KW_CurState {
- $$ = new InlineItem( @1, InlineItem::Curs );
- } |
- KW_TargState {
- $$ = new InlineItem( @1, InlineItem::Targs );
- } |
- KW_Entry SetNoWs '(' StateRef ')' SetWs {
- $$ = new InlineItem( @1, new NameRef(id->nameRef), InlineItem::Entry );
- };
-
-InlineExprAny:
- IL_WhiteSpace | IL_Comment | IL_Literal | IL_Symbol |
- TK_UInt | TK_Hex | TK_Word;
-
-/* Anything in a ExecValExpr that is not dynamically allocated. This includes
- * all special symbols caught in inline code except the semi. */
-InlineExprSymbol:
- '(' { $$.data = "("; $$.length = 1; } |
- ')' { $$.data = ")"; $$.length = 1; } |
- '*' { $$.data = "*"; $$.length = 1; } |
- TK_NameSep { $$.data = "::"; $$.length = 1; };
-
-/* Parser for regular expression fsms. Any number of expression items which
- * generally gives a machine one character long or one character long stared. */
-RegularExpr:
- RegularExpr RegularExprItem {
- // An optimization to lessen the tree size. If a non-starred char is directly
- // under the left side on the right and the right side is another non-starred
- // char then paste them together and return the left side. Otherwise
- // just put the two under a new reg exp node.
- if ( $2->type == ReItem::Data && !$2->star &&
- $1->type == RegExpr::RecurseItem &&
- $1->item->type == ReItem::Data && !$1->item->star )
- {
- // Append the right side to the right side of the left and toss
- // the right side.
- $1->item->data.append( $2->data );
- delete $2;
- $$ = $1;
- }
- else {
- $$ = new RegExpr( $1, $2 );
- }
- } |
- /* Nothing */ {
- // Can't optimize the tree.
- $$ = new RegExpr();
- };
-
-/* RegularExprItems can be a character spec with an optional staring of the char. */
-RegularExprItem:
- RegularExprChar RE_Star {
- $1->star = true;
- $$ = $1;
- } |
- RegularExprChar {
- $$ = $1;
- };
-
-/* A character spec can be a set of characters inside of square parenthesis,
- * a dot specifying any character or some explicitly stated character. */
-RegularExprChar:
- RE_SqOpen RegularExprOrData RE_SqClose {
- $$ = new ReItem( InputLoc(@1), $2, ReItem::OrBlock );
- } |
- RE_SqOpenNeg RegularExprOrData RE_SqClose {
- $$ = new ReItem( InputLoc(@1), $2, ReItem::NegOrBlock );
- } |
- RE_Dot {
- $$ = new ReItem( InputLoc(@1), ReItem::Dot );
- } |
- RE_Char {
- $$ = new ReItem( InputLoc(@1), $1.data[0] );
- };
-
-/* The data inside of a [] expression in a regular expression. Accepts any
- * number of characters or ranges. */
-RegularExprOrData:
- RegularExprOrData RegularExprOrChar {
- // An optimization to lessen the tree size. If an or char is directly
- // under the left side on the right and the right side is another or
- // char then paste them together and return the left side. Otherwise
- // just put the two under a new or data node.
- if ( $2->type == ReOrItem::Data &&
- $1->type == ReOrBlock::RecurseItem &&
- $1->item->type == ReOrItem::Data )
- {
- // Append the right side to right side of the left and toss
- // the right side.
- $1->item->data.append( $2->data );
- delete $2;
- $$ = $1;
- }
- else {
- // Can't optimize, put the left and right under a new node.
- $$ = new ReOrBlock( $1, $2 );
- }
- } |
- /* Nothing */ {
- $$ = new ReOrBlock();
- };
-
-
-/* A single character inside of an or expression. Can either be a character
- * or a set of characters. */
-RegularExprOrChar:
- RE_Char {
- $$ = new ReOrItem( InputLoc(@1), $1.data[0] );
- } |
- RE_Char RE_Dash RE_Char {
- $$ = new ReOrItem( InputLoc(@2), $1.data[0], $3.data[0] );
- };
-
-RangeLit:
- TK_Literal {
- // Range literas must have only one char.
- if ( strlen($1.data) != 1 ) {
- // Recover by using the literal anyways.
- error(@1) << "literal used in range must be of length 1" << endl;
- }
- $$ = new Literal( InputLoc(@1), $1, Literal::LitString );
- } |
- AlphabetNum {
- // Create a new literal number.
- $$ = new Literal( InputLoc(@1), $1, Literal::Number );
- };
-
-%%
-
-/* Try to do a definition, common to assignment and instantiation. Warns about
- * instances other than main not being implemented yet. */
-void tryMachineDef( const YYLTYPE &loc, char *name, JoinOrLm *joinOrLm, bool isInstance )
-{
- GraphDictEl *newEl = id->pd->graphDict.insert( name );
- if ( newEl != 0 ) {
- /* New element in the dict, all good. */
- newEl->value = new VarDef( name, joinOrLm );
- newEl->isInstance = isInstance;
- newEl->loc = loc;
-
- /* It it is an instance, put on the instance list. */
- if ( isInstance )
- id->pd->instanceList.append( newEl );
- }
- else {
- // Recover by ignoring the duplicate.
- error(loc) << "fsm \"" << name << "\" previously defined" << endl;
- }
-}
-
-void doInclude( const InputLoc &loc, char *sectionName, char *inputFile )
-{
- /* Bail if we hit the max include depth. */
- if ( includeDepth == INCLUDE_STACK_SIZE ) {
- error(loc) << "hit maximum include depth of " << INCLUDE_STACK_SIZE << endl;
- }
- else {
- char *includeTo = id->pd->fsmName;
-
- /* Implement defaults for the input file and section name. */
- if ( inputFile == 0 )
- inputFile = id->fileName;
- if ( sectionName == 0 )
- sectionName = id->pd->fsmName;
-
- /* Parse the included file. */
- InputData *oldId = id;
- id = new InputData( inputFile, sectionName, includeTo );
- includeDepth += 1;
- yyparse();
- includeDepth -= 1;
- delete id;
- id = oldId;
- }
-}
-
-void openSection()
-{
- if ( ! sectionOpened ) {
- sectionOpened = true;
- *outStream << "<ragel_def name=\"" << id->pd->fsmName << "\">\n";
- }
-}
-
-void yyerror( char *err )
-{
- /* Bison won't give us the location, but in the last call to the scanner we
- * saved a pointer to the location variable. Use that. instead. */
- error(::yylloc->first_line, ::yylloc->first_column) << err << endl;
-}
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-%{
-
-#define YY_NEVER_INTERACTIVE 1
-//#define WANT_TOKEN_WRITE
-
-#include <iostream>
-#include "ragel.h"
-#include "rlparse.h"
-#include "parsedata.h"
-#include "buffer.h"
-
-using std::cout;
-using std::cerr;
-using std::endl;
-
-Buffer tokbuf;
-int builtinBrace = 0;
-bool inlineWhitespace = true;
-bool handlingInclude = false;
-bool multiline = false;
-
-/* Used for recognising host language code blocks, init with anything not
- * involved in the host lang test. */
-int previous_tokens[2] = { TK_Section, TK_Section };
-
-/* These keep track of the start of an inline comment or literal string for
- * reporting unterminated comments or strings. */
-int il_comm_lit_first_line;
-int il_comm_lit_first_column;
-
-/* These keep track of the start of a code block for reporting unterminated
- * code blocks. */
-int il_code_first_line;
-int il_code_first_column;
-
-/* Include Stack data. */
-YY_BUFFER_STATE buff_stack[INCLUDE_STACK_SIZE];
-bool multiline_stack[INCLUDE_STACK_SIZE];
-int inc_stack_ptr = 0;
-
-YYSTYPE *yylval;
-YYLTYPE *yylloc;
-
-extern InputData *id;
-extern int includeDepth;
-
-void garble();
-
-void extendToken( char *data, int len );
-void extendToken();
-
-int emitToken( int token, char *data, int len );
-int emitNoData( int token );
-void passThrough( char *data );
-bool openMachineSpecBlock();
-void popInclude();
-
-enum InlineBlockType {
- CurlyDelimited,
- SemiTerminated
-} inlineBlockType;
-
-/* Using a wrapper for the parser, must the lex declaration. */
-#define YY_DECL int ragel_lex()
-
-%}
-
-/* Outside an fsm machine specification ("outside code"). */
-%x OC_SGL_LIT
-%x OC_DBL_LIT
-%x OC_C_COM
-%x OC_CXX_COM
-
-/* Inside a fsm machine specification. */
-%x RL_INITIAL
-%x RL_SLIT
-%x RL_DLIT
-%x RL_OREXP
-%x RL_REGEXP
-%x RL_REGEXP_OR
-%x RL_SHELL_COM
-%x RL_VERBOSE_EMBED
-%x RL_WRITE
-
-/* Inline code. */
-%x IL_INITIAL
-%x IL_SGL_LIT
-%x IL_DBL_LIT
-%x IL_C_COM
-%x IL_CXX_COM
-
-WSCHAR [\t\n\v\f\r ]
-IDENT [a-zA-Z_][a-zA-Z_0-9]*
-
-%%
-
- /* Numbers in outter code. */
-<INITIAL>[0-9]+ {
- garble();
- passThrough( yytext );
-}
-
- /* Words in outter code. */
-<INITIAL>{IDENT} {
- garble();
- passThrough( yytext );
-}
-
- /* Begin a c style comment. */
-<INITIAL>"/*" {
- BEGIN(OC_C_COM);
- extendToken();
- passThrough( yytext );
-}
- /* Data in a C style comment. */
-<OC_C_COM>. extendToken(); passThrough( yytext );
-<OC_C_COM>\n extendToken(); passThrough( yytext );
-
- /* Terminate a C style comment. */
-<OC_C_COM>"*/" {
- BEGIN(INITIAL);
- garble();
- passThrough( yytext );
-}
-
- /* Begin a C++ style comment. */
-<INITIAL>"//" {
- BEGIN(OC_CXX_COM);
- extendToken();
- passThrough( yytext );
-}
- /* Data in a C++ style comment. */
-<OC_CXX_COM>[^\n]+ {
- extendToken();
- passThrough( yytext );
-}
- /* Terminate a C++ style comment. */
-<OC_CXX_COM>\n {
- BEGIN(INITIAL);
- garble();
- passThrough( yytext );
-}
-
-
- /* Start literals. */
-<INITIAL>\' {
- BEGIN(OC_SGL_LIT);
- extendToken();
- passThrough( yytext );
-}
-<INITIAL>\" {
- BEGIN(OC_DBL_LIT);
- extendToken();
- passThrough( yytext );
-}
- /* Various escape sequences in literals. We don't need to get them
- * all here. We just need to pick off the ones that could confuse us
- * about the literal we are matchine */
-<OC_SGL_LIT,OC_DBL_LIT>\\\' extendToken(); passThrough( yytext );
-<OC_SGL_LIT,OC_DBL_LIT>\\\" extendToken(); passThrough( yytext );
-<OC_SGL_LIT,OC_DBL_LIT>\\\\ extendToken(); passThrough( yytext );
- /* Characters in literals. */
-<OC_DBL_LIT>[^\"] extendToken(); passThrough( yytext );
-<OC_SGL_LIT>[^\'] extendToken(); passThrough( yytext );
- /* Terminate a double literal */
-<OC_DBL_LIT>\" {
- BEGIN(INITIAL);
- garble();
- passThrough( yytext );
-}
- /* Terminate a single literal. */
-<OC_SGL_LIT>\' {
- BEGIN(INITIAL);
- garble();
- passThrough( yytext );
-}
-
- /* Whitespace. */
-<INITIAL>{WSCHAR}+ {
- garble();
- passThrough( yytext );
-}
-
- /* Section Deliminator */
-<INITIAL>"%%" {
- BEGIN(RL_INITIAL);
- multiline = false;
- return emitNoData( TK_Section );
-}
-
- /* Section Deliminator */
-<INITIAL>"%%{" {
- BEGIN(RL_INITIAL);
- multiline = true;
- return emitNoData( TK_Section );
-}
-
-<INITIAL>"{" {
- garble();
- passThrough( yytext );
-}
-
-<INITIAL>"}" {
- garble();
- passThrough( yytext );
-}
-
-<INITIAL>";" {
- garble();
- passThrough( yytext );
-}
-
- /* Any other characters. */
-<INITIAL>. {
- garble();
- passThrough( yytext );
-}
-
- /* Numbers. */
-<RL_INITIAL,IL_INITIAL>[0-9][0-9]* {
- return emitToken( TK_UInt, yytext, yyleng );
-}
-<RL_INITIAL,IL_INITIAL>0x[0-9a-fA-F][0-9a-fA-F]* {
- return emitToken( TK_Hex, yytext, yyleng );
-}
-
- /* Keywords in RL and IL. */
-<RL_INITIAL>variable\ [a-zA-Z_]+ {
- BEGIN(IL_INITIAL);
- inlineBlockType = SemiTerminated;
- return emitToken( KW_Variable, yytext+9, yyleng-9 );
-}
-<RL_INITIAL>access {
- BEGIN(IL_INITIAL);
- inlineBlockType = SemiTerminated;
- return emitNoData( KW_Access );
-}
-<RL_INITIAL>action {
- return emitNoData( KW_Action );
-}
-<RL_INITIAL>alphtype {
- BEGIN(IL_INITIAL);
- inlineWhitespace = false;
- inlineBlockType = SemiTerminated;
- return emitNoData( KW_AlphType );
-}
-<RL_INITIAL>getkey {
- BEGIN(IL_INITIAL);
- inlineBlockType = SemiTerminated;
- return emitNoData( KW_GetKey );
-}
-<RL_INITIAL>when {
- return emitNoData( KW_When );
-}
-<RL_INITIAL>eof {
- return emitNoData( KW_Eof );
-}
-<RL_INITIAL>err {
- return emitNoData( KW_Err );
-}
-<RL_INITIAL>lerr {
- return emitNoData( KW_Lerr );
-}
-<RL_INITIAL>to {
- return emitNoData( KW_To );
-}
-<RL_INITIAL>from {
- return emitNoData( KW_From );
-}
-
-
- /*
-<RL_INITIAL>range {
- return emitNoData( KW_Range );
-}*/
-
-<RL_INITIAL>write {
- BEGIN(RL_WRITE);
- return emitNoData( KW_Write );
-}
-<RL_INITIAL>machine {
- return emitNoData( KW_Machine );
-}
-<RL_INITIAL>include {
- /* Include tokens statments are processed by both the scanner and the
- * parser. The scanner opens the include file and switches to it and the
- * parser invokes a new parser for handling the tokens. We use
- * handlingInclude to indicate that the scanner is processing an include
- * directive. Ends at ; */
- handlingInclude = true;
- return emitNoData( KW_Include );
-}
-
-<RL_WRITE>{WSCHAR}+ garble();
-<RL_WRITE>; {
- BEGIN(RL_INITIAL);
- return emitNoData( ';' );
-}
-
- /* These must be synced in rlparse.y */
-<IL_INITIAL>fpc {
- return emitNoData( KW_PChar );
-}
-<IL_INITIAL>fc {
- return emitNoData( KW_Char );
-}
-<IL_INITIAL>fhold {
- return emitNoData( KW_Hold );
-}
-<IL_INITIAL>fgoto {
- return emitNoData( KW_Goto );
-}
-<IL_INITIAL>fcall {
- return emitNoData( KW_Call );
-}
-<IL_INITIAL>fret {
- return emitNoData( KW_Ret );
-}
-<IL_INITIAL>fcurs {
- return emitNoData( KW_CurState );
-}
-<IL_INITIAL>ftargs {
- return emitNoData( KW_TargState );
-}
-<IL_INITIAL>fentry {
- return emitNoData( KW_Entry );
-}
-<IL_INITIAL>fnext {
- return emitNoData( KW_Next );
-}
-<IL_INITIAL>fexec {
- return emitNoData( KW_Exec );
-}
-<IL_INITIAL>fbreak {
- return emitNoData( KW_Break );
-}
-
- /* Words. */
-<RL_INITIAL,IL_INITIAL,RL_WRITE>{IDENT} {
- return emitToken( TK_Word, yytext, yyleng );
-}
-
- /* Begin a shell style comment. */
-<RL_INITIAL># {
- BEGIN(RL_SHELL_COM);
- extendToken();
-}
- /* Data in a shell style comment. */
-<RL_SHELL_COM>[^\n]+ {
- extendToken();
-}
- /* Terminate a C++ style comment. */
-<RL_SHELL_COM>\n {
- BEGIN(RL_INITIAL);
- garble();
-}
-
- /*
- * Start single and double literals.
- */
-<RL_INITIAL>' {
- BEGIN(RL_SLIT);
- extendToken();
-}
-<RL_INITIAL>\" {
- BEGIN(RL_DLIT);
- extendToken();
-}
-
- /* Escape sequences in single and double literals. */
-<RL_SLIT,RL_DLIT>\\0 extendToken( "\0", 1 );
-<RL_SLIT,RL_DLIT>\\a extendToken( "\a", 1 );
-<RL_SLIT,RL_DLIT>\\b extendToken( "\b", 1 );
-<RL_SLIT,RL_DLIT>\\t extendToken( "\t", 1 );
-<RL_SLIT,RL_DLIT>\\n extendToken( "\n", 1 );
-<RL_SLIT,RL_DLIT>\\v extendToken( "\v", 1 );
-<RL_SLIT,RL_DLIT>\\f extendToken( "\f", 1 );
-<RL_SLIT,RL_DLIT>\\r extendToken( "\r", 1 );
-<RL_SLIT,RL_DLIT>\\\n extendToken();
-<RL_SLIT,RL_DLIT>\\. extendToken( yytext+1, 1 );
-
- /* Characters in literals. */
-<RL_SLIT>[^'] extendToken( yytext, 1 );
-<RL_DLIT>[^"] extendToken( yytext, 1 );
-
- /* Terminate a single literal. */
-<RL_SLIT>'[i]* {
- BEGIN(RL_INITIAL);
- return emitToken( yytext[1] == 'i' ? TK_CiLiteral : TK_Literal, 0, 0 );
-}
- /* Terminate a double literal */
-<RL_DLIT>\"[i]* {
- BEGIN(RL_INITIAL);
- return emitToken( yytext[1] == 'i' ? TK_CiLiteral : TK_Literal, 0, 0 );
-}
-
- /*
- * Start an OR expression.
- */
-<RL_INITIAL>"[" {
- BEGIN(RL_OREXP);
- return emitNoData( RE_SqOpen );
-}
-
-<RL_INITIAL>"\[^" {
- BEGIN(RL_OREXP);
- return emitNoData( RE_SqOpenNeg );
-}
-
- /* Escape sequences in OR expressions. */
-<RL_OREXP>\\0 { return emitToken( RE_Char, "\0", 1 ); }
-<RL_OREXP>\\a { return emitToken( RE_Char, "\a", 1 ); }
-<RL_OREXP>\\b { return emitToken( RE_Char, "\b", 1 ); }
-<RL_OREXP>\\t { return emitToken( RE_Char, "\t", 1 ); }
-<RL_OREXP>\\n { return emitToken( RE_Char, "\n", 1 ); }
-<RL_OREXP>\\v { return emitToken( RE_Char, "\v", 1 ); }
-<RL_OREXP>\\f { return emitToken( RE_Char, "\f", 1 ); }
-<RL_OREXP>\\r { return emitToken( RE_Char, "\r", 1 ); }
-<RL_OREXP>\\\n { garble(); }
-<RL_OREXP>\\. { return emitToken( RE_Char, yytext+1, 1 ); }
-
- /* Range dash in an OR expression. */
-<RL_OREXP>- {
- return emitNoData( RE_Dash );
-}
-
- /* Characters in an OR expression. */
-<RL_OREXP>[^\]] {
- return emitToken( RE_Char, yytext, 1 );
-}
-
- /* Terminate an OR expression. */
-<RL_OREXP>\] {
- BEGIN(RL_INITIAL);
- return emitNoData( RE_SqClose );
-}
-
- /*
- * Start a regular expression.
- */
-<RL_INITIAL>\/ {
- BEGIN(RL_REGEXP);
- return emitNoData( RE_Slash );
-}
-
- /* Escape sequences in regular expressions. */
-<RL_REGEXP,RL_REGEXP_OR>\\0 {
- return emitToken( RE_Char, "\0", 1 );
-}
-<RL_REGEXP,RL_REGEXP_OR>\\a {
- return emitToken( RE_Char, "\a", 1 );
-}
-<RL_REGEXP,RL_REGEXP_OR>\\b {
- return emitToken( RE_Char, "\b", 1 );
-}
-<RL_REGEXP,RL_REGEXP_OR>\\t {
- return emitToken( RE_Char, "\t", 1 );
-}
-<RL_REGEXP,RL_REGEXP_OR>\\n {
- return emitToken( RE_Char, "\n", 1 );
-}
-<RL_REGEXP,RL_REGEXP_OR>\\v {
- return emitToken( RE_Char, "\v", 1 );
-}
-<RL_REGEXP,RL_REGEXP_OR>\\f {
- return emitToken( RE_Char, "\f", 1 );
-}
-<RL_REGEXP,RL_REGEXP_OR>\\r {
- return emitToken( RE_Char, "\r", 1 );
-}
-<RL_REGEXP,RL_REGEXP_OR>\\\n {
- garble();
-}
-<RL_REGEXP,RL_REGEXP_OR>\\. {
- return emitToken( RE_Char, yytext+1, 1 );
-}
-
- /* Special characters in a regular expression. */
-<RL_REGEXP>\. {
- return emitNoData( RE_Dot );
-}
-<RL_REGEXP>\* {
- return emitNoData( RE_Star );
-}
-<RL_REGEXP>"\[^" {
- BEGIN(RL_REGEXP_OR);
- return emitNoData( RE_SqOpenNeg );
-}
-<RL_REGEXP>"\[" {
- BEGIN(RL_REGEXP_OR);
- return emitNoData( RE_SqOpen );
-}
-
- /* Range dash in a regular expression or set. */
-<RL_REGEXP_OR>- {
- return emitNoData( RE_Dash );
-}
-
- /* Terminate an or set or a regular expression. */
-<RL_REGEXP_OR>\] {
- BEGIN(RL_REGEXP);
- return emitNoData( RE_SqClose );
-}
-
- /* Characters in a regular expression. */
-<RL_REGEXP,RL_REGEXP_OR>[^/] {
- return emitToken( RE_Char, yytext, 1 );
-}
-
- /* Terminate a regular expression */
-<RL_REGEXP,RL_REGEXP_OR>\/[i]* {
- BEGIN(RL_INITIAL);
- return emitToken( RE_Slash, yytext, yyleng );
-}
-
- /* Builtin code move to Builtin initial. */
-<RL_INITIAL>"{" {
- if ( openMachineSpecBlock() ) {
- /* Plain bracket. */
- return emitNoData( *yytext );
- }
- else {
- /* Start an inline code block. Keep track of where it started in case
- * it terminates prematurely. Return the open bracket. */
- BEGIN(IL_INITIAL);
- inlineBlockType = CurlyDelimited;
- il_code_first_line = id->last_line;
- il_code_first_column = id->last_column+1;
- builtinBrace++;
- return emitNoData( *yytext );
- }
-}
-
-<RL_INITIAL>\.\. {
- return emitNoData( TK_DotDot );
-}
-
-<RL_INITIAL>:> {
- return emitNoData( TK_ColonGt );
-}
-
-<RL_INITIAL>:>> {
- return emitNoData( TK_ColonGtGt );
-}
-
-<RL_INITIAL><: {
- return emitNoData( TK_LtColon );
-}
-
-<RL_INITIAL>-- {
- return emitNoData( TK_DashDash );
-}
-
- /* The instantiation operator. */
-<RL_INITIAL>:= {
- return emitNoData( TK_ColonEquals );
-}
-
- /* Error actions. */
-<RL_INITIAL>\>\! {
- return emitNoData( TK_StartGblError );
-}
-<RL_INITIAL>\$\! {
- return emitNoData( TK_AllGblError );
-}
-<RL_INITIAL>%\! {
- return emitNoData( TK_FinalGblError );
-}
-<RL_INITIAL><\! {
- return emitNoData( TK_NotStartGblError );
-}
-<RL_INITIAL>@\! {
- return emitNoData( TK_NotFinalGblError );
-}
-<RL_INITIAL><>\! {
- return emitNoData( TK_MiddleGblError );
-}
-
- /* Local error actions. */
-<RL_INITIAL>\>\^ {
- return emitNoData( TK_StartLocalError );
-}
-<RL_INITIAL>\$\^ {
- return emitNoData( TK_AllLocalError );
-}
-<RL_INITIAL>%\^ {
- return emitNoData( TK_FinalLocalError );
-}
-<RL_INITIAL><\^ {
- return emitNoData( TK_NotStartLocalError );
-}
-<RL_INITIAL>@\^ {
- return emitNoData( TK_NotFinalLocalError );
-}
-<RL_INITIAL><>\^ {
- return emitNoData( TK_MiddleLocalError );
-}
-
- /* EOF Actions. */
-<RL_INITIAL>\>\/ {
- return emitNoData( TK_StartEOF );
-}
-<RL_INITIAL>\$\/ {
- return emitNoData( TK_AllEOF );
-}
-<RL_INITIAL>%\/ {
- return emitNoData( TK_FinalEOF );
-}
-<RL_INITIAL><\/ {
- return emitNoData( TK_NotStartEOF );
-}
-<RL_INITIAL>@\/ {
- return emitNoData( TK_NotFinalEOF );
-}
-<RL_INITIAL><>\/ {
- return emitNoData( TK_MiddleEOF );
-}
-
- /* To State Actions. */
-<RL_INITIAL>\>~ {
- return emitNoData( TK_StartToState );
-}
-<RL_INITIAL>\$~ {
- return emitNoData( TK_AllToState );
-}
-<RL_INITIAL>%~ {
- return emitNoData( TK_FinalToState );
-}
-<RL_INITIAL><~ {
- return emitNoData( TK_NotStartToState );
-}
-<RL_INITIAL>@~ {
- return emitNoData( TK_NotFinalToState );
-}
-<RL_INITIAL><>~ {
- return emitNoData( TK_MiddleToState );
-}
-
- /* From State Actions. */
-<RL_INITIAL>\>\* {
- return emitNoData( TK_StartFromState );
-}
-<RL_INITIAL>\$\* {
- return emitNoData( TK_AllFromState );
-}
-<RL_INITIAL>%\* {
- return emitNoData( TK_FinalFromState );
-}
-<RL_INITIAL><\* {
- return emitNoData( TK_NotStartFromState );
-}
-<RL_INITIAL>@\* {
- return emitNoData( TK_NotFinalFromState );
-}
-<RL_INITIAL><>\* {
- return emitNoData( TK_MiddleFromState );
-}
-
-<RL_INITIAL><> {
- return emitNoData( TK_Middle );
-}
-
-<RL_INITIAL>\>\? {
- return emitNoData( TK_StartCond );
-}
-<RL_INITIAL>\$\? {
- return emitNoData( TK_AllCond );
-}
-<RL_INITIAL>%\? {
- return emitNoData( TK_LeavingCond );
-}
-
- /* The Arrow operator. */
-<RL_INITIAL>-> {
- return emitNoData( TK_Arrow );
-}
-
- /* The double arrow operator. */
-<RL_INITIAL>=> {
- return emitNoData( TK_DoubleArrow );
-}
-
- /* Double star (longest match kleene star). */
-<RL_INITIAL>\*\* {
- return emitNoData( TK_StarStar );
-}
-
- /* Name separator. */
-<RL_INITIAL>:: {
- return emitNoData( TK_NameSep );
-}
-
- /* Opening of longest match. */
-<RL_INITIAL>\|\* {
- return emitNoData( TK_BarStar );
-}
-
- /* Catch the repetition operator now to free up the parser. Once caught,
- * Send only the opening brace and rescan the rest so it can be broken
- * up for the parser. */
-<RL_INITIAL>\{([0-9]+(,[0-9]*)?|,[0-9]+)\} {
- yyless(1);
- return emitNoData( TK_RepOpOpen );
-}
-
- /* Section Deliminator */
-<RL_INITIAL>"}%%" {
- BEGIN(INITIAL);
- return emitNoData( TK_Section );
-}
-
- /* Whitespace. */
-<RL_INITIAL>[\t\v\f\r ] garble();
-<RL_INITIAL>\n {
- if ( multiline )
- garble();
- else {
- BEGIN(INITIAL);
- return emitNoData( TK_SectionNL );
- }
-}
-
- /* Any other characters. */
-<RL_INITIAL>. {
- return emitNoData( *yytext );
-}
-
- /* End of input in a literal is an error. */
-<RL_SLIT,RL_DLIT><<EOF>> {
- error(id->first_line, id->first_column) << "unterminated literal" << endl;
- exit(1);
-}
-
- /* End of input in a comment is an error. */
-<RL_SHELL_COM><<EOF>> {
- error(id->first_line, id->first_column) << "unterminated comment" << endl;
- exit(1);
-}
-
- /* Begin a C style comment. */
-<IL_INITIAL>"/*" {
- BEGIN(IL_C_COM);
- il_comm_lit_first_line = id->last_line;
- il_comm_lit_first_column = id->last_column+1;
- extendToken( yytext, yyleng );
-}
- /* Data in a C style comment. */
-<IL_C_COM>\n extendToken( yytext, 1 );
-<IL_C_COM>. extendToken( yytext, 1 );
-
- /* Terminate a C style comment. */
-<IL_C_COM>"*/" {
- BEGIN(IL_INITIAL);
- return emitToken( IL_Comment, yytext, 2 );
-}
-
- /* Begin a C++ style comment. */
-<IL_INITIAL>"//" {
- BEGIN(IL_CXX_COM);
- il_comm_lit_first_line = id->last_line;
- il_comm_lit_first_column = id->last_column+1;
- extendToken( yytext, yyleng );
-}
- /* Data in a C++ style comment. */
-<IL_CXX_COM>[^\n]+ {
- extendToken( yytext, yyleng );
-}
- /* Terminate a C++ style comment. */
-<IL_CXX_COM>\n {
- BEGIN(IL_INITIAL);
- return emitToken( IL_Comment, yytext, 1 );
-}
-
-
- /* Start literals. */
-<IL_INITIAL>' {
- BEGIN(IL_SGL_LIT);
- il_comm_lit_first_line = id->last_line;
- il_comm_lit_first_column = id->last_column+1;
- extendToken( yytext, 1 );
-}
-<IL_INITIAL>\" {
- BEGIN(IL_DBL_LIT);
- il_comm_lit_first_line = id->last_line;
- il_comm_lit_first_column = id->last_column+1;
- extendToken( yytext, 1 );
-}
- /* Various escape sequences in literals. We don't need to get them
- * all here. We just need to pick off the ones that could confuse us
- * about the literal we are matching */
-<IL_SGL_LIT,IL_DBL_LIT>\\' extendToken( yytext, yyleng );
-<IL_SGL_LIT,IL_DBL_LIT>\\\" extendToken( yytext, yyleng );
-<IL_SGL_LIT,IL_DBL_LIT>\\\\ extendToken( yytext, yyleng );
- /* Characters in literals. */
-<IL_DBL_LIT>[^\"] extendToken( yytext, 1 );
-<IL_SGL_LIT>[^'] extendToken( yytext, 1 );
-
- /* Terminate a double literal */
-<IL_DBL_LIT>\" {
- BEGIN(IL_INITIAL);
- return emitToken( IL_Literal, yytext, 1 );
-}
- /* Terminate a single literal. */
-<IL_SGL_LIT>' {
- BEGIN(IL_INITIAL);
- return emitToken( IL_Literal, yytext, 1 );
-}
-
- /* Open Brace, increment count of open braces. */
-<IL_INITIAL>"{" {
- builtinBrace++;
- return emitToken( IL_Symbol, yytext, 1 );
-}
-
- /* Close brace, decrement count of open braces. */
-<IL_INITIAL>"}" {
- builtinBrace--;
- if ( inlineBlockType == CurlyDelimited && builtinBrace == 0 ) {
- /* Inline code block ends. */
- BEGIN(RL_INITIAL);
- inlineWhitespace = true;
- return emitNoData( *yytext );
- }
- else {
- /* Either a semi terminated inline block or only the closing brace of
- * some inner scope, not the block's closing brace. */
- return emitToken( IL_Symbol, yytext, 1 );
- }
-}
-
- /* May need to terminate the inline block. */
-<IL_INITIAL>; {
- if ( inlineBlockType == SemiTerminated ) {
- /* Inline code block ends. */
- BEGIN(RL_INITIAL);
- inlineWhitespace = true;
- return emitNoData( TK_Semi );
- }
- else {
- /* Not ending. The semi is sent as a token, not a generic symbol. */
- return emitNoData( *yytext );
- }
-}
-
- /* Catch some symbols so they can be
- * sent as tokens instead as generic symbols. */
-<IL_INITIAL>[*()] {
- return emitNoData( *yytext );
-}
-<IL_INITIAL>:: {
- return emitNoData( TK_NameSep );
-}
-
- /* Whitespace. */
-<IL_INITIAL>{WSCHAR}+ {
- if ( inlineWhitespace )
- return emitToken( IL_WhiteSpace, yytext, yyleng );
-}
-
- /* Any other characters. */
-<IL_INITIAL>. {
- return emitToken( IL_Symbol, yytext, 1 );
-}
-
-<INITIAL><<EOF>> {
- /* If we are not at the bottom of the include stack, then pop the current
- * file that we are scanning. Since we are always returning 0 to the parser
- * it will exit and return to the parser that called it. */
- if ( inc_stack_ptr > 0 )
- popInclude();
- return 0;
-}
-
- /* End of input in a literal is an error. */
-<IL_SGL_LIT,IL_DBL_LIT><<EOF>> {
- error(il_comm_lit_first_line, il_comm_lit_first_column) <<
- "unterminated literal" << endl;
- exit(1);
-}
-
- /* End of input in a comment is an error. */
-<IL_C_COM,IL_CXX_COM><<EOF>> {
- error(il_comm_lit_first_line, il_comm_lit_first_column) <<
- "unterminated comment" << endl;
- exit(1);
-}
-
- /* End of intput in a code block. */
-<IL_INITIAL><<EOF>> {
- error(il_code_first_line, il_code_first_column) <<
- "unterminated code block" << endl;
- exit(1);
-}
-
-%%
-
-/* Write out token data, escaping special charachters. */
-#ifdef WANT_TOKEN_WRITE
-void writeToken( int token, char *data )
-{
- cout << "token id " << token << " at " << id->fileName << ":" <<
- yylloc->first_line << ":" << yylloc->first_column << "-" <<
- yylloc->last_line << ":" << yylloc->last_column << " ";
-
- if ( data != 0 ) {
- while ( *data != 0 ) {
- switch ( *data ) {
- case '\n': cout << "\\n"; break;
- case '\t': cout << "\\t"; break;
- default: cout << *data; break;
- }
- data += 1;
- }
- }
- cout << endl;
-}
-#endif
-
-/* Caclulate line info from yytext. Called on every pattern match. */
-void updateLineInfo()
-{
- /* yytext should always have at least one char. */
- assert( yytext[0] != 0 );
-
- /* Scan through yytext up to the last character. */
- char *p = yytext;
- for ( ; p[1] != 0; p++ ) {
- if ( p[0] == '\n' ) {
- id->last_line += 1;
- id->last_column = 0;
- }
- else {
- id->last_column += 1;
- }
- }
-
- /* Always consider the last character as not a newline. Newlines at the
- * end of a token are as any old character at the end of the line. */
- id->last_column += 1;
-
- /* The caller may be about to emit a token, be prepared to pass the line
- * info to the parser. */
- yylloc->first_line = id->first_line;
- yylloc->first_column = id->first_column;
- yylloc->last_line = id->last_line;
- yylloc->last_column = id->last_column;
-
- /* If the last character was indeed a newline, then wrap ahead now. */
- if ( p[0] == '\n' ) {
- id->last_line += 1;
- id->last_column = 0;
- }
-}
-
-/* Eat up a matched pattern that will not be part of a token. */
-void garble()
-{
- /* Update line information from yytext. */
- updateLineInfo();
-
- /* The next token starts ahead of the last token. */
- id->first_line = id->last_line;
- id->first_column = id->last_column + 1;
-}
-
-/* Append data to the end of the token. More token data expected. */
-void extendToken( char *data, int len )
-{
- if ( data != 0 && len > 0 )
- tokbuf.append( data, len );
-
- /* Update line information from yytext. */
- updateLineInfo();
-}
-
-/* Extend, but with no data, more data to come. */
-void extendToken()
-{
- /* Update line information from yytext. */
- updateLineInfo();
-}
-
-
-/* Possibly process include data. */
-void processInclude( int token )
-{
- static char *incFileName = 0;
-
- if ( handlingInclude ) {
- if ( token == KW_Include )
- incFileName = 0;
- else if ( token == TK_Literal )
- incFileName = yylval->data.data;
- else if ( token == ';' ) {
- /* Terminate the include statement. Start reading from included file. */
- handlingInclude = false;
-
- if ( id->active && includeDepth < INCLUDE_STACK_SIZE ) {
- /* If there is no section name or input file, default to the curren values. */
- if ( incFileName == 0 )
- incFileName = id->fileName;
-
- /* Make the new buffer and switch to it. */
- FILE *incFile = fopen( incFileName, "rt" );
- if ( incFile != 0 ) {
- buff_stack[inc_stack_ptr] = YY_CURRENT_BUFFER;
- multiline_stack[inc_stack_ptr] = multiline;
- inc_stack_ptr += 1;
- yy_switch_to_buffer( yy_create_buffer( incFile, YY_BUF_SIZE ) );
- BEGIN(INITIAL);
- }
- else {
- error(*yylloc) << "could not locate include file \"" << incFileName
- << "\"" << endl;
- }
- }
- }
- }
-}
-
-void popInclude()
-{
- /* Free the current buffer and move to the previous. */
- yy_delete_buffer( YY_CURRENT_BUFFER );
- inc_stack_ptr -= 1;
- yy_switch_to_buffer( buff_stack[inc_stack_ptr] );
- multiline = multiline_stack[inc_stack_ptr];
-
- /* Includes get called only from RL_INITIAL. */
- BEGIN(RL_INITIAL);
-}
-
-
-/* Append data to the end of a token and emitToken it to the parser. */
-int emitToken( int token, char *data, int len )
-{
- /* Append any new data. */
- if ( data != 0 && len > 0 )
- tokbuf.append( data, len );
-
- /* Duplicate the buffer. */
- yylval->data.length = tokbuf.length;
- yylval->data.data = new char[tokbuf.length+1];
- memcpy( yylval->data.data, tokbuf.data, tokbuf.length );
- yylval->data.data[tokbuf.length] = 0;
-
- /* Update line information from yytext. */
- updateLineInfo();
-
- /* Write token info. */
-#ifdef WANT_TOKEN_WRITE
- writeToken( token, tokbuf.data );
-#endif
-
- /* Clear out the buffer. */
- tokbuf.clear();
-
- /* The next token starts ahead of the last token. */
- id->first_line = id->last_line;
- id->first_column = id->last_column + 1;
-
- /* Maintain a record of two tokens back. */
- previous_tokens[1] = previous_tokens[0];
- previous_tokens[0] = token;
-
- /* Possibly process the include statement; */
- processInclude( token );
-
- return token;
-}
-
-/* Emit a token with no data to the parser. */
-int emitNoData( int token )
-{
- /* Return null to the parser. */
- yylval->data.data = 0;
- yylval->data.length = 0;
-
- /* Update line information from yytext. */
- updateLineInfo();
-
- /* Write token info. */
-#ifdef WANT_TOKEN_WRITE
- writeToken( token, 0 );
-#endif
-
- /* Clear out the buffer. */
- tokbuf.clear();
-
- /* The next token starts ahead of the last token. */
- id->first_line = id->last_line;
- id->first_column = id->last_column + 1;
-
- /* Maintain a record of two tokens back. */
- previous_tokens[1] = previous_tokens[0];
- previous_tokens[0] = token;
-
- /* Possibly process the include statement; */
- processInclude( token );
-
- return token;
-}
-
-/* Pass tokens in outter code through to the output. */
-void passThrough( char *data )
-{
- /* If no errors and we are at the bottom of the include stack (the source
- * file listed on the command line) then write out the data. */
- if ( gblErrorCount == 0 && inc_stack_ptr == 0 &&
- machineSpec == 0 && machineName == 0 )
- {
- xmlEscapeHost( *outStream, data );
- }
-}
-
-/* Init a buffer. */
-Buffer::Buffer()
-:
- data(0),
- length(0),
- allocated(0)
-{
-}
-
-/* Empty out a buffer on destruction. */
-Buffer::~Buffer()
-{
- empty();
-}
-
-/* Free the space allocated for the buffer. */
-void Buffer::empty()
-{
- if ( data != 0 ) {
- free( data );
-
- data = 0;
- length = 0;
- allocated = 0;
- }
-}
-
-/* Grow the buffer when to len allocation. */
-void Buffer::upAllocate( int len )
-{
- if ( data == 0 )
- data = (char*) malloc( len );
- else
- data = (char*) realloc( data, len );
- allocated = len;
-}
-
-int yywrap()
-{
- /* Once processessing of the input is done, signal no more. */
- return 1;
-}
-
-/* Here simply to suppress the unused yyunpt warning. */
-void thisFuncIsNeverCalled()
-{
- yyunput(0, 0);
-}
-
-/* Put the scannner back into the outside code start state. */
-void beginOutsideCode()
-{
- BEGIN(INITIAL);
-}
-
-/* Determine if we are opening a machine specification block. */
-bool openMachineSpecBlock()
-{
- if ( previous_tokens[1] == TK_Section && previous_tokens[0] == TK_Word )
- return true;
- else if ( previous_tokens[0] == TK_Section )
- return true;
- return false;
-}
-
-/* Wrapper for the lexer which stores the locations of the value and location
- * variables of the parser into globals. The parser is reentrant, however the scanner
- * does not need to be, so globals work fine. This saves us passing them around
- * all the helper functions. */
-int yylex( YYSTYPE *yylval, YYLTYPE *yylloc )
-{
- ::yylval = yylval;
- ::yylloc = yylloc;
- return ragel_lex();
-}
-
+++ /dev/null
-#
-# Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
-#
-
-# This file is part of Ragel.
-#
-# Ragel is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Ragel is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ragel; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-INCS += -I../common -I../aapl
-DEFS +=
-
-CFLAGS += -g -Wall
-LDFLAGS +=
-
-CC_SRCS = \
- gendata.cpp xmltags.cpp xmlscan.cpp xmlparse.cpp \
- main.cpp redfsm.cpp gvdotgen.cpp fsmcodegen.cpp \
- tabcodegen.cpp ftabcodegen.cpp flatcodegen.cpp \
- fflatcodegen.cpp gotocodegen.cpp fgotocodegen.cpp \
- ipgotocodegen.cpp splitcodegen.cpp javacodegen.cpp
-
-GEN_SRC = xmltags.cpp xmlscan.cpp xmlparse.cpp xmlparse.h
-
-LIBS += @LIBS@
-PREFIX += @prefix@
-
-BUILD_PARSERS = @BUILD_PARSERS@
-
-#*************************************
-
-# Programs
-CXX = @CXX@
-
-# Get objects and dependencies from sources.
-OBJS = $(CC_SRCS:%.cpp=%.o)
-DEPS = $(CC_SRCS:%.cpp=.%.d)
-
-# Get the version info.
-include ../version.mk
-
-# Rules.
-all: rlcodegen
-
-rlcodegen: $(GEN_SRC) $(OBJS)
- $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
-
-ifeq ($(BUILD_PARSERS),true)
-
-xmlparse.h: xmlparse.kh
- kelbt -o $@ $<
-
-xmlparse.cpp: xmlparse.kl xmlparse.kh
- kelbt -o $@ $<
-
-xmlscan.cpp: xmlscan.rl
- ragel xmlscan.rl | rlcodegen -G2 -o xmlscan.cpp
-
-xmltags.cpp: xmltags.gperf
- gperf -L C++ -t $< > $@
-
-endif
-
-%.o: %.cpp
- @$(CXX) -M $(DEFS) $(INCS) $< > .$*.d
- $(CXX) -c $(CFLAGS) $(DEFS) $(INCS) -o $@ $<
-
-distclean: clean
- rm -f Makefile
-
-ifeq ($(BUILD_PARSERS),true)
-EXTRA_CLEAN = $(GEN_SRC)
-endif
-
-clean:
- rm -f tags .*.d *.o rlcodegen $(EXTRA_CLEAN)
-
-install: all
- install -d $(PREFIX)/bin
- install -s rlcodegen $(PREFIX)/bin/rlcodegen
-
--include $(DEPS)
+++ /dev/null
-/*
- * Copyright 2004-2006 Adrian Thurston <thurston@cs.queensu.ca>
- * 2004 Eric Ocean <eric.ocean@ampede.com>
- * 2005 Alan West <alan@alanz.com>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "rlcodegen.h"
-#include "fflatcodegen.h"
-#include "redfsm.h"
-#include "gendata.h"
-
-std::ostream &FFlatCodeGen::TO_STATE_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->toStateAction != 0 )
- act = state->toStateAction->actListId+1;
- out << act;
- return out;
-}
-
-std::ostream &FFlatCodeGen::FROM_STATE_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->fromStateAction != 0 )
- act = state->fromStateAction->actListId+1;
- out << act;
- return out;
-}
-
-std::ostream &FFlatCodeGen::EOF_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->eofAction != 0 )
- act = state->eofAction->actListId+1;
- out << act;
- return out;
-}
-
-/* Write out the function for a transition. */
-std::ostream &FFlatCodeGen::TRANS_ACTION( RedTransAp *trans )
-{
- int action = 0;
- if ( trans->action != 0 )
- action = trans->action->actListId+1;
- out << action;
- return out;
-}
-
-/* Write out the function switch. This switch is keyed on the values
- * of the func index. */
-std::ostream &FFlatCodeGen::TO_STATE_ACTION_SWITCH()
-{
- /* Loop the actions. */
- for ( ActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
- if ( redAct->numToStateRefs > 0 ) {
- /* Write the entry label. */
- out << "\tcase " << redAct->actListId+1 << ":\n";
-
- /* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
- ACTION( out, item->value, 0, false );
-
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-/* Write out the function switch. This switch is keyed on the values
- * of the func index. */
-std::ostream &FFlatCodeGen::FROM_STATE_ACTION_SWITCH()
-{
- /* Loop the actions. */
- for ( ActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
- if ( redAct->numFromStateRefs > 0 ) {
- /* Write the entry label. */
- out << "\tcase " << redAct->actListId+1 << ":\n";
-
- /* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
- ACTION( out, item->value, 0, false );
-
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-std::ostream &FFlatCodeGen::EOF_ACTION_SWITCH()
-{
- /* Loop the actions. */
- for ( ActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
- if ( redAct->numEofRefs > 0 ) {
- /* Write the entry label. */
- out << "\tcase " << redAct->actListId+1 << ":\n";
-
- /* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
- ACTION( out, item->value, 0, true );
-
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-/* Write out the function switch. This switch is keyed on the values
- * of the func index. */
-std::ostream &FFlatCodeGen::ACTION_SWITCH()
-{
- /* Loop the actions. */
- for ( ActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
- if ( redAct->numTransRefs > 0 ) {
- /* Write the entry label. */
- out << "\tcase " << redAct->actListId+1 << ":\n";
-
- /* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
- ACTION( out, item->value, 0, false );
-
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-void FFlatCodeGen::writeOutData()
-{
- if ( anyConditions() ) {
- OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() );
- COND_KEYS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxCondSpan), CSP() );
- COND_KEY_SPANS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxCond), C() );
- CONDS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxCondIndexOffset), CO() );
- COND_INDEX_OFFSET();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- OPEN_ARRAY( WIDE_ALPH_TYPE(), K() );
- KEYS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxSpan), SP() );
- KEY_SPANS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxFlatIndexOffset), IO() );
- FLAT_INDEX_OFFSET();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxIndex), I() );
- INDICIES();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxState), TT() );
- TRANS_TARGS();
- CLOSE_ARRAY() <<
- "\n";
-
- if ( anyActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActListId), TA() );
- TRANS_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- if ( anyToStateActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), TSA() );
- TO_STATE_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- if ( anyFromStateActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), FSA() );
- FROM_STATE_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- if ( anyEofActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActListId), EA() );
- EOF_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- out <<
- "static const int " << START() << " = " << START_STATE_ID() << ";\n"
- "\n";
-
- if ( cgd->writeFirstFinal ) {
- out <<
- "static const int " << FIRST_FINAL() << " = " << FIRST_FINAL_STATE() << ";\n"
- "\n";
- }
-
- if ( cgd->writeErr ) {
- out <<
- "static const int " << ERROR() << " = " << ERROR_STATE() << ";\n"
- "\n";
- }
-}
-
-void FFlatCodeGen::writeOutExec()
-{
- outLabelUsed = false;
-
- out <<
- " {\n"
- " int _slen";
-
- if ( anyRegCurStateRef() )
- out << ", _ps";
-
- out << ";\n";
- out << " int _trans";
-
- if ( anyConditions() )
- out << ", _cond";
-
- out << ";\n";
-
- out <<
- " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_keys;\n"
- " " << PTR_CONST() << ARRAY_TYPE(maxIndex) << POINTER() << "_inds;\n";
-
- if ( anyConditions() ) {
- out <<
- " " << PTR_CONST() << ARRAY_TYPE(maxCond) << POINTER() << "_conds;\n"
- " " << WIDE_ALPH_TYPE() << " _widec;\n";
- }
-
- if ( cgd->hasEnd ) {
- outLabelUsed = true;
- out <<
- " if ( " << P() << " == " << PE() << " )\n"
- " goto _out;\n";
- }
-
- out << "_resume:\n";
-
- if ( redFsm->errState != 0 ) {
- outLabelUsed = true;
- out <<
- " if ( " << CS() << " == " << redFsm->errState->id << " )\n"
- " goto _out;\n";
- }
-
- if ( anyFromStateActions() ) {
- out <<
- " switch ( " << FSA() << "[" << CS() << "] ) {\n";
- FROM_STATE_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- "\n";
- }
-
- if ( anyConditions() )
- COND_TRANSLATE();
-
- LOCATE_TRANS();
-
- if ( anyRegCurStateRef() )
- out << " _ps = " << CS() << ";\n";
-
- out <<
- " " << CS() << " = " << TT() << "[_trans];\n\n";
-
- if ( anyRegActions() ) {
- out <<
- " if ( " << TA() << "[_trans] == 0 )\n"
- " goto _again;\n"
- "\n"
- " switch ( " << TA() << "[_trans] ) {\n";
- ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- "\n";
- }
-
- if ( anyRegActions() || anyActionGotos() || anyActionCalls() || anyActionRets() )
- out << "_again:\n";
-
- if ( anyToStateActions() ) {
- out <<
- " switch ( " << TSA() << "[" << CS() << "] ) {\n";
- TO_STATE_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- "\n";
- }
-
- if ( cgd->hasEnd ) {
- out <<
- " if ( ++" << P() << " != " << PE() << " )\n"
- " goto _resume;\n";
- }
- else {
- out <<
- " " << P() << " += 1;\n"
- " goto _resume;\n";
- }
-
- if ( outLabelUsed )
- out << " _out: {}\n";
-
- out << " }\n";
-}
-
-void FFlatCodeGen::writeOutEOF()
-{
- if ( anyEofActions() ) {
- out <<
- " {\n"
- " switch ( " << EA() << "[" << CS() << "] ) {\n";
- EOF_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- "\n";
- }
-}
+++ /dev/null
-/*
- * Copyright 2004-2006 Adrian Thurston <thurston@cs.queensu.ca>
- * 2004 Eric Ocean <eric.ocean@ampede.com>
- * 2005 Alan West <alan@alanz.com>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _FFLATCODEGEN_H
-#define _FFLATCODEGEN_H
-
-#include <iostream>
-#include "flatcodegen.h"
-
-/* Forwards. */
-struct CodeGenData;
-
-/*
- * FFlatCodeGen
- */
-class FFlatCodeGen : public FlatCodeGen
-{
-protected:
- std::ostream &TO_STATE_ACTION_SWITCH();
- std::ostream &FROM_STATE_ACTION_SWITCH();
- std::ostream &EOF_ACTION_SWITCH();
- std::ostream &ACTION_SWITCH();
-
- virtual std::ostream &TO_STATE_ACTION( RedStateAp *state );
- virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state );
- virtual std::ostream &EOF_ACTION( RedStateAp *state );
- virtual std::ostream &TRANS_ACTION( RedTransAp *trans );
-
- virtual void writeOutData();
- virtual void writeOutEOF();
- virtual void writeOutExec();
-};
-
-/*
- * CFFlatCodeGen
- */
-struct CFFlatCodeGen
- : public FFlatCodeGen, public CCodeGen
-{
-};
-
-/*
- * DFFlatCodeGen
- */
-struct DFFlatCodeGen
- : public FFlatCodeGen, public DCodeGen
-{
-};
-
-#endif /* _FFLATCODEGEN_H */
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- * 2004 Eric Ocean <eric.ocean@ampede.com>
- * 2005 Alan West <alan@alanz.com>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "rlcodegen.h"
-#include "fgotocodegen.h"
-#include "redfsm.h"
-#include "gendata.h"
-#include "bstmap.h"
-
-std::ostream &FGotoCodeGen::EXEC_ACTIONS()
-{
- /* Loop the actions. */
- for ( ActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
- if ( redAct->numTransRefs > 0 ) {
- /* We are at the start of a glob, write the case. */
- out << "f" << redAct->actListId << ":\n";
-
- /* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
- ACTION( out, item->value, 0, false );
-
- out << "\tgoto _again;\n";
- }
- }
- return out;
-}
-
-/* Write out the function switch. This switch is keyed on the values
- * of the func index. */
-std::ostream &FGotoCodeGen::TO_STATE_ACTION_SWITCH()
-{
- /* Loop the actions. */
- for ( ActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
- if ( redAct->numToStateRefs > 0 ) {
- /* Write the entry label. */
- out << "\tcase " << redAct->actListId+1 << ":\n";
-
- /* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
- ACTION( out, item->value, 0, false );
-
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-/* Write out the function switch. This switch is keyed on the values
- * of the func index. */
-std::ostream &FGotoCodeGen::FROM_STATE_ACTION_SWITCH()
-{
- /* Loop the actions. */
- for ( ActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
- if ( redAct->numFromStateRefs > 0 ) {
- /* Write the entry label. */
- out << "\tcase " << redAct->actListId+1 << ":\n";
-
- /* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
- ACTION( out, item->value, 0, false );
-
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-std::ostream &FGotoCodeGen::EOF_ACTION_SWITCH()
-{
- /* Loop the actions. */
- for ( ActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
- if ( redAct->numEofRefs > 0 ) {
- /* Write the entry label. */
- out << "\tcase " << redAct->actListId+1 << ":\n";
-
- /* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
- ACTION( out, item->value, 0, true );
-
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-
-std::ostream &FGotoCodeGen::FINISH_CASES()
-{
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* States that are final and have an out action need a case. */
- if ( st->eofAction != 0 ) {
- /* Write the case label. */
- out << "\t\tcase " << st->id << ": ";
-
- /* Jump to the func. */
- out << "goto f" << st->eofAction->actListId << ";\n";
- }
- }
-
- return out;
-}
-
-unsigned int FGotoCodeGen::TO_STATE_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->toStateAction != 0 )
- act = state->toStateAction->actListId+1;
- return act;
-}
-
-unsigned int FGotoCodeGen::FROM_STATE_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->fromStateAction != 0 )
- act = state->fromStateAction->actListId+1;
- return act;
-}
-
-unsigned int FGotoCodeGen::EOF_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->eofAction != 0 )
- act = state->eofAction->actListId+1;
- return act;
-}
-
-void FGotoCodeGen::writeOutData()
-{
- out <<
- "static const int " << START() << " = " << START_STATE_ID() << ";\n"
- "\n";
-
- if ( cgd->writeFirstFinal ) {
- out <<
- "static const int " << FIRST_FINAL() << " = " << FIRST_FINAL_STATE() << ";\n"
- "\n";
- }
-
- if ( cgd->writeErr ) {
- out <<
- "static const int " << ERROR() << " = " << ERROR_STATE() << ";\n"
- "\n";
- }
-
- if ( anyToStateActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), TSA() );
- TO_STATE_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- if ( anyFromStateActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), FSA() );
- FROM_STATE_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- if ( anyEofActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), EA() );
- EOF_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-}
-
-void FGotoCodeGen::writeOutExec()
-{
- outLabelUsed = false;
-
- out << " {\n";
-
- if ( anyRegCurStateRef() )
- out << " int _ps = 0;\n";
-
- if ( anyConditions() )
- out << " " << WIDE_ALPH_TYPE() << " _widec;\n";
-
- if ( cgd->hasEnd ) {
- outLabelUsed = true;
- out <<
- " if ( " << P() << " == " << PE() << " )\n"
- " goto _out;\n";
- }
-
- out << "_resume:\n";
-
- if ( anyFromStateActions() ) {
- out <<
- " switch ( " << FSA() << "[" << CS() << "] ) {\n";
- FROM_STATE_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- "\n";
- }
-
- out <<
- " switch ( " << CS() << " ) {\n";
- STATE_GOTOS();
- SWITCH_DEFAULT() <<
- " }\n"
- "\n";
- TRANSITIONS() <<
- "\n";
-
- if ( anyRegActions() )
- EXEC_ACTIONS() << "\n";
-
- out << "_again:\n";
-
- if ( anyToStateActions() ) {
- out <<
- " switch ( " << TSA() << "[" << CS() << "] ) {\n";
- TO_STATE_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- "\n";
- }
-
- if ( cgd->hasEnd ) {
- out <<
- " if ( ++" << P() << " != " << PE() << " )\n"
- " goto _resume;\n";
- }
- else {
- out <<
- " " << P() << " += 1;\n"
- " goto _resume;\n";
- }
-
-
- if ( outLabelUsed )
- out << " _out: {}\n";
-
- out << " }\n";
-}
-
-void FGotoCodeGen::writeOutEOF()
-{
- if ( anyEofActions() ) {
- out <<
- " {\n"
- " switch ( " << EA() << "[" << CS() << "] ) {\n";
- EOF_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- "\n";
- }
-}
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- * 2004 Eric Ocean <eric.ocean@ampede.com>
- * 2005 Alan West <alan@alanz.com>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _FGOTOCODEGEN_H
-#define _FGOTOCODEGEN_H
-
-#include <iostream>
-#include "gotocodegen.h"
-
-/* Forwards. */
-struct CodeGenData;
-
-
-/*
- * class FGotoCodeGen
- */
-class FGotoCodeGen : public GotoCodeGen
-{
-public:
- std::ostream &EXEC_ACTIONS();
- std::ostream &TO_STATE_ACTION_SWITCH();
- std::ostream &FROM_STATE_ACTION_SWITCH();
- std::ostream &FINISH_CASES();
- std::ostream &EOF_ACTION_SWITCH();
- unsigned int TO_STATE_ACTION( RedStateAp *state );
- unsigned int FROM_STATE_ACTION( RedStateAp *state );
- unsigned int EOF_ACTION( RedStateAp *state );
-
- virtual void writeOutData();
- virtual void writeOutEOF();
- virtual void writeOutExec();
-};
-
-/*
- * class CFGotoCodeGen
- */
-struct CFGotoCodeGen
- : public FGotoCodeGen, public CCodeGen
-{
-};
-
-/*
- * class DFGotoCodeGen
- */
-struct DFGotoCodeGen
- : public FGotoCodeGen, public DCodeGen
-{
-};
-
-#endif /* _FGOTOCODEGEN_H */
+++ /dev/null
-/*
- * Copyright 2004-2006 Adrian Thurston <thurston@cs.queensu.ca>
- * 2004 Eric Ocean <eric.ocean@ampede.com>
- * 2005 Alan West <alan@alanz.com>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "rlcodegen.h"
-#include "flatcodegen.h"
-#include "redfsm.h"
-#include "gendata.h"
-
-std::ostream &FlatCodeGen::TO_STATE_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->toStateAction != 0 )
- act = state->toStateAction->location+1;
- out << act;
- return out;
-}
-
-std::ostream &FlatCodeGen::FROM_STATE_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->fromStateAction != 0 )
- act = state->fromStateAction->location+1;
- out << act;
- return out;
-}
-
-std::ostream &FlatCodeGen::EOF_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->eofAction != 0 )
- act = state->eofAction->location+1;
- out << act;
- return out;
-}
-
-std::ostream &FlatCodeGen::TRANS_ACTION( RedTransAp *trans )
-{
- /* If there are actions, emit them. Otherwise emit zero. */
- int act = 0;
- if ( trans->action != 0 )
- act = trans->action->location+1;
- out << act;
- return out;
-}
-
-std::ostream &FlatCodeGen::TO_STATE_ACTION_SWITCH()
-{
- /* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = cgd->actionList; act.lte(); act++ ) {
- /* Write out referenced actions. */
- if ( act->numToStateRefs > 0 ) {
- /* Write the case label, the action and the case break */
- out << "\tcase " << act->actionId << ":\n";
- ACTION( out, act, 0, false );
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-std::ostream &FlatCodeGen::FROM_STATE_ACTION_SWITCH()
-{
- /* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = cgd->actionList; act.lte(); act++ ) {
- /* Write out referenced actions. */
- if ( act->numFromStateRefs > 0 ) {
- /* Write the case label, the action and the case break */
- out << "\tcase " << act->actionId << ":\n";
- ACTION( out, act, 0, false );
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-std::ostream &FlatCodeGen::EOF_ACTION_SWITCH()
-{
- /* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = cgd->actionList; act.lte(); act++ ) {
- /* Write out referenced actions. */
- if ( act->numEofRefs > 0 ) {
- /* Write the case label, the action and the case break */
- out << "\tcase " << act->actionId << ":\n";
- ACTION( out, act, 0, true );
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-
-std::ostream &FlatCodeGen::ACTION_SWITCH()
-{
- /* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = cgd->actionList; act.lte(); act++ ) {
- /* Write out referenced actions. */
- if ( act->numTransRefs > 0 ) {
- /* Write the case label, the action and the case break */
- out << "\tcase " << act->actionId << ":\n";
- ACTION( out, act, 0, false );
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-
-std::ostream &FlatCodeGen::FLAT_INDEX_OFFSET()
-{
- out << "\t";
- int totalStateNum = 0, curIndOffset = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Write the index offset. */
- out << curIndOffset;
- if ( !st.last() ) {
- out << ", ";
- if ( ++totalStateNum % IALL == 0 )
- out << "\n\t";
- }
-
- /* Move the index offset ahead. */
- if ( st->transList != 0 )
- curIndOffset += keyOps->span( st->lowKey, st->highKey );
-
- if ( st->defTrans != 0 )
- curIndOffset += 1;
- }
- out << "\n";
- return out;
-}
-
-std::ostream &FlatCodeGen::KEY_SPANS()
-{
- out << "\t";
- int totalStateNum = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Write singles length. */
- unsigned long long span = 0;
- if ( st->transList != 0 )
- span = keyOps->span( st->lowKey, st->highKey );
- out << span;
- if ( !st.last() ) {
- out << ", ";
- if ( ++totalStateNum % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- return out;
-}
-
-std::ostream &FlatCodeGen::TO_STATE_ACTIONS()
-{
- out << "\t";
- int totalStateNum = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Write any eof action. */
- TO_STATE_ACTION(st);
- if ( !st.last() ) {
- out << ", ";
- if ( ++totalStateNum % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- return out;
-}
-
-std::ostream &FlatCodeGen::FROM_STATE_ACTIONS()
-{
- out << "\t";
- int totalStateNum = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Write any eof action. */
- FROM_STATE_ACTION(st);
- if ( !st.last() ) {
- out << ", ";
- if ( ++totalStateNum % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- return out;
-}
-
-std::ostream &FlatCodeGen::EOF_ACTIONS()
-{
- out << "\t";
- int totalStateNum = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Write any eof action. */
- EOF_ACTION(st);
- if ( !st.last() ) {
- out << ", ";
- if ( ++totalStateNum % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- return out;
-}
-
-std::ostream &FlatCodeGen::COND_KEYS()
-{
- out << '\t';
- int totalTrans = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Emit just cond low key and cond high key. */
- out << KEY( st->condLowKey ) << ", ";
- out << KEY( st->condHighKey ) << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
-
- /* Output one last number so we don't have to figure out when the last
- * entry is and avoid writing a comma. */
- out << 0 << "\n";
- return out;
-}
-
-std::ostream &FlatCodeGen::COND_KEY_SPANS()
-{
- out << "\t";
- int totalStateNum = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Write singles length. */
- unsigned long long span = 0;
- if ( st->condList != 0 )
- span = keyOps->span( st->condLowKey, st->condHighKey );
- out << span;
- if ( !st.last() ) {
- out << ", ";
- if ( ++totalStateNum % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- return out;
-}
-
-std::ostream &FlatCodeGen::CONDS()
-{
- int totalTrans = 0;
- out << '\t';
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- if ( st->condList != 0 ) {
- /* Walk the singles. */
- unsigned long long span = keyOps->span( st->condLowKey, st->condHighKey );
- for ( unsigned long long pos = 0; pos < span; pos++ ) {
- if ( st->condList[pos] != 0 )
- out << st->condList[pos]->condSpaceId + 1 << ", ";
- else
- out << "0, ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
- }
- }
-
- /* Output one last number so we don't have to figure out when the last
- * entry is and avoid writing a comma. */
- out << 0 << "\n";
- return out;
-}
-
-std::ostream &FlatCodeGen::COND_INDEX_OFFSET()
-{
- out << "\t";
- int totalStateNum = 0, curIndOffset = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Write the index offset. */
- out << curIndOffset;
- if ( !st.last() ) {
- out << ", ";
- if ( ++totalStateNum % IALL == 0 )
- out << "\n\t";
- }
-
- /* Move the index offset ahead. */
- if ( st->condList != 0 )
- curIndOffset += keyOps->span( st->condLowKey, st->condHighKey );
- }
- out << "\n";
- return out;
-}
-
-
-std::ostream &FlatCodeGen::KEYS()
-{
- out << '\t';
- int totalTrans = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Emit just low key and high key. */
- out << KEY( st->lowKey ) << ", ";
- out << KEY( st->highKey ) << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
-
- /* Output one last number so we don't have to figure out when the last
- * entry is and avoid writing a comma. */
- out << 0 << "\n";
- return out;
-}
-
-std::ostream &FlatCodeGen::INDICIES()
-{
- int totalTrans = 0;
- out << '\t';
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- if ( st->transList != 0 ) {
- /* Walk the singles. */
- unsigned long long span = keyOps->span( st->lowKey, st->highKey );
- for ( unsigned long long pos = 0; pos < span; pos++ ) {
- out << st->transList[pos]->id << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
- }
-
- /* The state's default index goes next. */
- if ( st->defTrans != 0 )
- out << st->defTrans->id << ", ";
-
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
-
- /* Output one last number so we don't have to figure out when the last
- * entry is and avoid writing a comma. */
- out << 0 << "\n";
- return out;
-}
-
-std::ostream &FlatCodeGen::TRANS_TARGS()
-{
- /* Transitions must be written ordered by their id. */
- RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()];
- for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ )
- transPtrs[trans->id] = trans;
-
- /* Keep a count of the num of items in the array written. */
- out << '\t';
- int totalStates = 0;
- for ( int t = 0; t < redFsm->transSet.length(); t++ ) {
- /* Write out the target state. */
- RedTransAp *trans = transPtrs[t];
- out << trans->targ->id;
- if ( t < redFsm->transSet.length()-1 ) {
- out << ", ";
- if ( ++totalStates % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- delete[] transPtrs;
- return out;
-}
-
-
-std::ostream &FlatCodeGen::TRANS_ACTIONS()
-{
- /* Transitions must be written ordered by their id. */
- RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()];
- for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ )
- transPtrs[trans->id] = trans;
-
- /* Keep a count of the num of items in the array written. */
- out << '\t';
- int totalAct = 0;
- for ( int t = 0; t < redFsm->transSet.length(); t++ ) {
- /* Write the function for the transition. */
- RedTransAp *trans = transPtrs[t];
- TRANS_ACTION( trans );
- if ( t < redFsm->transSet.length()-1 ) {
- out << ", ";
- if ( ++totalAct % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- delete[] transPtrs;
- return out;
-}
-
-void FlatCodeGen::LOCATE_TRANS()
-{
- out <<
- " _keys = " << ARR_OFF( K(), "(" + CS() + "<<1)" ) << ";\n"
- " _inds = " << ARR_OFF( I(), IO() + "[" + CS() + "]" ) << ";\n"
- "\n"
- " _slen = " << SP() << "[" << CS() << "];\n"
- " _trans = _inds[ _slen > 0 && _keys[0] <=" << GET_WIDE_KEY() << " &&\n"
- " " << GET_WIDE_KEY() << " <= _keys[1] ?\n"
- " " << GET_WIDE_KEY() << " - _keys[0] : _slen ];\n"
- "\n";
-}
-
-void FlatCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish )
-{
- ret << "{" << CS() << " = " << gotoDest << "; " <<
- CTRL_FLOW() << "goto _again;}";
-}
-
-void FlatCodeGen::GOTO_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish )
-{
- ret << "{" << CS() << " = (";
- INLINE_LIST( ret, ilItem->children, 0, inFinish );
- ret << "); " << CTRL_FLOW() << "goto _again;}";
-}
-
-void FlatCodeGen::CURS( ostream &ret, bool inFinish )
-{
- ret << "(_ps)";
-}
-
-void FlatCodeGen::TARGS( ostream &ret, bool inFinish, int targState )
-{
- ret << "(" << CS() << ")";
-}
-
-void FlatCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish )
-{
- ret << CS() << " = " << nextDest << ";";
-}
-
-void FlatCodeGen::NEXT_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish )
-{
- ret << CS() << " = (";
- INLINE_LIST( ret, ilItem->children, 0, inFinish );
- ret << ");";
-}
-
-void FlatCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish )
-{
- ret << "{" << STACK() << "[" << TOP() << "++] = " << CS() << "; " << CS() << " = " <<
- callDest << "; " << CTRL_FLOW() << "goto _again;}";
-}
-
-
-void FlatCodeGen::CALL_EXPR( ostream &ret, InlineItem *ilItem, int targState, bool inFinish )
-{
- ret << "{" << STACK() << "[" << TOP() << "++] = " << CS() << "; " << CS() << " = (";
- INLINE_LIST( ret, ilItem->children, targState, inFinish );
- ret << "); " << CTRL_FLOW() << "goto _again;}";
-}
-
-
-void FlatCodeGen::RET( ostream &ret, bool inFinish )
-{
- ret << "{" << CS() << " = " << STACK() << "[--" << TOP() << "]; " <<
- CTRL_FLOW() << "goto _again;}";
-}
-
-void FlatCodeGen::BREAK( ostream &ret, int targState )
-{
- outLabelUsed = true;
- ret << CTRL_FLOW() << "goto _out;";
-}
-
-void FlatCodeGen::writeOutData()
-{
- /* If there are any transtion functions then output the array. If there
- * are none, don't bother emitting an empty array that won't be used. */
- if ( anyActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActArrItem), A() );
- ACTIONS_ARRAY();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- if ( anyConditions() ) {
- OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() );
- COND_KEYS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxCondSpan), CSP() );
- COND_KEY_SPANS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxCond), C() );
- CONDS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxCondIndexOffset), CO() );
- COND_INDEX_OFFSET();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- OPEN_ARRAY( WIDE_ALPH_TYPE(), K() );
- KEYS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxSpan), SP() );
- KEY_SPANS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxFlatIndexOffset), IO() );
- FLAT_INDEX_OFFSET();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxIndex), I() );
- INDICIES();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxState), TT() );
- TRANS_TARGS();
- CLOSE_ARRAY() <<
- "\n";
-
- if ( anyActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), TA() );
- TRANS_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- if ( anyToStateActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), TSA() );
- TO_STATE_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- if ( anyFromStateActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), FSA() );
- FROM_STATE_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- if ( anyEofActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), EA() );
- EOF_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- out <<
- "static const int " << START() << " = " << START_STATE_ID() << ";\n"
- "\n";
-
- if ( cgd->writeFirstFinal ) {
- out <<
- "static const int " << FIRST_FINAL() << " = " << FIRST_FINAL_STATE() << ";\n"
- "\n";
- }
-
- if ( cgd->writeErr ) {
- out <<
- "static const int " << ERROR() << " = " << ERROR_STATE() << ";\n"
- "\n";
- }
-}
-
-void FlatCodeGen::COND_TRANSLATE()
-{
- out <<
- " _widec = " << GET_KEY() << ";\n";
-
- out <<
- " _keys = " << ARR_OFF( CK(), "(" + CS() + "<<1)" ) << ";\n"
- " _conds = " << ARR_OFF( C(), CO() + "[" + CS() + "]" ) << ";\n"
- "\n"
- " _slen = " << CSP() << "[" << CS() << "];\n"
- " _cond = _slen > 0 && _keys[0] <=" << GET_WIDE_KEY() << " &&\n"
- " " << GET_WIDE_KEY() << " <= _keys[1] ?\n"
- " _conds[" << GET_WIDE_KEY() << " - _keys[0]] : 0;\n"
- "\n";
-
- out <<
- " switch ( _cond ) {\n";
- for ( CondSpaceList::Iter csi = cgd->condSpaceList; csi.lte(); csi++ ) {
- CondSpace *condSpace = csi;
- out << " case " << condSpace->condSpaceId + 1 << ": {\n";
- out << TABS(2) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" <<
- KEY(condSpace->baseKey) << " + (" << GET_KEY() <<
- " - " << KEY(keyOps->minKey) << "));\n";
-
- for ( CondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
- out << TABS(2) << "if ( ";
- CONDITION( out, *csi );
- Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize());
- out << " ) _widec += " << condValOffset << ";\n";
- }
-
- out << " }\n";
- out << " break;\n";
- }
-
- SWITCH_DEFAULT();
-
- out <<
- " }\n";
-}
-
-void FlatCodeGen::writeOutExec()
-{
- outLabelUsed = false;
-
- out <<
- " {\n"
- " int _slen";
-
- if ( anyRegCurStateRef() )
- out << ", _ps";
-
- out <<
- ";\n"
- " int _trans";
-
- if ( anyConditions() )
- out << ", _cond";
- out << ";\n";
-
- if ( anyToStateActions() || anyRegActions() || anyFromStateActions() ) {
- out <<
- " " << PTR_CONST() << ARRAY_TYPE(maxActArrItem) << POINTER() << "_acts;\n"
- " " << UINT() << " _nacts;\n";
- }
-
- out <<
- " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_keys;\n"
- " " << PTR_CONST() << ARRAY_TYPE(maxIndex) << POINTER() << "_inds;\n";
-
- if ( anyConditions() ) {
- out <<
- " " << PTR_CONST() << ARRAY_TYPE(maxCond) << POINTER() << "_conds;\n"
- " " << WIDE_ALPH_TYPE() << " _widec;\n";
- }
-
- out << "\n";
-
- if ( cgd->hasEnd ) {
- outLabelUsed = true;
- out <<
- " if ( " << P() << " == " << PE() << " )\n"
- " goto _out;\n";
- }
-
- out << "_resume:\n";
-
- if ( redFsm->errState != 0 ) {
- outLabelUsed = true;
- out <<
- " if ( " << CS() << " == " << redFsm->errState->id << " )\n"
- " goto _out;\n";
- }
-
- if ( anyFromStateActions() ) {
- out <<
- " _acts = " << ARR_OFF( A(), FSA() + "[" + CS() + "]" ) << ";\n"
- " _nacts = " << CAST(UINT()) << " *_acts++;\n"
- " while ( _nacts-- > 0 ) {\n"
- " switch ( *_acts++ ) {\n";
- FROM_STATE_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- "\n";
- }
-
- if ( anyConditions() )
- COND_TRANSLATE();
-
- LOCATE_TRANS();
-
- if ( anyRegCurStateRef() )
- out << " _ps = " << CS() << ";\n";
-
- out <<
- " " << CS() << " = " << TT() << "[_trans];\n"
- "\n";
-
- if ( anyRegActions() ) {
- out <<
- " if ( " << TA() << "[_trans] == 0 )\n"
- " goto _again;\n"
- "\n"
- " _acts = " << ARR_OFF( A(), TA() + "[_trans]" ) << ";\n"
- " _nacts = " << CAST(UINT()) << " *_acts++;\n"
- " while ( _nacts-- > 0 ) {\n"
- " switch ( *(_acts++) )\n {\n";
- ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- "\n";
- }
-
- if ( anyRegActions() || anyActionGotos() || anyActionCalls() || anyActionRets() )
- out << "_again:\n";
-
- if ( anyToStateActions() ) {
- out <<
- " _acts = " << ARR_OFF( A(), TSA() + "[" + CS() + "]" ) << ";\n"
- " _nacts = " << CAST(UINT()) << " *_acts++;\n"
- " while ( _nacts-- > 0 ) {\n"
- " switch ( *_acts++ ) {\n";
- TO_STATE_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- "\n";
- }
-
- if ( cgd->hasEnd ) {
- out <<
- " if ( ++" << P() << " != " << PE() << " )\n"
- " goto _resume;\n";
- }
- else {
- out <<
- " " << P() << " += 1;\n"
- " goto _resume;\n";
- }
-
- if ( outLabelUsed )
- out << " _out: {}\n";
-
- out << " }\n";
-}
-
-void FlatCodeGen::writeOutEOF()
-{
- if ( anyEofActions() ) {
- out <<
- " {\n"
- " " << PTR_CONST() << ARRAY_TYPE(maxActArrItem) << POINTER() << "_acts = " <<
- ARR_OFF( A(), EA() + "[" + CS() + "]" ) << ";\n"
- " " << UINT() << " _nacts = " << CAST(UINT()) << " *_acts++;\n"
- " while ( _nacts-- > 0 ) {\n"
- " switch ( *_acts++ ) {\n";
- EOF_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- " }\n"
- "\n";
- }
-}
+++ /dev/null
-/*
- * Copyright 2004-2006 Adrian Thurston <thurston@cs.queensu.ca>
- * 2004 Eric Ocean <eric.ocean@ampede.com>
- * 2005 Alan West <alan@alanz.com>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _FLATCODEGEN_H
-#define _FLATCODEGEN_H
-
-#include <iostream>
-#include "fsmcodegen.h"
-
-/* Forwards. */
-struct CodeGenData;
-struct NameInst;
-struct RedTransAp;
-struct RedStateAp;
-
-/*
- * FlatCodeGen
- */
-class FlatCodeGen : virtual public FsmCodeGen
-{
-public:
- virtual ~FlatCodeGen() { }
-
-protected:
- std::ostream &TO_STATE_ACTION_SWITCH();
- std::ostream &FROM_STATE_ACTION_SWITCH();
- std::ostream &EOF_ACTION_SWITCH();
- std::ostream &ACTION_SWITCH();
- std::ostream &KEYS();
- std::ostream &INDICIES();
- std::ostream &FLAT_INDEX_OFFSET();
- std::ostream &KEY_SPANS();
- std::ostream &TO_STATE_ACTIONS();
- std::ostream &FROM_STATE_ACTIONS();
- std::ostream &EOF_ACTIONS();
- std::ostream &TRANS_TARGS();
- std::ostream &TRANS_ACTIONS();
- void LOCATE_TRANS();
-
- std::ostream &COND_INDEX_OFFSET();
- void COND_TRANSLATE();
- std::ostream &CONDS();
- std::ostream &COND_KEYS();
- std::ostream &COND_KEY_SPANS();
-
- void GOTO( ostream &ret, int gotoDest, bool inFinish );
- void CALL( ostream &ret, int callDest, int targState, bool inFinish );
- void NEXT( ostream &ret, int nextDest, bool inFinish );
- void GOTO_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish );
- void NEXT_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish );
- void CALL_EXPR( ostream &ret, InlineItem *ilItem, int targState, bool inFinish );
- void CURS( ostream &ret, bool inFinish );
- void TARGS( ostream &ret, bool inFinish, int targState );
- void RET( ostream &ret, bool inFinish );
- void BREAK( ostream &ret, int targState );
-
- virtual std::ostream &TO_STATE_ACTION( RedStateAp *state );
- virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state );
- virtual std::ostream &EOF_ACTION( RedStateAp *state );
- virtual std::ostream &TRANS_ACTION( RedTransAp *trans );
-
- virtual void writeOutData();
- virtual void writeOutEOF();
- virtual void writeOutExec();
-};
-
-/*
- * CFlatCodeGen
- */
-struct CFlatCodeGen
- : public FlatCodeGen, public CCodeGen
-{
-};
-
-/*
- * DFlatCodeGen
- */
-struct DFlatCodeGen
- : public FlatCodeGen, public DCodeGen
-{
-};
-
-#endif /* _FLATCODEGEN_H */
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- * 2004 Eric Ocean <eric.ocean@ampede.com>
- * 2005 Alan West <alan@alanz.com>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "rlcodegen.h"
-#include "fsmcodegen.h"
-#include "redfsm.h"
-#include "gendata.h"
-#include <sstream>
-#include <string>
-#include <assert.h>
-
-using std::ostream;
-using std::ostringstream;
-using std::string;
-using std::cerr;
-using std::endl;
-
-
-/* Determine if a string is only whitespace. Code blocks that are only
- * whitespace need not be output. */
-bool onlyWhitespace( char *str )
-{
- while ( *str != 0 ) {
- if ( *str != ' ' && *str != '\t' && *str != '\n' &&
- *str != '\v' && *str != '\f' && *str != '\r' )
- return false;
- str += 1;
- }
- return true;
-}
-
-/* Init code gen with in parameters. */
-FsmCodeGen::FsmCodeGen( )
-:
- fsmName(0),
- cgd(0),
- redFsm(0),
- out(*outStream),
- bAnyToStateActions(false),
- bAnyFromStateActions(false),
- bAnyRegActions(false),
- bAnyEofActions(false),
- bAnyActionGotos(false),
- bAnyActionCalls(false),
- bAnyActionRets(false),
- bAnyRegActionRets(false),
- bAnyRegActionByValControl(false),
- bAnyRegNextStmt(false),
- bAnyRegCurStateRef(false),
- bAnyRegBreak(false),
- bAnyLmSwitchError(false),
- bAnyConditions(false)
-{
-}
-
-/* Does the machine have any actions. */
-bool FsmCodeGen::anyActions()
-{
- return redFsm->actionMap.length() > 0;
-}
-
-void FsmCodeGen::findFinalActionRefs()
-{
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Rerence count out of single transitions. */
- for ( RedTransList::Iter rtel = st->outSingle; rtel.lte(); rtel++ ) {
- if ( rtel->value->action != 0 ) {
- rtel->value->action->numTransRefs += 1;
- for ( ActionTable::Iter item = rtel->value->action->key; item.lte(); item++ )
- item->value->numTransRefs += 1;
- }
- }
-
- /* Reference count out of range transitions. */
- for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) {
- if ( rtel->value->action != 0 ) {
- rtel->value->action->numTransRefs += 1;
- for ( ActionTable::Iter item = rtel->value->action->key; item.lte(); item++ )
- item->value->numTransRefs += 1;
- }
- }
-
- /* Reference count default transition. */
- if ( st->defTrans != 0 && st->defTrans->action != 0 ) {
- st->defTrans->action->numTransRefs += 1;
- for ( ActionTable::Iter item = st->defTrans->action->key; item.lte(); item++ )
- item->value->numTransRefs += 1;
- }
-
- /* Reference count to state actions. */
- if ( st->toStateAction != 0 ) {
- st->toStateAction->numToStateRefs += 1;
- for ( ActionTable::Iter item = st->toStateAction->key; item.lte(); item++ )
- item->value->numToStateRefs += 1;
- }
-
- /* Reference count from state actions. */
- if ( st->fromStateAction != 0 ) {
- st->fromStateAction->numFromStateRefs += 1;
- for ( ActionTable::Iter item = st->fromStateAction->key; item.lte(); item++ )
- item->value->numFromStateRefs += 1;
- }
-
- /* Reference count EOF actions. */
- if ( st->eofAction != 0 ) {
- st->eofAction->numEofRefs += 1;
- for ( ActionTable::Iter item = st->eofAction->key; item.lte(); item++ )
- item->value->numEofRefs += 1;
- }
- }
-}
-
-/* Assign ids to referenced actions. */
-void FsmCodeGen::assignActionIds()
-{
- int nextActionId = 0;
- for ( ActionList::Iter act = cgd->actionList; act.lte(); act++ ) {
- /* Only ever interested in referenced actions. */
- if ( act->numRefs() > 0 )
- act->actionId = nextActionId++;
- }
-}
-
-void FsmCodeGen::setValueLimits()
-{
- maxSingleLen = 0;
- maxRangeLen = 0;
- maxKeyOffset = 0;
- maxIndexOffset = 0;
- maxActListId = 0;
- maxActionLoc = 0;
- maxActArrItem = 0;
- maxSpan = 0;
- maxCondSpan = 0;
- maxFlatIndexOffset = 0;
- maxCondOffset = 0;
- maxCondLen = 0;
- maxCondSpaceId = 0;
- maxCondIndexOffset = 0;
-
- /* In both of these cases the 0 index is reserved for no value, so the max
- * is one more than it would be if they started at 0. */
- maxIndex = redFsm->transSet.length();
- maxCond = cgd->condSpaceList.length();
-
- /* The nextStateId - 1 is the last state id assigned. */
- maxState = redFsm->nextStateId - 1;
-
- for ( CondSpaceList::Iter csi = cgd->condSpaceList; csi.lte(); csi++ ) {
- if ( csi->condSpaceId > maxCondSpaceId )
- maxCondSpaceId = csi->condSpaceId;
- }
-
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Maximum cond length. */
- if ( st->stateCondList.length() > maxCondLen )
- maxCondLen = st->stateCondList.length();
-
- /* Maximum single length. */
- if ( st->outSingle.length() > maxSingleLen )
- maxSingleLen = st->outSingle.length();
-
- /* Maximum range length. */
- if ( st->outRange.length() > maxRangeLen )
- maxRangeLen = st->outRange.length();
-
- /* The key offset index offset for the state after last is not used, skip it.. */
- if ( ! st.last() ) {
- maxCondOffset += st->stateCondList.length();
- maxKeyOffset += st->outSingle.length() + st->outRange.length()*2;
- maxIndexOffset += st->outSingle.length() + st->outRange.length() + 1;
- }
-
- /* Max cond span. */
- if ( st->condList != 0 ) {
- unsigned long long span = keyOps->span( st->condLowKey, st->condHighKey );
- if ( span > maxCondSpan )
- maxCondSpan = span;
- }
-
- /* Max key span. */
- if ( st->transList != 0 ) {
- unsigned long long span = keyOps->span( st->lowKey, st->highKey );
- if ( span > maxSpan )
- maxSpan = span;
- }
-
- /* Max cond index offset. */
- if ( ! st.last() ) {
- if ( st->condList != 0 )
- maxCondIndexOffset += keyOps->span( st->condLowKey, st->condHighKey );
- }
-
- /* Max flat index offset. */
- if ( ! st.last() ) {
- if ( st->transList != 0 )
- maxFlatIndexOffset += keyOps->span( st->lowKey, st->highKey );
- maxFlatIndexOffset += 1;
- }
- }
-
- for ( ActionTableMap::Iter at = redFsm->actionMap; at.lte(); at++ ) {
- /* Maximum id of action lists. */
- if ( at->actListId+1 > maxActListId )
- maxActListId = at->actListId+1;
-
- /* Maximum location of items in action array. */
- if ( at->location+1 > maxActionLoc )
- maxActionLoc = at->location+1;
-
- /* Maximum values going into the action array. */
- if ( at->key.length() > maxActArrItem )
- maxActArrItem = at->key.length();
- for ( ActionTable::Iter item = at->key; item.lte(); item++ ) {
- if ( item->value->actionId > maxActArrItem )
- maxActArrItem = item->value->actionId;
- }
- }
-}
-
-void FsmCodeGen::analyzeAction( Action *act, InlineList *inlineList )
-{
- for ( InlineList::Iter item = *inlineList; item.lte(); item++ ) {
- /* Only consider actions that are referenced. */
- if ( act->numRefs() > 0 ) {
- if ( item->type == InlineItem::Goto || item->type == InlineItem::GotoExpr )
- bAnyActionGotos = true;
- else if ( item->type == InlineItem::Call || item->type == InlineItem::CallExpr )
- bAnyActionCalls = true;
- else if ( item->type == InlineItem::Ret )
- bAnyActionRets = true;
- }
-
- /* Check for various things in regular actions. */
- if ( act->numTransRefs > 0 || act->numToStateRefs > 0 || act->numFromStateRefs > 0 ) {
- /* Any returns in regular actions? */
- if ( item->type == InlineItem::Ret )
- bAnyRegActionRets = true;
-
- /* Any next statements in the regular actions? */
- if ( item->type == InlineItem::Next || item->type == InlineItem::NextExpr )
- bAnyRegNextStmt = true;
-
- /* Any by value control in regular actions? */
- if ( item->type == InlineItem::CallExpr || item->type == InlineItem::GotoExpr )
- bAnyRegActionByValControl = true;
-
- /* Any references to the current state in regular actions? */
- if ( item->type == InlineItem::Curs )
- bAnyRegCurStateRef = true;
-
- if ( item->type == InlineItem::Break )
- bAnyRegBreak = true;
-
- if ( item->type == InlineItem::LmSwitch && item->handlesError )
- bAnyLmSwitchError = true;
- }
-
- if ( item->children != 0 )
- analyzeAction( act, item->children );
- }
-}
-
-void FsmCodeGen::analyzeActionList( RedAction *redAct, InlineList *inlineList )
-{
- for ( InlineList::Iter item = *inlineList; item.lte(); item++ ) {
- /* Any next statements in the action table? */
- if ( item->type == InlineItem::Next || item->type == InlineItem::NextExpr )
- redAct->bAnyNextStmt = true;
-
- /* Any references to the current state. */
- if ( item->type == InlineItem::Curs )
- redAct->bAnyCurStateRef = true;
-
- if ( item->type == InlineItem::Break )
- redAct->bAnyBreakStmt = true;
-
- if ( item->children != 0 )
- analyzeActionList( redAct, item->children );
- }
-}
-
-/* Gather various info on the machine. */
-void FsmCodeGen::analyzeMachine()
-{
- /* Find the true count of action references. */
- findFinalActionRefs();
-
- /* Check if there are any calls in action code. */
- for ( ActionList::Iter act = cgd->actionList; act.lte(); act++ ) {
- /* Record the occurrence of various kinds of actions. */
- if ( act->numToStateRefs > 0 )
- bAnyToStateActions = true;
- if ( act->numFromStateRefs > 0 )
- bAnyFromStateActions = true;
- if ( act->numEofRefs > 0 )
- bAnyEofActions = true;
- if ( act->numTransRefs > 0 )
- bAnyRegActions = true;
-
- /* Recurse through the action's parse tree looking for various things. */
- analyzeAction( act, act->inlineList );
- }
-
- /* Analyze reduced action lists. */
- for ( ActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
- for ( ActionTable::Iter act = redAct->key; act.lte(); act++ )
- analyzeActionList( redAct, act->value->inlineList );
- }
-
- /* Find states that have transitions with actions that have next
- * statements. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Check any actions out of outSinge. */
- for ( RedTransList::Iter rtel = st->outSingle; rtel.lte(); rtel++ ) {
- if ( rtel->value->action != 0 && rtel->value->action->anyCurStateRef() )
- st->bAnyRegCurStateRef = true;
- }
-
- /* Check any actions out of outRange. */
- for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) {
- if ( rtel->value->action != 0 && rtel->value->action->anyCurStateRef() )
- st->bAnyRegCurStateRef = true;
- }
-
- /* Check any action out of default. */
- if ( st->defTrans != 0 && st->defTrans->action != 0 &&
- st->defTrans->action->anyCurStateRef() )
- st->bAnyRegCurStateRef = true;
-
- if ( st->stateCondList.length() > 0 )
- bAnyConditions = true;
- }
-
- /* Assign ids to actions that are referenced. */
- assignActionIds();
-
- /* Set the maximums of various values used for deciding types. */
- setValueLimits();
-
- /* Determine if we should use indicies. */
- calcIndexSize();
-}
-
-unsigned int FsmCodeGen::arrayTypeSize( unsigned long maxVal )
-{
- long long maxValLL = (long long) maxVal;
- HostType *arrayType = keyOps->typeSubsumes( maxValLL );
- assert( arrayType != 0 );
- return arrayType->size;
-}
-
-string FsmCodeGen::ARRAY_TYPE( unsigned long maxVal )
-{
- long long maxValLL = (long long) maxVal;
- HostType *arrayType = keyOps->typeSubsumes( maxValLL );
- assert( arrayType != 0 );
-
- string ret = arrayType->data1;
- if ( arrayType->data2 != 0 ) {
- ret += " ";
- ret += arrayType->data2;
- }
- return ret;
-}
-
-
-/* Write out the fsm name. */
-string FsmCodeGen::FSM_NAME()
-{
- return fsmName;
-}
-
-/* Emit the offset of the start state as a decimal integer. */
-string FsmCodeGen::START_STATE_ID()
-{
- ostringstream ret;
- ret << redFsm->startState->id;
- return ret.str();
-};
-
-/* Write out the array of actions. */
-std::ostream &FsmCodeGen::ACTIONS_ARRAY()
-{
- out << "\t0, ";
- int totalActions = 1;
- for ( ActionTableMap::Iter act = redFsm->actionMap; act.lte(); act++ ) {
- /* Write out the length, which will never be the last character. */
- out << act->key.length() << ", ";
- /* Put in a line break every 8 */
- if ( totalActions++ % 8 == 7 )
- out << "\n\t";
-
- for ( ActionTable::Iter item = act->key; item.lte(); item++ ) {
- out << item->value->actionId;
- if ( ! (act.last() && item.last()) )
- out << ", ";
-
- /* Put in a line break every 8 */
- if ( totalActions++ % 8 == 7 )
- out << "\n\t";
- }
- }
- out << "\n";
- return out;
-}
-
-
-string FsmCodeGen::CS()
-{
- ostringstream ret;
- if ( cgd->curStateExpr != 0 ) {
- /* Emit the user supplied method of retrieving the key. */
- ret << "(";
- INLINE_LIST( ret, cgd->curStateExpr, 0, false );
- ret << ")";
- }
- else {
- /* Expression for retrieving the key, use simple dereference. */
- ret << ACCESS() << "cs";
- }
- return ret.str();
-}
-
-string FsmCodeGen::ACCESS()
-{
- ostringstream ret;
- if ( cgd->accessExpr != 0 )
- INLINE_LIST( ret, cgd->accessExpr, 0, false );
- return ret.str();
-}
-
-string FsmCodeGen::GET_WIDE_KEY()
-{
- if ( anyConditions() )
- return "_widec";
- else
- return GET_KEY();
-}
-
-string FsmCodeGen::GET_WIDE_KEY( RedStateAp *state )
-{
- if ( state->stateCondList.length() > 0 )
- return "_widec";
- else
- return GET_KEY();
-}
-
-string FsmCodeGen::GET_KEY()
-{
- ostringstream ret;
- if ( cgd->getKeyExpr != 0 ) {
- /* Emit the user supplied method of retrieving the key. */
- ret << "(";
- INLINE_LIST( ret, cgd->getKeyExpr, 0, false );
- ret << ")";
- }
- else {
- /* Expression for retrieving the key, use simple dereference. */
- ret << "(*" << P() << ")";
- }
- return ret.str();
-}
-
-/* Write out level number of tabs. Makes the nested binary search nice
- * looking. */
-string FsmCodeGen::TABS( int level )
-{
- string result;
- while ( level-- > 0 )
- result += "\t";
- return result;
-}
-
-/* Write out a key from the fsm code gen. Depends on wether or not the key is
- * signed. */
-string FsmCodeGen::KEY( Key key )
-{
- ostringstream ret;
- if ( keyOps->isSigned || !hostLang->explicitUnsigned )
- ret << key.getVal();
- else
- ret << (unsigned long) key.getVal() << 'u';
- return ret.str();
-}
-
-void FsmCodeGen::EXEC( ostream &ret, InlineItem *item, int targState, int inFinish )
-{
- /* The parser gives fexec two children. The double brackets are for D
- * code. If the inline list is a single word it will get interpreted as a
- * C-style cast by the D compiler. */
- ret << "{" << P() << " = ((";
- INLINE_LIST( ret, item->children, targState, inFinish );
- ret << "))-1;}";
-}
-
-void FsmCodeGen::EXECTE( ostream &ret, InlineItem *item, int targState, int inFinish )
-{
- /* Tokend version of exec. */
-
- /* The parser gives fexec two children. The double brackets are for D
- * code. If the inline list is a single word it will get interpreted as a
- * C-style cast by the D compiler. */
- ret << "{" << TOKEND() << " = ((";
- INLINE_LIST( ret, item->children, targState, inFinish );
- ret << "));}";
-}
-
-
-void FsmCodeGen::LM_SWITCH( ostream &ret, InlineItem *item,
- int targState, int inFinish )
-{
- ret <<
- " switch( act ) {\n";
-
- /* If the switch handles error then we also forced the error state. It
- * will exist. */
- if ( item->handlesError ) {
- ret << " case 0: " << TOKEND() << " = " << TOKSTART() << "; ";
- GOTO( ret, redFsm->errState->id, inFinish );
- ret << "\n";
- }
-
- for ( InlineList::Iter lma = *item->children; lma.lte(); lma++ ) {
- /* Write the case label, the action and the case break. */
- ret << " case " << lma->lmId << ":\n";
-
- /* Write the block and close it off. */
- ret << " {";
- INLINE_LIST( ret, lma->children, targState, inFinish );
- ret << "}\n";
-
- ret << " break;\n";
- }
- /* Default required for D code. */
- ret <<
- " default: break;\n"
- " }\n"
- "\t";
-}
-
-void FsmCodeGen::SET_ACT( ostream &ret, InlineItem *item )
-{
- ret << ACT() << " = " << item->lmId << ";";
-}
-
-void FsmCodeGen::SET_TOKEND( ostream &ret, InlineItem *item )
-{
- /* The tokend action sets tokend. */
- ret << TOKEND() << " = " << P();
- if ( item->offset != 0 )
- out << "+" << item->offset;
- out << ";";
-}
-
-void FsmCodeGen::GET_TOKEND( ostream &ret, InlineItem *item )
-{
- ret << TOKEND();
-}
-
-void FsmCodeGen::INIT_TOKSTART( ostream &ret, InlineItem *item )
-{
- ret << TOKSTART() << " = " << NULL_ITEM() << ";";
-}
-
-void FsmCodeGen::INIT_ACT( ostream &ret, InlineItem *item )
-{
- ret << ACT() << " = 0;";
-}
-
-void FsmCodeGen::SET_TOKSTART( ostream &ret, InlineItem *item )
-{
- ret << TOKSTART() << " = " << P() << ";";
-}
-
-void FsmCodeGen::SUB_ACTION( ostream &ret, InlineItem *item,
- int targState, bool inFinish )
-{
- if ( item->children->length() > 0 ) {
- /* Write the block and close it off. */
- ret << "{";
- INLINE_LIST( ret, item->children, targState, inFinish );
- ret << "}";
- }
-}
-
-
-/* Write out an inline tree structure. Walks the list and possibly calls out
- * to virtual functions than handle language specific items in the tree. */
-void FsmCodeGen::INLINE_LIST( ostream &ret, InlineList *inlineList,
- int targState, bool inFinish )
-{
- for ( InlineList::Iter item = *inlineList; item.lte(); item++ ) {
- switch ( item->type ) {
- case InlineItem::Text:
- ret << item->data;
- break;
- case InlineItem::Goto:
- GOTO( ret, item->targState->id, inFinish );
- break;
- case InlineItem::Call:
- CALL( ret, item->targState->id, targState, inFinish );
- break;
- case InlineItem::Next:
- NEXT( ret, item->targState->id, inFinish );
- break;
- case InlineItem::Ret:
- RET( ret, inFinish );
- break;
- case InlineItem::PChar:
- ret << P();
- break;
- case InlineItem::Char:
- ret << GET_KEY();
- break;
- case InlineItem::Hold:
- ret << P() << "--;";
- break;
- case InlineItem::Exec:
- EXEC( ret, item, targState, inFinish );
- break;
- case InlineItem::HoldTE:
- ret << TOKEND() << "--;";
- break;
- case InlineItem::ExecTE:
- EXECTE( ret, item, targState, inFinish );
- break;
- case InlineItem::Curs:
- CURS( ret, inFinish );
- break;
- case InlineItem::Targs:
- TARGS( ret, inFinish, targState );
- break;
- case InlineItem::Entry:
- ret << item->targState->id;
- break;
- case InlineItem::GotoExpr:
- GOTO_EXPR( ret, item, inFinish );
- break;
- case InlineItem::CallExpr:
- CALL_EXPR( ret, item, targState, inFinish );
- break;
- case InlineItem::NextExpr:
- NEXT_EXPR( ret, item, inFinish );
- break;
- case InlineItem::LmSwitch:
- LM_SWITCH( ret, item, targState, inFinish );
- break;
- case InlineItem::LmSetActId:
- SET_ACT( ret, item );
- break;
- case InlineItem::LmSetTokEnd:
- SET_TOKEND( ret, item );
- break;
- case InlineItem::LmGetTokEnd:
- GET_TOKEND( ret, item );
- break;
- case InlineItem::LmInitTokStart:
- INIT_TOKSTART( ret, item );
- break;
- case InlineItem::LmInitAct:
- INIT_ACT( ret, item );
- break;
- case InlineItem::LmSetTokStart:
- SET_TOKSTART( ret, item );
- break;
- case InlineItem::SubAction:
- SUB_ACTION( ret, item, targState, inFinish );
- break;
- case InlineItem::Break:
- BREAK( ret, targState );
- break;
- }
- }
-}
-/* Write out paths in line directives. Escapes any special characters. */
-string FsmCodeGen::LDIR_PATH( char *path )
-{
- ostringstream ret;
- for ( char *pc = path; *pc != 0; pc++ ) {
- if ( *pc == '\\' )
- ret << "\\\\";
- else
- ret << *pc;
- }
- return ret.str();
-}
-
-void FsmCodeGen::ACTION( ostream &ret, Action *action, int targState, bool inFinish )
-{
- /* Write the preprocessor line info for going into the source file. */
- lineDirective( ret, cgd->fileName, action->loc.line );
-
- /* Write the block and close it off. */
- ret << "\t{";
- INLINE_LIST( ret, action->inlineList, targState, inFinish );
- ret << "}\n";
-}
-
-void FsmCodeGen::CONDITION( ostream &ret, Action *condition )
-{
- ret << "\n";
- lineDirective( ret, cgd->fileName, condition->loc.line );
- INLINE_LIST( ret, condition->inlineList, 0, false );
-}
-
-string FsmCodeGen::ERROR_STATE()
-{
- ostringstream ret;
- if ( redFsm->errState != 0 )
- ret << redFsm->errState->id;
- else
- ret << "-1";
- return ret.str();
-}
-
-string FsmCodeGen::FIRST_FINAL_STATE()
-{
- ostringstream ret;
- if ( redFsm->firstFinState != 0 )
- ret << redFsm->firstFinState->id;
- else
- ret << redFsm->nextStateId;
- return ret.str();
-}
-
-void FsmCodeGen::writeOutInit()
-{
- out << " {\n";
- out << "\t" << CS() << " = " << START() << ";\n";
-
- /* If there are any calls, then the stack top needs initialization. */
- if ( anyActionCalls() || anyActionRets() )
- out << "\t" << TOP() << " = 0;\n";
-
- if ( cgd->hasLongestMatch ) {
- out <<
- " " << TOKSTART() << " = " << NULL_ITEM() << ";\n"
- " " << TOKEND() << " = " << NULL_ITEM() << ";\n"
- " " << ACT() << " = 0;\n";
- }
- out << " }\n";
-}
-
-string FsmCodeGen::DATA_PREFIX()
-{
- if ( cgd->dataPrefix )
- return FSM_NAME() + "_";
- return "";
-}
-
-/* Emit the alphabet data type. */
-string FsmCodeGen::ALPH_TYPE()
-{
- string ret = keyOps->alphType->data1;
- if ( keyOps->alphType->data2 != 0 ) {
- ret += " ";
- ret += + keyOps->alphType->data2;
- }
- return ret;
-}
-
-/* Emit the alphabet data type. */
-string FsmCodeGen::WIDE_ALPH_TYPE()
-{
- string ret;
- if ( maxKey <= keyOps->maxKey )
- ret = ALPH_TYPE();
- else {
- long long maxKeyVal = maxKey.getLongLong();
- HostType *wideType = keyOps->typeSubsumes( keyOps->isSigned, maxKeyVal );
- assert( wideType != 0 );
-
- ret = wideType->data1;
- if ( wideType->data2 != 0 ) {
- ret += " ";
- ret += wideType->data2;
- }
- }
- return ret;
-}
-
-
-/*
- * Language specific, but style independent code generators functions.
- */
-
-string CCodeGen::PTR_CONST()
-{
- return "const ";
-}
-
-std::ostream &CCodeGen::OPEN_ARRAY( string type, string name )
-{
- out << "static const " << type << " " << name << "[] = {\n";
- return out;
-}
-
-std::ostream &CCodeGen::CLOSE_ARRAY()
-{
- return out << "};\n";
-}
-
-std::ostream &CCodeGen::STATIC_VAR( string type, string name )
-{
- out << "static const " << type << " " << name;
- return out;
-}
-
-string CCodeGen::UINT( )
-{
- return "unsigned int";
-}
-
-string CCodeGen::ARR_OFF( string ptr, string offset )
-{
- return ptr + " + " + offset;
-}
-
-string CCodeGen::CAST( string type )
-{
- return "(" + type + ")";
-}
-
-string CCodeGen::NULL_ITEM()
-{
- return "0";
-}
-
-string CCodeGen::POINTER()
-{
- return " *";
-}
-
-std::ostream &CCodeGen::SWITCH_DEFAULT()
-{
- return out;
-}
-
-string CCodeGen::CTRL_FLOW()
-{
- return "";
-}
-
-/*
- * D Specific
- */
-
-string DCodeGen::NULL_ITEM()
-{
- return "null";
-}
-
-string DCodeGen::POINTER()
-{
- // multiple items seperated by commas can also be pointer types.
- return "* ";
-}
-
-string DCodeGen::PTR_CONST()
-{
- return "";
-}
-
-std::ostream &DCodeGen::OPEN_ARRAY( string type, string name )
-{
- out << "static const " << type << "[] " << name << " = [\n";
- return out;
-}
-
-std::ostream &DCodeGen::CLOSE_ARRAY()
-{
- return out << "];\n";
-}
-
-std::ostream &DCodeGen::STATIC_VAR( string type, string name )
-{
- out << "static const " << type << " " << name;
- return out;
-}
-
-string DCodeGen::ARR_OFF( string ptr, string offset )
-{
- return "&" + ptr + "[" + offset + "]";
-}
-
-string DCodeGen::CAST( string type )
-{
- return "cast(" + type + ")";
-}
-
-string DCodeGen::UINT( )
-{
- return "uint";
-}
-
-std::ostream &DCodeGen::SWITCH_DEFAULT()
-{
- out << " default: break;\n";
- return out;
-}
-
-string DCodeGen::CTRL_FLOW()
-{
- return "if (true) ";
-}
-
-
-/*
- * Java Specific
- */
-
-string JavaCodeGen::PTR_CONST()
-{
- /* Not used in Java code. */
- assert( false );
- return "final";
-}
-
-std::ostream &JavaCodeGen::OPEN_ARRAY( string type, string name )
-{
- out << "static final " << type << "[] " << name << " = {\n";
- return out;
-}
-
-std::ostream &JavaCodeGen::CLOSE_ARRAY()
-{
- return out << "};\n";
-}
-
-std::ostream &JavaCodeGen::STATIC_VAR( string type, string name )
-{
- out << "static final " << type << " " << name;
- return out;
-}
-
-string JavaCodeGen::UINT( )
-{
- /* Not used. */
- assert( false );
- return "long";
-}
-
-string JavaCodeGen::ARR_OFF( string ptr, string offset )
-{
- return ptr + " + " + offset;
-}
-
-string JavaCodeGen::CAST( string type )
-{
- return "(" + type + ")";
-}
-
-string JavaCodeGen::NULL_ITEM()
-{
- /* In java we use integers instead of pointers. */
- return "-1";
-}
-
-string JavaCodeGen::POINTER()
-{
- /* Not used. */
- assert( false );
- return " *";
-}
-
-std::ostream &JavaCodeGen::SWITCH_DEFAULT()
-{
- return out;
-}
-
-string JavaCodeGen::GET_KEY()
-{
- ostringstream ret;
- if ( cgd->getKeyExpr != 0 ) {
- /* Emit the user supplied method of retrieving the key. */
- ret << "(";
- INLINE_LIST( ret, cgd->getKeyExpr, 0, false );
- ret << ")";
- }
- else {
- /* Expression for retrieving the key, use simple dereference. */
- ret << "data[" << P() << "]";
- }
- return ret.str();
-}
-
-string JavaCodeGen::CTRL_FLOW()
-{
- return "if (true) ";
-}
-
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- * 2004 Eric Ocean <eric.ocean@ampede.com>
- * 2005 Alan West <alan@alanz.com>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _FSMCODEGEN_H
-#define _FSMCODEGEN_H
-
-#include <iostream>
-#include <string>
-#include <stdio.h>
-#include "common.h"
-
-using std::string;
-using std::ostream;
-
-/* Integer array line length. */
-#define IALL 8
-
-/* Forwards. */
-struct RedFsmAp;
-struct RedStateAp;
-struct CodeGenData;
-struct Action;
-struct NameInst;
-struct InlineItem;
-struct InlineList;
-struct RedAction;
-struct LongestMatch;
-struct LongestMatchPart;
-
-inline string itoa( int i )
-{
- char buf[16];
- sprintf( buf, "%i", i );
- return buf;
-}
-
-/*
- * class FsmCodeGen
- */
-class FsmCodeGen
-{
-public:
- FsmCodeGen();
- virtual ~FsmCodeGen() {}
-
- virtual void writeOutData() = 0;
- virtual void writeOutInit();
- virtual void writeOutExec() = 0;
- virtual void writeOutEOF() = 0;
-
- /* Gather various info on the machine. */
- void analyzeAction( Action *act, InlineList *inlineList );
- void analyzeActionList( RedAction *redAct, InlineList *inlineList );
- void analyzeMachine();
-
-protected:
- friend struct CodeGenData;
-
- string FSM_NAME();
- string START_STATE_ID();
- ostream &ACTIONS_ARRAY();
- string GET_WIDE_KEY();
- string GET_WIDE_KEY( RedStateAp *state );
- string TABS( int level );
- string KEY( Key key );
- string LDIR_PATH( char *path );
- void ACTION( ostream &ret, Action *action, int targState, bool inFinish );
- void CONDITION( ostream &ret, Action *condition );
- string ALPH_TYPE();
- string WIDE_ALPH_TYPE();
- string ARRAY_TYPE( unsigned long maxVal );
-
- virtual string ARR_OFF( string ptr, string offset ) = 0;
- virtual string CAST( string type ) = 0;
- virtual string UINT() = 0;
- virtual string NULL_ITEM() = 0;
- virtual string POINTER() = 0;
- virtual string GET_KEY();
- virtual ostream &SWITCH_DEFAULT() = 0;
-
- string P() { return "p"; }
- string PE() { return "pe"; }
-
- string ACCESS();
- string CS();
- string STACK() { return ACCESS() + "stack"; }
- string TOP() { return ACCESS() + "top"; }
- string TOKSTART() { return ACCESS() + "tokstart"; }
- string TOKEND() { return ACCESS() + "tokend"; }
- string ACT() { return ACCESS() + "act"; }
-
- string DATA_PREFIX();
- string PM() { return "_" + DATA_PREFIX() + "partition_map"; }
- string C() { return "_" + DATA_PREFIX() + "cond_spaces"; }
- string CK() { return "_" + DATA_PREFIX() + "cond_keys"; }
- string K() { return "_" + DATA_PREFIX() + "trans_keys"; }
- string I() { return "_" + DATA_PREFIX() + "indicies"; }
- string CO() { return "_" + DATA_PREFIX() + "cond_offsets"; }
- string KO() { return "_" + DATA_PREFIX() + "key_offsets"; }
- string IO() { return "_" + DATA_PREFIX() + "index_offsets"; }
- string CL() { return "_" + DATA_PREFIX() + "cond_lengths"; }
- string SL() { return "_" + DATA_PREFIX() + "single_lengths"; }
- string RL() { return "_" + DATA_PREFIX() + "range_lengths"; }
- string A() { return "_" + DATA_PREFIX() + "actions"; }
- string TA() { return "_" + DATA_PREFIX() + "trans_actions_wi"; }
- string TT() { return "_" + DATA_PREFIX() + "trans_targs_wi"; }
- string TSA() { return "_" + DATA_PREFIX() + "to_state_actions"; }
- string FSA() { return "_" + DATA_PREFIX() + "from_state_actions"; }
- string EA() { return "_" + DATA_PREFIX() + "eof_actions"; }
- string SP() { return "_" + DATA_PREFIX() + "key_spans"; }
- string CSP() { return "_" + DATA_PREFIX() + "cond_key_spans"; }
- string START() { return DATA_PREFIX() + "start"; }
- string ERROR() { return DATA_PREFIX() + "error"; }
- string FIRST_FINAL() { return DATA_PREFIX() + "first_final"; }
- string CTXDATA() { return DATA_PREFIX() + "ctxdata"; }
-
- void INLINE_LIST( ostream &ret, InlineList *inlineList, int targState, bool inFinish );
- virtual void GOTO( ostream &ret, int gotoDest, bool inFinish ) = 0;
- virtual void CALL( ostream &ret, int callDest, int targState, bool inFinish ) = 0;
- virtual void NEXT( ostream &ret, int nextDest, bool inFinish ) = 0;
- virtual void GOTO_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish ) = 0;
- virtual void NEXT_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish ) = 0;
- virtual void CALL_EXPR( ostream &ret, InlineItem *ilItem,
- int targState, bool inFinish ) = 0;
- virtual void RET( ostream &ret, bool inFinish ) = 0;
- virtual void BREAK( ostream &ret, int targState ) = 0;
- virtual void CURS( ostream &ret, bool inFinish ) = 0;
- virtual void TARGS( ostream &ret, bool inFinish, int targState ) = 0;
- void EXEC( ostream &ret, InlineItem *item, int targState, int inFinish );
- void EXECTE( ostream &ret, InlineItem *item, int targState, int inFinish );
- void LM_SWITCH( ostream &ret, InlineItem *item, int targState, int inFinish );
- void SET_ACT( ostream &ret, InlineItem *item );
- void INIT_TOKSTART( ostream &ret, InlineItem *item );
- void INIT_ACT( ostream &ret, InlineItem *item );
- void SET_TOKSTART( ostream &ret, InlineItem *item );
- void SET_TOKEND( ostream &ret, InlineItem *item );
- void GET_TOKEND( ostream &ret, InlineItem *item );
- void SUB_ACTION( ostream &ret, InlineItem *item,
- int targState, bool inFinish );
-
- string ERROR_STATE();
- string FIRST_FINAL_STATE();
-
- virtual string PTR_CONST() = 0;
- virtual ostream &OPEN_ARRAY( string type, string name ) = 0;
- virtual ostream &CLOSE_ARRAY() = 0;
- virtual ostream &STATIC_VAR( string type, string name ) = 0;
-
- virtual string CTRL_FLOW() = 0;
-
- unsigned int arrayTypeSize( unsigned long maxVal );
-
- bool anyActions();
- bool anyToStateActions() { return bAnyToStateActions; }
- bool anyFromStateActions() { return bAnyFromStateActions; }
- bool anyRegActions() { return bAnyRegActions; }
- bool anyEofActions() { return bAnyEofActions; }
- bool anyActionGotos() { return bAnyActionGotos; }
- bool anyActionCalls() { return bAnyActionCalls; }
- bool anyActionRets() { return bAnyActionRets; }
- bool anyRegActionRets() { return bAnyRegActionRets; }
- bool anyRegActionByValControl() { return bAnyRegActionByValControl; }
- bool anyRegNextStmt() { return bAnyRegNextStmt; }
- bool anyRegCurStateRef() { return bAnyRegCurStateRef; }
- bool anyRegBreak() { return bAnyRegBreak; }
- bool anyLmSwitchError() { return bAnyLmSwitchError; }
- bool anyConditions() { return bAnyConditions; }
-
- /* Set up labelNeeded flag for each state. Differs for each goto style so
- * is virtual. */
- virtual void setLabelsNeeded() {}
-
- /* Determine if we should use indicies. */
- virtual void calcIndexSize() {}
-
- void findFinalActionRefs();
- void assignActionIds();
- void setValueLimits();
-
- /* Are there any regular transition functions, any out transition functions. */
- char *fsmName;
- CodeGenData *cgd;
- RedFsmAp *redFsm;
-
- bool outLabelUsed;
- bool againLabelUsed;
-
-protected:
- ostream &out;
-
- bool bAnyToStateActions;
- bool bAnyFromStateActions;
- bool bAnyRegActions;
- bool bAnyEofActions;
- bool bAnyActionGotos;
- bool bAnyActionCalls;
- bool bAnyActionRets;
- bool bAnyRegActionRets;
- bool bAnyRegActionByValControl;
- bool bAnyRegNextStmt;
- bool bAnyRegCurStateRef;
- bool bAnyRegBreak;
- bool bAnyLmSwitchError;
- bool bAnyConditions;
-
- int maxState;
- int maxSingleLen;
- int maxRangeLen;
- int maxKeyOffset;
- int maxIndexOffset;
- int maxIndex;
- int maxActListId;
- int maxActionLoc;
- int maxActArrItem;
- unsigned long long maxSpan;
- unsigned long long maxCondSpan;
- int maxFlatIndexOffset;
- Key maxKey;
- int maxCondOffset;
- int maxCondLen;
- int maxCondSpaceId;
- int maxCondIndexOffset;
- int maxCond;
-
- bool useIndicies;
-};
-
-class CCodeGen : virtual public FsmCodeGen
-{
-public:
- virtual string NULL_ITEM();
- virtual string POINTER();
- virtual ostream &SWITCH_DEFAULT();
- virtual ostream &OPEN_ARRAY( string type, string name );
- virtual ostream &CLOSE_ARRAY();
- virtual ostream &STATIC_VAR( string type, string name );
- virtual string ARR_OFF( string ptr, string offset );
- virtual string CAST( string type );
- virtual string UINT();
- virtual string PTR_CONST();
- virtual string CTRL_FLOW();
-};
-
-class DCodeGen : virtual public FsmCodeGen
-{
-public:
- virtual string NULL_ITEM();
- virtual string POINTER();
- virtual ostream &SWITCH_DEFAULT();
- virtual ostream &OPEN_ARRAY( string type, string name );
- virtual ostream &CLOSE_ARRAY();
- virtual ostream &STATIC_VAR( string type, string name );
- virtual string ARR_OFF( string ptr, string offset );
- virtual string CAST( string type );
- virtual string UINT();
- virtual string PTR_CONST();
- virtual string CTRL_FLOW();
-};
-
-class JavaCodeGen : virtual public FsmCodeGen
-{
-public:
- virtual string NULL_ITEM();
- virtual string POINTER();
- virtual ostream &SWITCH_DEFAULT();
- virtual ostream &OPEN_ARRAY( string type, string name );
- virtual ostream &CLOSE_ARRAY();
- virtual ostream &STATIC_VAR( string type, string name );
- virtual string ARR_OFF( string ptr, string offset );
- virtual string CAST( string type );
- virtual string UINT();
- virtual string PTR_CONST();
- virtual string GET_KEY();
- virtual string CTRL_FLOW();
-};
-
-#endif /* _FSMCODEGEN_H */
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- * 2004 Eric Ocean <eric.ocean@ampede.com>
- * 2005 Alan West <alan@alanz.com>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "rlcodegen.h"
-#include "ftabcodegen.h"
-#include "redfsm.h"
-#include "gendata.h"
-
-/* Determine if we should use indicies or not. */
-void FTabCodeGen::calcIndexSize()
-{
- int sizeWithInds = 0, sizeWithoutInds = 0;
-
- /* Calculate cost of using with indicies. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- int totalIndex = st->outSingle.length() + st->outRange.length() +
- (st->defTrans == 0 ? 0 : 1);
- sizeWithInds += arrayTypeSize(maxIndex) * totalIndex;
- }
- sizeWithInds += arrayTypeSize(maxState) * redFsm->transSet.length();
- if ( anyActions() )
- sizeWithInds += arrayTypeSize(maxActListId) * redFsm->transSet.length();
-
- /* Calculate the cost of not using indicies. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- int totalIndex = st->outSingle.length() + st->outRange.length() +
- (st->defTrans == 0 ? 0 : 1);
- sizeWithoutInds += arrayTypeSize(maxState) * totalIndex;
- if ( anyActions() )
- sizeWithoutInds += arrayTypeSize(maxActListId) * totalIndex;
- }
-
- /* If using indicies reduces the size, use them. */
- useIndicies = sizeWithInds < sizeWithoutInds;
-}
-
-std::ostream &FTabCodeGen::TO_STATE_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->toStateAction != 0 )
- act = state->toStateAction->actListId+1;
- out << act;
- return out;
-}
-
-std::ostream &FTabCodeGen::FROM_STATE_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->fromStateAction != 0 )
- act = state->fromStateAction->actListId+1;
- out << act;
- return out;
-}
-
-std::ostream &FTabCodeGen::EOF_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->eofAction != 0 )
- act = state->eofAction->actListId+1;
- out << act;
- return out;
-}
-
-
-/* Write out the function for a transition. */
-std::ostream &FTabCodeGen::TRANS_ACTION( RedTransAp *trans )
-{
- int action = 0;
- if ( trans->action != 0 )
- action = trans->action->actListId+1;
- out << action;
- return out;
-}
-
-/* Write out the function switch. This switch is keyed on the values
- * of the func index. */
-std::ostream &FTabCodeGen::TO_STATE_ACTION_SWITCH()
-{
- /* Loop the actions. */
- for ( ActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
- if ( redAct->numToStateRefs > 0 ) {
- /* Write the entry label. */
- out << "\tcase " << redAct->actListId+1 << ":\n";
-
- /* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
- ACTION( out, item->value, 0, false );
-
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-/* Write out the function switch. This switch is keyed on the values
- * of the func index. */
-std::ostream &FTabCodeGen::FROM_STATE_ACTION_SWITCH()
-{
- /* Loop the actions. */
- for ( ActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
- if ( redAct->numFromStateRefs > 0 ) {
- /* Write the entry label. */
- out << "\tcase " << redAct->actListId+1 << ":\n";
-
- /* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
- ACTION( out, item->value, 0, false );
-
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-std::ostream &FTabCodeGen::EOF_ACTION_SWITCH()
-{
- /* Loop the actions. */
- for ( ActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
- if ( redAct->numEofRefs > 0 ) {
- /* Write the entry label. */
- out << "\tcase " << redAct->actListId+1 << ":\n";
-
- /* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
- ACTION( out, item->value, 0, true );
-
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-/* Write out the function switch. This switch is keyed on the values
- * of the func index. */
-std::ostream &FTabCodeGen::ACTION_SWITCH()
-{
- /* Loop the actions. */
- for ( ActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
- if ( redAct->numTransRefs > 0 ) {
- /* Write the entry label. */
- out << "\tcase " << redAct->actListId+1 << ":\n";
-
- /* Write each action in the list of action items. */
- for ( ActionTable::Iter item = redAct->key; item.lte(); item++ )
- ACTION( out, item->value, 0, false );
-
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-void FTabCodeGen::writeOutData()
-{
- if ( anyConditions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxCondOffset), CO() );
- COND_OFFSETS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxCondLen), CL() );
- COND_LENS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() );
- COND_KEYS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxCondSpaceId), C() );
- COND_SPACES();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- OPEN_ARRAY( ARRAY_TYPE(maxKeyOffset), KO() );
- KEY_OFFSETS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( WIDE_ALPH_TYPE(), K() );
- KEYS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxSingleLen), SL() );
- SINGLE_LENS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxRangeLen), RL() );
- RANGE_LENS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxIndexOffset), IO() );
- INDEX_OFFSETS();
- CLOSE_ARRAY() <<
- "\n";
-
- if ( useIndicies ) {
- OPEN_ARRAY( ARRAY_TYPE(maxIndex), I() );
- INDICIES();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxState), TT() );
- TRANS_TARGS_WI();
- CLOSE_ARRAY() <<
- "\n";
-
- if ( anyActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActListId), TA() );
- TRANS_ACTIONS_WI();
- CLOSE_ARRAY() <<
- "\n";
- }
- }
- else {
- OPEN_ARRAY( ARRAY_TYPE(maxState), TT() );
- TRANS_TARGS();
- CLOSE_ARRAY() <<
- "\n";
-
- if ( anyActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActListId), TA() );
- TRANS_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
- }
-
- if ( anyToStateActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), TSA() );
- TO_STATE_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- if ( anyFromStateActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), FSA() );
- FROM_STATE_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- if ( anyEofActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActListId), EA() );
- EOF_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- out <<
- "static const int " << START() << " = " << START_STATE_ID() << ";\n"
- "\n";
-
- if ( cgd->writeFirstFinal ) {
- out <<
- "static const int " << FIRST_FINAL() << " = " << FIRST_FINAL_STATE() << ";\n"
- "\n";
- }
-
- if ( cgd->writeErr ) {
- out <<
- "static const int " << ERROR() << " = " << ERROR_STATE() << ";\n"
- "\n";
- }
-}
-
-void FTabCodeGen::writeOutExec()
-{
- outLabelUsed = false;
-
- out <<
- " {\n"
- " int _klen";
-
- if ( anyRegCurStateRef() )
- out << ", _ps";
-
- out <<
- ";\n"
- " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_keys;\n"
- " int _trans;\n";
-
- if ( anyConditions() )
- out << " " << WIDE_ALPH_TYPE() << " _widec;\n";
-
- out << "\n";
-
- if ( cgd->hasEnd ) {
- outLabelUsed = true;
- out <<
- " if ( " << P() << " == " << PE() << " )\n"
- " goto _out;\n";
- }
-
- out << "_resume:\n";
-
- if ( redFsm->errState != 0 ) {
- outLabelUsed = true;
- out <<
- " if ( " << CS() << " == " << redFsm->errState->id << " )\n"
- " goto _out;\n";
- }
-
- if ( anyFromStateActions() ) {
- out <<
- " switch ( " << FSA() << "[" << CS() << "] ) {\n";
- FROM_STATE_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- "\n";
- }
-
- if ( anyConditions() )
- COND_TRANSLATE();
-
- LOCATE_TRANS();
-
- out << "_match:\n";
-
- if ( anyRegCurStateRef() )
- out << " _ps = " << CS() << ";\n";
-
- if ( useIndicies )
- out << " _trans = " << I() << "[_trans];\n";
-
- out <<
- " " << CS() << " = " << TT() << "[_trans];\n"
- "\n";
-
- if ( anyRegActions() ) {
- out <<
- " if ( " << TA() << "[_trans] == 0 )\n"
- " goto _again;\n"
- "\n"
- " switch ( " << TA() << "[_trans] ) {\n";
- ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- "\n";
- }
-
- if ( anyRegActions() || anyActionGotos() || anyActionCalls() || anyActionRets() )
- out << "_again:\n";
-
- if ( anyToStateActions() ) {
- out <<
- " switch ( " << TSA() << "[" << CS() << "] ) {\n";
- TO_STATE_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- "\n";
- }
-
- if ( cgd->hasEnd ) {
- out <<
- " if ( ++" << P() << " != " << PE() << " )\n"
- " goto _resume;\n";
- }
- else {
- out <<
- " " << P() << " += 1;\n"
- " goto _resume;\n";
- }
-
-
- if ( outLabelUsed )
- out << " _out: {}\n";
-
- out << " }\n";
-}
-
-
-void FTabCodeGen::writeOutEOF()
-{
- if ( anyEofActions() ) {
- out <<
- " {\n"
- " switch ( " << EA() << "[" << CS() << "] ) {\n";
- EOF_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- "\n";
- }
-}
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- * 2004 Eric Ocean <eric.ocean@ampede.com>
- * 2005 Alan West <alan@alanz.com>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _FTABCODEGEN_H
-#define _FTABCODEGEN_H
-
-#include <iostream>
-#include "tabcodegen.h"
-
-/* Forwards. */
-struct CodeGenData;
-
-
-/*
- * FTabCodeG\verb|e
- */
-class FTabCodeGen : public TabCodeGen
-{
-protected:
- std::ostream &TO_STATE_ACTION_SWITCH();
- std::ostream &FROM_STATE_ACTION_SWITCH();
- std::ostream &EOF_ACTION_SWITCH();
- std::ostream &ACTION_SWITCH();
-
- virtual std::ostream &TO_STATE_ACTION( RedStateAp *state );
- virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state );
- virtual std::ostream &EOF_ACTION( RedStateAp *state );
- virtual std::ostream &TRANS_ACTION( RedTransAp *trans );
- virtual void calcIndexSize();
- virtual void writeOutData();
- virtual void writeOutEOF();
- virtual void writeOutExec();
-};
-
-
-/*
- * CFTabCodeGen
- */
-struct CFTabCodeGen
- : public FTabCodeGen, public CCodeGen
-{
-};
-
-/*
- * class DFTabCodeGen
- */
-struct DFTabCodeGen
- : public FTabCodeGen, public DCodeGen
-{
-};
-
-#endif /* _FTABCODEGEN_H */
+++ /dev/null
-/*
- * Copyright 2005-2006 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "gendata.h"
-
-/* Code Generators. */
-#include "gvdotgen.h"
-#include "tabcodegen.h"
-#include "ftabcodegen.h"
-#include "flatcodegen.h"
-#include "fflatcodegen.h"
-#include "gotocodegen.h"
-#include "fgotocodegen.h"
-#include "ipgotocodegen.h"
-#include "splitcodegen.h"
-#include "javacodegen.h"
-
-#include <iostream>
-
-using std::cerr;
-using std::endl;
-
-CodeGenData *cgd = 0;
-
-void CodeGenData::createMachine()
-{
- redFsm = new RedFsmAp();
-}
-
-void CodeGenData::initActionList( unsigned long length )
-{
- allActions = new Action[length];
- for ( unsigned long a = 0; a < length; a++ )
- actionList.append( allActions+a );
-}
-
-void CodeGenData::newAction( int anum, char *name, int line,
- int col, InlineList *inlineList )
-{
- allActions[anum].actionId = anum;
- allActions[anum].name = name;
- allActions[anum].loc.line = line;
- allActions[anum].loc.col = col;
- allActions[anum].inlineList = inlineList;
-}
-
-void CodeGenData::initActionTableList( unsigned long length )
-{
- allActionTables = new RedAction[length];
-}
-
-void CodeGenData::initStateList( unsigned long length )
-{
- allStates = new RedStateAp[length];
- for ( unsigned long s = 0; s < length; s++ )
- redFsm->stateList.append( allStates+s );
-}
-
-void CodeGenData::setStartState( unsigned long startState )
-{
- this->startState = startState;
-}
-
-void CodeGenData::addEntryPoint( char *name, unsigned long entryState )
-{
- entryPointIds.append( entryState );
- entryPointNames.append( name );
-}
-
-void CodeGenData::initTransList( int snum, unsigned long length )
-{
- /* Could preallocate the out range to save time growing it. For now do
- * nothing. */
-}
-
-void CodeGenData::newTrans( int snum, int tnum, Key lowKey,
- Key highKey, long targ, long action )
-{
- /* Get the current state and range. */
- RedStateAp *curState = allStates + snum;
- RedTransList &destRange = curState->outRange;
-
- /* Make the new transitions. */
- RedStateAp *targState = targ >= 0 ? (allStates + targ) :
- wantComplete ? redFsm->getErrorState() : 0;
- RedAction *actionTable = action >= 0 ? (allActionTables + action) : 0;
- RedTransAp *trans = redFsm->allocateTrans( targState, actionTable );
- RedTransEl transEl( lowKey, highKey, trans );
-
- if ( wantComplete ) {
- /* If the machine is to be complete then we need to fill any gaps with
- * the error transitions. */
- if ( destRange.length() == 0 ) {
- /* Range is currently empty. */
- if ( keyOps->minKey < lowKey ) {
- /* The first range doesn't start at the low end. */
- Key fillHighKey = lowKey;
- fillHighKey.decrement();
-
- /* Create the filler with the state's error transition. */
- RedTransEl newTel( keyOps->minKey, fillHighKey, redFsm->getErrorTrans() );
- destRange.append( newTel );
- }
- }
- else {
- /* The range list is not empty, get the the last range. */
- RedTransEl *last = &destRange[destRange.length()-1];
- Key nextKey = last->highKey;
- nextKey.increment();
- if ( nextKey < lowKey ) {
- /* There is a gap to fill. Make the high key. */
- Key fillHighKey = lowKey;
- fillHighKey.decrement();
-
- /* Create the filler with the state's error transtion. */
- RedTransEl newTel( nextKey, fillHighKey, redFsm->getErrorTrans() );
- destRange.append( newTel );
- }
- }
- }
-
- /* Filler taken care of. Append the range. */
- destRange.append( RedTransEl( lowKey, highKey, trans ) );
-}
-
-void CodeGenData::finishTransList( int snum )
-{
- /* Get the current state and range. */
- RedStateAp *curState = allStates + snum;
- RedTransList &destRange = curState->outRange;
-
- /* If building a complete machine we may need filler on the end. */
- if ( wantComplete ) {
- /* Check if there are any ranges already. */
- if ( destRange.length() == 0 ) {
- /* Fill with the whole alphabet. */
- /* Add the range on the lower and upper bound. */
- RedTransEl newTel( keyOps->minKey, keyOps->maxKey, redFsm->getErrorTrans() );
- destRange.append( newTel );
- }
- else {
- /* Get the last and check for a gap on the end. */
- RedTransEl *last = &destRange[destRange.length()-1];
- if ( last->highKey < keyOps->maxKey ) {
- /* Make the high key. */
- Key fillLowKey = last->highKey;
- fillLowKey.increment();
-
- /* Create the new range with the error trans and append it. */
- RedTransEl newTel( fillLowKey, keyOps->maxKey, redFsm->getErrorTrans() );
- destRange.append( newTel );
- }
- }
- }
-}
-
-void CodeGenData::setFinal( int snum )
-{
- RedStateAp *curState = allStates + snum;
- curState->isFinal = true;
-}
-
-
-void CodeGenData::setStateActions( int snum, long toStateAction,
- long fromStateAction, long eofAction )
-{
- RedStateAp *curState = allStates + snum;
- if ( toStateAction >= 0 )
- curState->toStateAction = allActionTables + toStateAction;
- if ( fromStateAction >= 0 )
- curState->fromStateAction = allActionTables + fromStateAction;
- if ( eofAction >= 0 )
- curState->eofAction = allActionTables + eofAction;
-}
-
-void CodeGenData::resolveTargetStates( InlineList *inlineList )
-{
- for ( InlineList::Iter item = *inlineList; item.lte(); item++ ) {
- switch ( item->type ) {
- case InlineItem::Goto: case InlineItem::Call:
- case InlineItem::Next: case InlineItem::Entry:
- item->targState = allStates + item->targId;
- break;
- default:
- break;
- }
-
- if ( item->children != 0 )
- resolveTargetStates( item->children );
- }
-}
-
-
-void CodeGenData::finishMachine()
-{
- if ( redFsm->forcedErrorState )
- redFsm->getErrorState();
-
- /* We get the start state as an offset, set the pointer now. */
- redFsm->startState = allStates + startState;
- for ( EntryIdVect::Iter en = entryPointIds; en.lte(); en++ )
- redFsm->entryPoints.insert( allStates + *en );
-
- for ( ActionList::Iter a = actionList; a.lte(); a++ )
- resolveTargetStates( a->inlineList );
-
- /* Note that even if we want a complete graph we do not give the error
- * state a default transition. All machines break out of the processing
- * loop when in the error state. */
-
- if ( codeStyle == GenGoto || codeStyle == GenFGoto || codeStyle == GenIpGoto ) {
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- for ( StateCondList::Iter sci = st->stateCondList; sci.lte(); sci++ )
- st->stateCondVect.append( sci );
- }
- }
-}
-
-
-bool CodeGenData::setAlphType( char *data )
-{
- /* FIXME: This should validate the alphabet type selection. */
- HostType *alphType = hostLang->hostTypes + atoi(data);
- thisKeyOps.setAlphType( alphType );
- return true;
-}
-
-void CodeGenData::initCondSpaceList( ulong length )
-{
- allCondSpaces = new CondSpace[length];
- for ( ulong c = 0; c < length; c++ )
- condSpaceList.append( allCondSpaces + c );
-}
-
-void CodeGenData::newCondSpace( int cnum, int condSpaceId, Key baseKey )
-{
- CondSpace *cond = allCondSpaces + cnum;
- cond->condSpaceId = condSpaceId;
- cond->baseKey = baseKey;
-}
-
-void CodeGenData::condSpaceItem( int cnum, long condActionId )
-{
- CondSpace *cond = allCondSpaces + cnum;
- cond->condSet.append( allActions + condActionId );
-}
-
-void CodeGenData::initStateCondList( int snum, ulong length )
-{
- /* Could preallocate these, as we could with transitions. */
-}
-
-void CodeGenData::addStateCond( int snum, Key lowKey, Key highKey, long condNum )
-{
- RedStateAp *curState = allStates + snum;
-
- /* Create the new state condition. */
- StateCond *stateCond = new StateCond;
- stateCond->lowKey = lowKey;
- stateCond->highKey = highKey;
-
- /* Assign it a cond space. */
- CondSpace *condSpace = allCondSpaces + condNum;
- stateCond->condSpace = condSpace;
-
- curState->stateCondList.append( stateCond );
-}
-
-
-/* Generate the codegen depending on the command line options given. */
-void CodeGenData::makeCodeGen()
-{
- switch ( hostLangType ) {
- case CCode:
- switch ( codeStyle ) {
- case GenTables:
- codeGen = new CTabCodeGen;
- break;
- case GenFTables:
- codeGen = new CFTabCodeGen;
- break;
- case GenFlat:
- codeGen = new CFlatCodeGen;
- break;
- case GenFFlat:
- codeGen = new CFFlatCodeGen;
- break;
- case GenGoto:
- codeGen = new CGotoCodeGen;
- break;
- case GenFGoto:
- codeGen = new CFGotoCodeGen;
- break;
- case GenIpGoto:
- codeGen = new CIpGotoCodeGen;
- break;
- case GenSplit:
- codeGen = new CSplitCodeGen;
- break;
- }
- break;
-
- case DCode:
- switch ( codeStyle ) {
- case GenTables:
- codeGen = new DTabCodeGen;
- break;
- case GenFTables:
- codeGen = new DFTabCodeGen;
- break;
- case GenFlat:
- codeGen = new DFlatCodeGen;
- break;
- case GenFFlat:
- codeGen = new DFFlatCodeGen;
- break;
- case GenGoto:
- codeGen = new DGotoCodeGen;
- break;
- case GenFGoto:
- codeGen = new DFGotoCodeGen;
- break;
- case GenIpGoto:
- codeGen = new DIpGotoCodeGen;
- break;
- case GenSplit:
- codeGen = new DSplitCodeGen;
- break;
- }
- break;
-
- case JavaCode:
- switch ( codeStyle ) {
- case GenTables:
- codeGen = new JavaTabCodeGen;
- break;
- default:
- assert(false);
- break;
- }
- break;
- }
-
- codeGen->fsmName = fsmName;
- codeGen->cgd = this;
-}
-
-CondSpace *CodeGenData::findCondSpace( Key lowKey, Key highKey )
-{
- for ( CondSpaceList::Iter cs = condSpaceList; cs.lte(); cs++ ) {
- Key csHighKey = cs->baseKey;
- csHighKey += keyOps->alphSize() * (1 << cs->condSet.length());
-
- if ( lowKey >= cs->baseKey && highKey <= csHighKey )
- return cs;
- }
- return 0;
-}
-
-Condition *CodeGenData::findCondition( Key key )
-{
- for ( ConditionList::Iter cond = conditionList; cond.lte(); cond++ ) {
- Key upperKey = cond->baseKey + (1 << cond->condSet.length());
- if ( cond->baseKey <= key && key <= upperKey )
- return cond;
- }
- return 0;
-}
-
-Key CodeGenData::findMaxKey()
-{
- Key maxKey = keyOps->maxKey;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- assert( st->outSingle.length() == 0 );
- assert( st->defTrans == 0 );
-
- long rangeLen = st->outRange.length();
- if ( rangeLen > 0 ) {
- Key highKey = st->outRange[rangeLen-1].highKey;
- if ( highKey > maxKey )
- maxKey = highKey;
- }
- }
- return maxKey;
-}
-
-/* Generate the code for an fsm. Assumes parseData is set up properly. Called
- * by parser code. */
-void CodeGenData::prepareMachine()
-{
- if ( hasBeenPrepared )
- return;
- hasBeenPrepared = true;
-
- /* Do this before distributing transitions out to singles and defaults
- * makes life easier. */
- Key maxKey = findMaxKey();
-
- redFsm->assignActionLocs();
-
- /* Order the states. */
- redFsm->depthFirstOrdering();
-
- if ( codeStyle == GenGoto || codeStyle == GenFGoto ||
- codeStyle == GenIpGoto || codeStyle == GenSplit )
- {
- /* For goto driven machines we can keep the original depth
- * first ordering because it's ok if the state ids are not
- * sequential. Split the the ids by final state status. */
- redFsm->sortStateIdsByFinal();
- }
- else {
- /* For table driven machines the location of the state is used to
- * identify it so the states must be sorted by their final ids.
- * Though having a deterministic ordering is important,
- * specifically preserving the depth first ordering is not because
- * states are stored in tables. */
- redFsm->sortStatesByFinal();
- redFsm->sequentialStateIds();
- }
-
- /* Find the first final state. This is the final state with the lowest
- * id. */
- redFsm->findFirstFinState();
-
- /* Choose default transitions and the single transition. */
- redFsm->chooseDefaultSpan();
-
- /* Maybe do flat expand, otherwise choose single. */
- if ( codeStyle == GenFlat || codeStyle == GenFFlat )
- redFsm->makeFlat();
- else
- redFsm->chooseSingle();
-
- /* If any errors have occured in the input file then don't write anything. */
- if ( gblErrorCount > 0 )
- return;
-
- if ( codeStyle == GenSplit )
- redFsm->partitionFsm( numSplitPartitions );
-
- if ( codeStyle == GenIpGoto || codeStyle == GenSplit )
- redFsm->setInTrans();
-
- /* Make a code generator that will output the header/code. */
- if ( codeGen == 0 )
- makeCodeGen();
- codeGen->redFsm = redFsm;
-
- /* Anlayze Machine will find the final action reference counts, among
- * other things. We will use these in reporting the usage
- * of fsm directives in action code. */
- codeGen->analyzeMachine();
- codeGen->maxKey = maxKey;
-}
-
-void CodeGenData::generateGraphviz()
-{
- /* Do ordering and choose state ids. */
- redFsm->depthFirstOrdering();
- redFsm->sequentialStateIds();
-
- /* For dot file generation we want to pick default transitions. */
- redFsm->chooseDefaultSpan();
-
- /* Make the generator. */
- GraphvizDotGen dotGen( fsmName, this, redFsm, *outStream );
-
- /* Write out with it. */
- dotGen.writeDotFile();
-}
-
-void CodeGenData::generateCode()
-{
- if ( writeOps & WO_NOEND )
- hasEnd = false;
-
- if ( writeOps & WO_NOERROR )
- writeErr = false;
-
- if ( writeOps & WO_NOPREFIX )
- dataPrefix = false;
-
- if ( writeOps & WO_NOFF )
- writeFirstFinal = false;
-
- if ( writeData || writeInit || writeExec || writeEOF ) {
- prepareMachine();
-
- /* Force a newline. */
- *outStream << "\n";
- genLineDirective( *outStream );
- }
-
-
- if ( writeExec ) {
- /* Must set labels immediately before writing because we may depend
- * on the noend write option. */
- codeGen->setLabelsNeeded();
- }
-
- if ( writeData )
- codeGen->writeOutData();
-
- if ( writeInit )
- codeGen->writeOutInit();
-
- if ( writeExec )
- codeGen->writeOutExec();
-
- if ( writeEOF )
- codeGen->writeOutEOF();
-}
-
-void CodeGenData::generate()
-{
- if ( redFsm != 0 ) {
- if ( outputFormat == OutCode )
- generateCode();
- else if ( outputFormat == OutGraphvizDot && !graphvizDone ) {
- graphvizDone = true;
- generateGraphviz();
- }
- }
-}
-
-void lineDirective( ostream &out, char *fileName, int line )
-{
- if ( hostLangType != JavaCode ) {
- /* Write the preprocessor line info for to the input file. */
- out << "#line " << line << " \"";
- for ( char *pc = fileName; *pc != 0; pc++ ) {
- if ( *pc == '\\' )
- out << "\\\\";
- else
- out << *pc;
- }
- out << "\"\n";
- }
-}
-
-void genLineDirective( ostream &out )
-{
- lineDirective( out, outputFileName, outFilter->line + 1 );
-}
+++ /dev/null
-/*
- * Copyright 2005-2006 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _GENDATA_H
-#define _GENDATA_H
-
-#include <iostream>
-#include "redfsm.h"
-#include "fsmcodegen.h"
-#include "common.h"
-
-struct NameInst;
-typedef DList<Action> ActionList;
-
-typedef unsigned long ulong;
-
-typedef AvlMap<char *, CodeGenData*, CmpStr> CodeGenMap;
-typedef AvlMapEl<char *, CodeGenData*> CodeGenMapEl;
-
-#define WO_NOEND 0x01
-#define WO_NOERROR 0x02
-#define WO_NOPREFIX 0x04
-#define WO_NOFF 0x08
-
-struct CodeGenData
-{
- CodeGenData( char *fileName, char *fsmName, bool wantComplete )
- :
- fileName(fileName),
- fsmName(fsmName),
- redFsm(0),
- allActions(0),
- allActionTables(0),
- allConditions(0),
- allCondSpaces(0),
- allStates(0),
- nameIndex(0),
- startState(0),
- getKeyExpr(0),
- accessExpr(0),
- curStateExpr(0),
- codeGen(0),
- wantComplete(wantComplete),
- writeOps(0),
- writeData(false),
- writeInit(false),
- writeExec(false),
- writeEOF(false),
- hasLongestMatch(false),
- hasEnd(true),
- dataPrefix(true),
- writeFirstFinal(true),
- writeErr(true),
- hasBeenPrepared(false)
- { }
-
- /*
- * Collecting the machine.
- */
-
- char *fileName;
- char *fsmName;
- RedFsmAp *redFsm;
- Action *allActions;
- RedAction *allActionTables;
- Condition *allConditions;
- CondSpace *allCondSpaces;
- RedStateAp *allStates;
- NameInst **nameIndex;
- int startState;
- ActionList actionList;
- ConditionList conditionList;
- CondSpaceList condSpaceList;
- InlineList *getKeyExpr;
- InlineList *accessExpr;
- InlineList *curStateExpr;
- FsmCodeGen *codeGen;
- KeyOps thisKeyOps;
- bool wantComplete;
- int writeOps;
- bool writeData;
- bool writeInit;
- bool writeExec;
- bool writeEOF;
- EntryIdVect entryPointIds;
- EntryNameVect entryPointNames;
- bool hasLongestMatch;
-
- /* Write options. */
- bool hasEnd;
- bool dataPrefix;
- bool writeFirstFinal;
- bool writeErr;
-
- void createMachine();
- void initActionList( unsigned long length );
- void newAction( int anum, char *name, int line, int col, InlineList *inlineList );
- void initActionTableList( unsigned long length );
- void initStateList( unsigned long length );
- void setStartState( unsigned long startState );
- void addEntryPoint( char *name, unsigned long entryState );
- void setFinal( int snum );
- void initTransList( int snum, unsigned long length );
- void newTrans( int snum, int tnum, Key lowKey, Key highKey,
- long targ, long act );
- void finishTransList( int snum );
- void setStateActions( int snum, long toStateAction,
- long fromStateAction, long eofAction );
- void finishMachine();
- void setForcedErrorState()
- { redFsm->forcedErrorState = true; }
-
- void initCondSpaceList( ulong length );
- void condSpaceItem( int cnum, long condActionId );
- void newCondSpace( int cnum, int condSpaceId, Key baseKey );
-
- void initStateCondList( int snum, ulong length );
- void addStateCond( int snum, Key lowKey, Key highKey, long condNum );
-
- CondSpace *findCondSpace( Key lowKey, Key highKey );
- Condition *findCondition( Key key );
-
- bool setAlphType( char *data );
-
- void makeCodeGen();
- void generateGraphviz();
- void resolveTargetStates( InlineList *inlineList );
- Key findMaxKey();
-
- void generate();
- void generateCode();
- void prepareMachine();
- bool hasBeenPrepared;
-};
-
-extern CodeGenData *cgd;
-
-void lineDirective( ostream &out, char *fileName, int line );
-void genLineDirective( ostream &out );
-
-#endif /* _GENDATA_H */
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- * 2004 Eric Ocean <eric.ocean@ampede.com>
- * 2005 Alan West <alan@alanz.com>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "rlcodegen.h"
-#include "gotocodegen.h"
-#include "redfsm.h"
-#include "bstmap.h"
-#include "gendata.h"
-
-/* Emit the goto to take for a given transition. */
-std::ostream &GotoCodeGen::TRANS_GOTO( RedTransAp *trans, int level )
-{
- out << TABS(level) << "goto tr" << trans->id << ";";
- return out;
-}
-
-std::ostream &GotoCodeGen::TO_STATE_ACTION_SWITCH()
-{
- /* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = cgd->actionList; act.lte(); act++ ) {
- /* Write out referenced actions. */
- if ( act->numToStateRefs > 0 ) {
- /* Write the case label, the action and the case break. */
- out << "\tcase " << act->actionId << ":\n";
- ACTION( out, act, 0, false );
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-std::ostream &GotoCodeGen::FROM_STATE_ACTION_SWITCH()
-{
- /* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = cgd->actionList; act.lte(); act++ ) {
- /* Write out referenced actions. */
- if ( act->numFromStateRefs > 0 ) {
- /* Write the case label, the action and the case break. */
- out << "\tcase " << act->actionId << ":\n";
- ACTION( out, act, 0, false );
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-std::ostream &GotoCodeGen::EOF_ACTION_SWITCH()
-{
- /* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = cgd->actionList; act.lte(); act++ ) {
- /* Write out referenced actions. */
- if ( act->numEofRefs > 0 ) {
- /* Write the case label, the action and the case break. */
- out << "\tcase " << act->actionId << ":\n";
- ACTION( out, act, 0, true );
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-std::ostream &GotoCodeGen::ACTION_SWITCH()
-{
- /* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = cgd->actionList; act.lte(); act++ ) {
- /* Write out referenced actions. */
- if ( act->numTransRefs > 0 ) {
- /* Write the case label, the action and the case break. */
- out << "\tcase " << act->actionId << ":\n";
- ACTION( out, act, 0, false );
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-void GotoCodeGen::GOTO_HEADER( RedStateAp *state )
-{
- /* Label the state. */
- out << "case " << state->id << ":\n";
-}
-
-
-void GotoCodeGen::emitSingleSwitch( RedStateAp *state )
-{
- /* Load up the singles. */
- int numSingles = state->outSingle.length();
- RedTransEl *data = state->outSingle.data;
-
- if ( numSingles == 1 ) {
- /* If there is a single single key then write it out as an if. */
- out << "\tif ( " << GET_WIDE_KEY(state) << " == " <<
- KEY(data[0].lowKey) << " )\n\t\t";
-
- /* Virtual function for writing the target of the transition. */
- TRANS_GOTO(data[0].value, 0) << "\n";
- }
- else if ( numSingles > 1 ) {
- /* Write out single keys in a switch if there is more than one. */
- out << "\tswitch( " << GET_WIDE_KEY(state) << " ) {\n";
-
- /* Write out the single indicies. */
- for ( int j = 0; j < numSingles; j++ ) {
- out << "\t\tcase " << KEY(data[j].lowKey) << ": ";
- TRANS_GOTO(data[j].value, 0) << "\n";
- }
-
- /* Emits a default case for D code. */
- SWITCH_DEFAULT();
-
- /* Close off the transition switch. */
- out << "\t}\n";
- }
-}
-
-void GotoCodeGen::emitRangeBSearch( RedStateAp *state, int level, int low, int high )
-{
- /* Get the mid position, staying on the lower end of the range. */
- int mid = (low + high) >> 1;
- RedTransEl *data = state->outRange.data;
-
- /* Determine if we need to look higher or lower. */
- bool anyLower = mid > low;
- bool anyHigher = mid < high;
-
- /* Determine if the keys at mid are the limits of the alphabet. */
- bool limitLow = data[mid].lowKey == keyOps->minKey;
- bool limitHigh = data[mid].highKey == keyOps->maxKey;
-
- if ( anyLower && anyHigher ) {
- /* Can go lower and higher than mid. */
- out << TABS(level) << "if ( " << GET_WIDE_KEY(state) << " < " <<
- KEY(data[mid].lowKey) << " ) {\n";
- emitRangeBSearch( state, level+1, low, mid-1 );
- out << TABS(level) << "} else if ( " << GET_WIDE_KEY(state) << " > " <<
- KEY(data[mid].highKey) << " ) {\n";
- emitRangeBSearch( state, level+1, mid+1, high );
- out << TABS(level) << "} else\n";
- TRANS_GOTO(data[mid].value, level+1) << "\n";
- }
- else if ( anyLower && !anyHigher ) {
- /* Can go lower than mid but not higher. */
- out << TABS(level) << "if ( " << GET_WIDE_KEY(state) << " < " <<
- KEY(data[mid].lowKey) << " ) {\n";
- emitRangeBSearch( state, level+1, low, mid-1 );
-
- /* if the higher is the highest in the alphabet then there is no
- * sense testing it. */
- if ( limitHigh ) {
- out << TABS(level) << "} else\n";
- TRANS_GOTO(data[mid].value, level+1) << "\n";
- }
- else {
- out << TABS(level) << "} else if ( " << GET_WIDE_KEY(state) << " <= " <<
- KEY(data[mid].highKey) << " )\n";
- TRANS_GOTO(data[mid].value, level+1) << "\n";
- }
- }
- else if ( !anyLower && anyHigher ) {
- /* Can go higher than mid but not lower. */
- out << TABS(level) << "if ( " << GET_WIDE_KEY(state) << " > " <<
- KEY(data[mid].highKey) << " ) {\n";
- emitRangeBSearch( state, level+1, mid+1, high );
-
- /* If the lower end is the lowest in the alphabet then there is no
- * sense testing it. */
- if ( limitLow ) {
- out << TABS(level) << "} else\n";
- TRANS_GOTO(data[mid].value, level+1) << "\n";
- }
- else {
- out << TABS(level) << "} else if ( " << GET_WIDE_KEY(state) << " >= " <<
- KEY(data[mid].lowKey) << " )\n";
- TRANS_GOTO(data[mid].value, level+1) << "\n";
- }
- }
- else {
- /* Cannot go higher or lower than mid. It's mid or bust. What
- * tests to do depends on limits of alphabet. */
- if ( !limitLow && !limitHigh ) {
- out << TABS(level) << "if ( " << KEY(data[mid].lowKey) << " <= " <<
- GET_WIDE_KEY(state) << " && " << GET_WIDE_KEY(state) << " <= " <<
- KEY(data[mid].highKey) << " )\n";
- TRANS_GOTO(data[mid].value, level+1) << "\n";
- }
- else if ( limitLow && !limitHigh ) {
- out << TABS(level) << "if ( " << GET_WIDE_KEY(state) << " <= " <<
- KEY(data[mid].highKey) << " )\n";
- TRANS_GOTO(data[mid].value, level+1) << "\n";
- }
- else if ( !limitLow && limitHigh ) {
- out << TABS(level) << "if ( " << KEY(data[mid].lowKey) << " <= " <<
- GET_WIDE_KEY(state) << " )\n";
- TRANS_GOTO(data[mid].value, level+1) << "\n";
- }
- else {
- /* Both high and low are at the limit. No tests to do. */
- TRANS_GOTO(data[mid].value, level+1) << "\n";
- }
- }
-}
-
-void GotoCodeGen::STATE_GOTO_ERROR()
-{
- /* Label the state and bail immediately. */
- outLabelUsed = true;
- RedStateAp *state = redFsm->errState;
- out << "case " << state->id << ":\n";
- out << " goto _out;\n";
-}
-
-void GotoCodeGen::COND_TRANSLATE( StateCond *stateCond, int level )
-{
- CondSpace *condSpace = stateCond->condSpace;
- out << TABS(level) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" <<
- KEY(condSpace->baseKey) << " + (" << GET_KEY() <<
- " - " << KEY(keyOps->minKey) << "));\n";
-
- for ( CondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
- out << TABS(level) << "if ( ";
- CONDITION( out, *csi );
- Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize());
- out << " ) _widec += " << condValOffset << ";\n";
- }
-}
-
-void GotoCodeGen::emitCondBSearch( RedStateAp *state, int level, int low, int high )
-{
- /* Get the mid position, staying on the lower end of the range. */
- int mid = (low + high) >> 1;
- StateCond **data = state->stateCondVect.data;
-
- /* Determine if we need to look higher or lower. */
- bool anyLower = mid > low;
- bool anyHigher = mid < high;
-
- /* Determine if the keys at mid are the limits of the alphabet. */
- bool limitLow = data[mid]->lowKey == keyOps->minKey;
- bool limitHigh = data[mid]->highKey == keyOps->maxKey;
-
- if ( anyLower && anyHigher ) {
- /* Can go lower and higher than mid. */
- out << TABS(level) << "if ( " << GET_KEY() << " < " <<
- KEY(data[mid]->lowKey) << " ) {\n";
- emitCondBSearch( state, level+1, low, mid-1 );
- out << TABS(level) << "} else if ( " << GET_KEY() << " > " <<
- KEY(data[mid]->highKey) << " ) {\n";
- emitCondBSearch( state, level+1, mid+1, high );
- out << TABS(level) << "} else {\n";
- COND_TRANSLATE(data[mid], level+1);
- out << TABS(level) << "}\n";
- }
- else if ( anyLower && !anyHigher ) {
- /* Can go lower than mid but not higher. */
- out << TABS(level) << "if ( " << GET_KEY() << " < " <<
- KEY(data[mid]->lowKey) << " ) {\n";
- emitCondBSearch( state, level+1, low, mid-1 );
-
- /* if the higher is the highest in the alphabet then there is no
- * sense testing it. */
- if ( limitHigh ) {
- out << TABS(level) << "} else {\n";
- COND_TRANSLATE(data[mid], level+1);
- out << TABS(level) << "}\n";
- }
- else {
- out << TABS(level) << "} else if ( " << GET_KEY() << " <= " <<
- KEY(data[mid]->highKey) << " ) {\n";
- COND_TRANSLATE(data[mid], level+1);
- out << TABS(level) << "}\n";
- }
- }
- else if ( !anyLower && anyHigher ) {
- /* Can go higher than mid but not lower. */
- out << TABS(level) << "if ( " << GET_KEY() << " > " <<
- KEY(data[mid]->highKey) << " ) {\n";
- emitCondBSearch( state, level+1, mid+1, high );
-
- /* If the lower end is the lowest in the alphabet then there is no
- * sense testing it. */
- if ( limitLow ) {
- out << TABS(level) << "} else {\n";
- COND_TRANSLATE(data[mid], level+1);
- out << TABS(level) << "}\n";
- }
- else {
- out << TABS(level) << "} else if ( " << GET_KEY() << " >= " <<
- KEY(data[mid]->lowKey) << " ) {\n";
- COND_TRANSLATE(data[mid], level+1);
- out << TABS(level) << "}\n";
- }
- }
- else {
- /* Cannot go higher or lower than mid. It's mid or bust. What
- * tests to do depends on limits of alphabet. */
- if ( !limitLow && !limitHigh ) {
- out << TABS(level) << "if ( " << KEY(data[mid]->lowKey) << " <= " <<
- GET_KEY() << " && " << GET_KEY() << " <= " <<
- KEY(data[mid]->highKey) << " ) {\n";
- COND_TRANSLATE(data[mid], level+1);
- out << TABS(level) << "}\n";
- }
- else if ( limitLow && !limitHigh ) {
- out << TABS(level) << "if ( " << GET_KEY() << " <= " <<
- KEY(data[mid]->highKey) << " ) {\n";
- COND_TRANSLATE(data[mid], level+1);
- out << TABS(level) << "}\n";
- }
- else if ( !limitLow && limitHigh ) {
- out << TABS(level) << "if ( " << KEY(data[mid]->lowKey) << " <= " <<
- GET_KEY() << " )\n {";
- COND_TRANSLATE(data[mid], level+1);
- out << TABS(level) << "}\n";
- }
- else {
- /* Both high and low are at the limit. No tests to do. */
- COND_TRANSLATE(data[mid], level);
- }
- }
-}
-
-std::ostream &GotoCodeGen::STATE_GOTOS()
-{
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- if ( st == redFsm->errState )
- STATE_GOTO_ERROR();
- else {
- /* Writing code above state gotos. */
- GOTO_HEADER( st );
-
- if ( st->stateCondVect.length() > 0 ) {
- out << " _widec = " << GET_KEY() << ";\n";
- emitCondBSearch( st, 1, 0, st->stateCondVect.length() - 1 );
- }
-
- /* Try singles. */
- if ( st->outSingle.length() > 0 )
- emitSingleSwitch( st );
-
- /* Default case is to binary search for the ranges, if that fails then */
- if ( st->outRange.length() > 0 )
- emitRangeBSearch( st, 1, 0, st->outRange.length() - 1 );
-
- /* Write the default transition. */
- TRANS_GOTO( st->defTrans, 1 ) << "\n";
- }
- }
- return out;
-}
-
-std::ostream &GotoCodeGen::TRANSITIONS()
-{
- /* Emit any transitions that have functions and that go to
- * this state. */
- for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) {
- /* Write the label for the transition so it can be jumped to. */
- out << " tr" << trans->id << ": ";
-
- /* Destination state. */
- if ( trans->action != 0 && trans->action->anyCurStateRef() )
- out << "_ps = " << CS() << ";";
- out << CS() << " = " << trans->targ->id << "; ";
-
- if ( trans->action != 0 ) {
- /* Write out the transition func. */
- out << "goto f" << trans->action->actListId << ";\n";
- }
- else {
- /* No code to execute, just loop around. */
- out << "goto _again;\n";
- }
- }
- return out;
-}
-
-std::ostream &GotoCodeGen::EXEC_FUNCS()
-{
- /* Make labels that set acts and jump to execFuncs. Loop func indicies. */
- for ( ActionTableMap::Iter redAct = redFsm->actionMap; redAct.lte(); redAct++ ) {
- if ( redAct->numTransRefs > 0 ) {
- out << " f" << redAct->actListId << ": " <<
- "_acts = " << ARR_OFF(A(), itoa( redAct->location+1 ) ) << ";"
- " goto execFuncs;\n";
- }
- }
-
- out <<
- "\n"
- "execFuncs:\n"
- " _nacts = *_acts++;\n"
- " while ( _nacts-- > 0 ) {\n"
- " switch ( *_acts++ ) {\n";
- ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- " goto _again;\n";
- return out;
-}
-
-unsigned int GotoCodeGen::TO_STATE_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->toStateAction != 0 )
- act = state->toStateAction->location+1;
- return act;
-}
-
-unsigned int GotoCodeGen::FROM_STATE_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->fromStateAction != 0 )
- act = state->fromStateAction->location+1;
- return act;
-}
-
-unsigned int GotoCodeGen::EOF_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->eofAction != 0 )
- act = state->eofAction->location+1;
- return act;
-}
-
-std::ostream &GotoCodeGen::TO_STATE_ACTIONS()
-{
- /* Take one off for the psuedo start state. */
- int numStates = redFsm->stateList.length();
- unsigned int *vals = new unsigned int[numStates];
- memset( vals, 0, sizeof(unsigned int)*numStates );
-
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ )
- vals[st->id] = TO_STATE_ACTION(st);
-
- out << "\t";
- for ( int st = 0; st < redFsm->nextStateId; st++ ) {
- /* Write any eof action. */
- out << vals[st];
- if ( st < numStates-1 ) {
- out << ", ";
- if ( (st+1) % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- delete[] vals;
- return out;
-}
-
-std::ostream &GotoCodeGen::FROM_STATE_ACTIONS()
-{
- /* Take one off for the psuedo start state. */
- int numStates = redFsm->stateList.length();
- unsigned int *vals = new unsigned int[numStates];
- memset( vals, 0, sizeof(unsigned int)*numStates );
-
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ )
- vals[st->id] = FROM_STATE_ACTION(st);
-
- out << "\t";
- for ( int st = 0; st < redFsm->nextStateId; st++ ) {
- /* Write any eof action. */
- out << vals[st];
- if ( st < numStates-1 ) {
- out << ", ";
- if ( (st+1) % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- delete[] vals;
- return out;
-}
-
-std::ostream &GotoCodeGen::EOF_ACTIONS()
-{
- /* Take one off for the psuedo start state. */
- int numStates = redFsm->stateList.length();
- unsigned int *vals = new unsigned int[numStates];
- memset( vals, 0, sizeof(unsigned int)*numStates );
-
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ )
- vals[st->id] = EOF_ACTION(st);
-
- out << "\t";
- for ( int st = 0; st < redFsm->nextStateId; st++ ) {
- /* Write any eof action. */
- out << vals[st];
- if ( st < numStates-1 ) {
- out << ", ";
- if ( (st+1) % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- delete[] vals;
- return out;
-}
-
-std::ostream &GotoCodeGen::FINISH_CASES()
-{
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* States that are final and have an out action need a case. */
- if ( st->eofAction != 0 ) {
- /* Write the case label. */
- out << "\t\tcase " << st->id << ": ";
-
- /* Write the goto func. */
- out << "goto f" << st->eofAction->actListId << ";\n";
- }
- }
-
- return out;
-}
-
-void GotoCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish )
-{
- ret << "{" << CS() << " = " << gotoDest << "; " <<
- CTRL_FLOW() << "goto _again;}";
-}
-
-void GotoCodeGen::GOTO_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish )
-{
- ret << "{" << CS() << " = (";
- INLINE_LIST( ret, ilItem->children, 0, inFinish );
- ret << "); " << CTRL_FLOW() << "goto _again;}";
-}
-
-void GotoCodeGen::CURS( ostream &ret, bool inFinish )
-{
- ret << "(_ps)";
-}
-
-void GotoCodeGen::TARGS( ostream &ret, bool inFinish, int targState )
-{
- ret << "(" << CS() << ")";
-}
-
-void GotoCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish )
-{
- ret << CS() << " = " << nextDest << ";";
-}
-
-void GotoCodeGen::NEXT_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish )
-{
- ret << CS() << " = (";
- INLINE_LIST( ret, ilItem->children, 0, inFinish );
- ret << ");";
-}
-
-void GotoCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish )
-{
- ret << "{" << STACK() << "[" << TOP() << "++] = " << CS() << "; " << CS() << " = " <<
- callDest << "; " << CTRL_FLOW() << "goto _again;}";
-}
-
-void GotoCodeGen::CALL_EXPR( ostream &ret, InlineItem *ilItem, int targState, bool inFinish )
-{
- ret << "{" << STACK() << "[" << TOP() << "++] = " << CS() << "; " << CS() << " = (";
- INLINE_LIST( ret, ilItem->children, targState, inFinish );
- ret << "); " << CTRL_FLOW() << "goto _again;}";
-}
-
-void GotoCodeGen::RET( ostream &ret, bool inFinish )
-{
- ret << "{" << CS() << " = " << STACK() << "[--" << TOP() << "]; " <<
- CTRL_FLOW() << "goto _again;}";
-}
-
-void GotoCodeGen::BREAK( ostream &ret, int targState )
-{
- outLabelUsed = true;
- ret << CTRL_FLOW() << "goto _out;";
-}
-
-void GotoCodeGen::writeOutData()
-{
- out <<
- "static const int " << START() << " = " << START_STATE_ID() << ";\n"
- "\n";
-
- if ( cgd->writeFirstFinal ) {
- out <<
- "static const int " << FIRST_FINAL() << " = " << FIRST_FINAL_STATE() << ";\n"
- "\n";
- }
-
- if ( cgd->writeErr ) {
- out <<
- "static const int " << ERROR() << " = " << ERROR_STATE() << ";\n"
- "\n";
- }
-
- if ( anyActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActArrItem), A() );
- ACTIONS_ARRAY();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- if ( anyToStateActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), TSA() );
- TO_STATE_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- if ( anyFromStateActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), FSA() );
- FROM_STATE_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- if ( anyEofActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), EA() );
- EOF_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-}
-
-void GotoCodeGen::writeOutExec()
-{
- outLabelUsed = false;
-
- out << " {\n";
-
- if ( anyRegCurStateRef() )
- out << " int _ps = 0;\n";
-
- if ( anyToStateActions() || anyRegActions() || anyFromStateActions() ) {
- out <<
- " " << PTR_CONST() << ARRAY_TYPE(maxActArrItem) << POINTER() << "_acts;\n"
- " " << UINT() << " _nacts;\n";
- }
-
- if ( anyConditions() )
- out << " " << WIDE_ALPH_TYPE() << " _widec;\n";
-
- out << "\n";
-
- if ( cgd->hasEnd ) {
- outLabelUsed = true;
- out <<
- " if ( " << P() << " == " << PE() << " )\n"
- " goto _out;\n";
- }
-
- out << "_resume:\n";
-
- if ( anyFromStateActions() ) {
- out <<
- " _acts = " << ARR_OFF( A(), FSA() + "[" + CS() + "]" ) << ";\n"
- " _nacts = " << CAST(UINT()) << " *_acts++;\n"
- " while ( _nacts-- > 0 ) {\n"
- " switch ( *_acts++ ) {\n";
- FROM_STATE_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- "\n";
- }
-
- out <<
- " switch ( " << CS() << " ) {\n";
- STATE_GOTOS();
- SWITCH_DEFAULT() <<
- " }\n"
- "\n";
- TRANSITIONS() <<
- "\n";
-
- if ( anyRegActions() )
- EXEC_FUNCS() << "\n";
-
- out << "_again:\n";
-
- if ( anyToStateActions() ) {
- out <<
- " _acts = " << ARR_OFF( A(), TSA() + "[" + CS() + "]" ) << ";\n"
- " _nacts = " << CAST(UINT()) << " *_acts++;\n"
- " while ( _nacts-- > 0 ) {\n"
- " switch ( *_acts++ ) {\n";
- TO_STATE_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- "\n";
- }
-
- if ( cgd->hasEnd ) {
- out <<
- " if ( ++" << P() << " != " << PE() << " )\n"
- " goto _resume;\n";
- }
- else {
- out <<
- " " << P() << " += 1;\n"
- " goto _resume;\n";
- }
-
- if ( outLabelUsed )
- out << " _out: {}\n";
-
- out << " }\n";
-}
-
-void GotoCodeGen::writeOutEOF()
-{
- if ( anyEofActions() ) {
- out <<
- " {\n"
- " " << PTR_CONST() << ARRAY_TYPE(maxActArrItem) << POINTER() << "_acts = " <<
- ARR_OFF( A(), EA() + "[" + CS() + "]" ) << ";\n"
- " " << UINT() << " _nacts = " << CAST(UINT()) << " *_acts++;\n"
- " while ( _nacts-- > 0 ) {\n"
- " switch ( *_acts++ ) {\n";
- EOF_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- " }\n"
- "\n";
- }
-}
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- * 2004 Eric Ocean <eric.ocean@ampede.com>
- * 2005 Alan West <alan@alanz.com>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _GOTOCODEGEN_H
-#define _GOTOCODEGEN_H
-
-#include <iostream>
-#include "fsmcodegen.h"
-
-/* Forwards. */
-struct CodeGenData;
-struct NameInst;
-struct RedTransAp;
-struct RedStateAp;
-struct StateCond;
-
-/*
- * Goto driven fsm.
- */
-class GotoCodeGen : virtual public FsmCodeGen
-{
-public:
- std::ostream &TO_STATE_ACTION_SWITCH();
- std::ostream &FROM_STATE_ACTION_SWITCH();
- std::ostream &EOF_ACTION_SWITCH();
- std::ostream &ACTION_SWITCH();
- std::ostream &STATE_GOTOS();
- std::ostream &TRANSITIONS();
- std::ostream &EXEC_FUNCS();
- std::ostream &FINISH_CASES();
-
- void GOTO( ostream &ret, int gotoDest, bool inFinish );
- void CALL( ostream &ret, int callDest, int targState, bool inFinish );
- void NEXT( ostream &ret, int nextDest, bool inFinish );
- void GOTO_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish );
- void NEXT_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish );
- void CALL_EXPR( ostream &ret, InlineItem *ilItem, int targState, bool inFinish );
- void CURS( ostream &ret, bool inFinish );
- void TARGS( ostream &ret, bool inFinish, int targState );
- void RET( ostream &ret, bool inFinish );
- void BREAK( ostream &ret, int targState );
-
- virtual unsigned int TO_STATE_ACTION( RedStateAp *state );
- virtual unsigned int FROM_STATE_ACTION( RedStateAp *state );
- virtual unsigned int EOF_ACTION( RedStateAp *state );
-
- std::ostream &TO_STATE_ACTIONS();
- std::ostream &FROM_STATE_ACTIONS();
- std::ostream &EOF_ACTIONS();
-
- void COND_TRANSLATE( StateCond *stateCond, int level );
- void emitCondBSearch( RedStateAp *state, int level, int low, int high );
- void STATE_CONDS( RedStateAp *state, bool genDefault );
-
- virtual std::ostream &TRANS_GOTO( RedTransAp *trans, int level );
-
- void emitSingleSwitch( RedStateAp *state );
- void emitRangeBSearch( RedStateAp *state, int level, int low, int high );
-
- /* Called from STATE_GOTOS just before writing the gotos */
- virtual void GOTO_HEADER( RedStateAp *state );
- virtual void STATE_GOTO_ERROR();
-
- virtual void writeOutData();
- virtual void writeOutEOF();
- virtual void writeOutExec();
-};
-
-/*
- * class CGotoCodeGen
- */
-struct CGotoCodeGen
- : public GotoCodeGen, public CCodeGen
-{
-};
-
-/*
- * class DGotoCodeGen
- */
-struct DGotoCodeGen
- : public GotoCodeGen, public DCodeGen
-{
-};
-
-
-#endif /* _GOTOCODEGEN_H */
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-
-#include "rlcodegen.h"
-#include "gvdotgen.h"
-#include "gendata.h"
-#include "redfsm.h"
-
-using namespace std;
-
-GraphvizDotGen::GraphvizDotGen( char *fsmName, CodeGenData *cgd,
- RedFsmAp *redFsm, ostream &out )
-:
- fsmName(fsmName),
- cgd(cgd),
- redFsm(redFsm),
- out(out)
-{
-}
-
-std::ostream &GraphvizDotGen::KEY( Key key )
-{
- if ( printPrintables && key.isPrintable() ) {
- // Output values as characters, ensuring we escape the quote (") character
- char cVal = (char) key.getVal();
- out << "'";
- switch ( cVal ) {
- case '"': case '\\':
- out << "\\" << cVal;
- break;
- default:
- out << cVal;
- break;
- }
- out << "'";
- }
- else {
- if ( keyOps->isSigned )
- out << key.getVal();
- else
- out << (unsigned long) key.getVal();
- }
-
- return out;
-}
-
-std::ostream &GraphvizDotGen::TRANS_ACTION( RedStateAp *fromState, RedTransAp *trans )
-{
- int n = 0;
- RedAction *actions[3];
-
- if ( fromState->fromStateAction != 0 )
- actions[n++] = fromState->fromStateAction;
- if ( trans->action != 0 )
- actions[n++] = trans->action;
- if ( trans->targ != 0 && trans->targ->toStateAction != 0 )
- actions[n++] = trans->targ->toStateAction;
-
- if ( n > 0 )
- out << " / ";
-
- /* Loop the existing actions and write out what's there. */
- for ( int a = 0; a < n; a++ ) {
- for ( ActionTable::Iter actIt = actions[a]->key.first(); actIt.lte(); actIt++ ) {
- Action *action = actIt->value;
- out << action->nameOrLoc();
- if ( a < n-1 || !actIt.last() )
- out << ", ";
- }
- }
- return out;
-}
-
-std::ostream &GraphvizDotGen::ACTION( RedAction *action )
-{
- /* The action. */
- out << " / ";
- for ( ActionTable::Iter actIt = action->key.first(); actIt.lte(); actIt++ ) {
- Action *action = actIt->value;
- if ( action->name != 0 )
- out << action->name;
- else
- out << action->loc.line << ":" << action->loc.col;
- if ( !actIt.last() )
- out << ", ";
- }
- return out;
-}
-
-std::ostream &GraphvizDotGen::ONCHAR( Key lowKey, Key highKey )
-{
- if ( lowKey > keyOps->maxKey ) {
- CondSpace *condSpace = cgd->findCondSpace( lowKey, highKey );
- Key values = ( lowKey - condSpace->baseKey ) / keyOps->alphSize();
-
- lowKey = keyOps->minKey +
- (lowKey - condSpace->baseKey - keyOps->alphSize() * values.getVal());
- highKey = keyOps->minKey +
- (highKey - condSpace->baseKey - keyOps->alphSize() * values.getVal());
- KEY( lowKey );
- if ( lowKey != highKey ) {
- out << "..";
- KEY( highKey );
- }
- out << "(";
-
- for ( CondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
- bool set = values & (1 << csi.pos());
- if ( !set )
- out << "!";
- out << (*csi)->nameOrLoc();
- if ( !csi.last() )
- out << ", ";
- }
- out << ")";
- }
- else {
- /* Output the key. Possibly a range. */
- KEY( lowKey );
- if ( highKey != lowKey ) {
- out << "..";
- KEY( highKey );
- }
- }
- return out;
-}
-
-void GraphvizDotGen::writeTransList( RedStateAp *state )
-{
- /* Build the set of unique transitions out of this state. */
- RedTransSet stTransSet;
- for ( RedTransList::Iter tel = state->outRange; tel.lte(); tel++ ) {
- /* If we haven't seen the transitions before, the move forward
- * emitting all the transitions on the same character. */
- if ( stTransSet.insert( tel->value ) ) {
- /* Write out the from and to states. */
- out << "\t" << state->id << " -> ";
-
- if ( tel->value->targ == 0 )
- out << "err_" << state->id;
- else
- out << tel->value->targ->id;
-
- /* Begin the label. */
- out << " [ label = \"";
- ONCHAR( tel->lowKey, tel->highKey );
-
- /* Walk the transition list, finding the same. */
- for ( RedTransList::Iter mtel = tel.next(); mtel.lte(); mtel++ ) {
- if ( mtel->value == tel->value ) {
- out << ", ";
- ONCHAR( mtel->lowKey, mtel->highKey );
- }
- }
-
- /* Write the action and close the transition. */
- TRANS_ACTION( state, tel->value );
- out << "\" ];\n";
- }
- }
-
- /* Write the default transition. */
- if ( state->defTrans != 0 ) {
- /* Write out the from and to states. */
- out << "\t" << state->id << " -> ";
-
- if ( state->defTrans->targ == 0 )
- out << "err_" << state->id;
- else
- out << state->defTrans->targ->id;
-
- /* Begin the label. */
- out << " [ label = \"DEF";
-
- /* Write the action and close the transition. */
- TRANS_ACTION( state, state->defTrans );
- out << "\" ];\n";
- }
-}
-
-void GraphvizDotGen::writeDotFile( )
-{
- out <<
- "digraph " << fsmName << " {\n"
- " rankdir=LR;\n";
-
- /* Define the psuedo states. Transitions will be done after the states
- * have been defined as either final or not final. */
- out << " node [ shape = point ];\n";
- out << " ENTRY;\n";
-
- /* Psuedo states for entry points in the entry map. */
- for ( EntryIdVect::Iter en = cgd->entryPointIds; en.lte(); en++ ) {
- RedStateAp *state = cgd->allStates + *en;
- out << " en_" << state->id << ";\n";
- }
-
- /* Psuedo states for final states with eof actions. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- if ( st->eofAction != 0 )
- out << " eof_" << st->id << ";\n";
- }
-
- out << " node [ shape = circle, height = 0.2 ];\n";
-
- /* Psuedo states for states whose default actions go to error. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- bool needsErr = false;
- if ( st->defTrans != 0 && st->defTrans->targ == 0 )
- needsErr = true;
- else {
- for ( RedTransList::Iter tel = st->outRange; tel.lte(); tel++ ) {
- if ( tel->value->targ == 0 ) {
- needsErr = true;
- break;
- }
- }
- }
-
- if ( needsErr )
- out << " err_" << st->id << " [ label=\"\"];\n";
- }
-
- /* Attributes common to all nodes, plus double circle for final states. */
- out << " node [ fixedsize = true, height = 0.65, shape = doublecircle ];\n";
-
- /* List Final states. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- if ( st->isFinal )
- out << " " << st->id << ";\n";
- }
-
- /* List transitions. */
- out << " node [ shape = circle ];\n";
-
- /* Walk the states. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ )
- writeTransList( st );
-
- /* Transitions into the start state. */
- out << " ENTRY -> " << redFsm->startState->id << " [ label = \"IN";
- out << "\" ];\n";
-
- /* Transitions into the entry points. */
- for ( EntryIdVect::Iter en = cgd->entryPointIds; en.lte(); en++ ) {
- RedStateAp *state = cgd->allStates + *en;
- char *name = cgd->entryPointNames[en.pos()];
- out << " en_" << state->id << " -> " << state->id <<
- " [ label = \"" << name << "\" ];\n";
- }
-
- /* Out action transitions. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- if ( st->eofAction != 0 ) {
- out << " " << st->id << " -> eof_" <<
- st->id << " [ label = \"EOF";
- ACTION( st->eofAction ) << "\" ];\n";
- }
- }
-
- out <<
- "}\n";
-}
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _GVDOTGEN_H
-#define _GVDOTGEN_H
-
-#include <iostream>
-#include "redfsm.h"
-
-/* Forwards. */
-struct CodeGenData;
-
-class GraphvizDotGen
-{
-public:
- GraphvizDotGen( char *fsmName, CodeGenData *cgd,
- RedFsmAp *redFsm, std::ostream &out );
-
- /* Print an fsm to out stream. */
- void writeTransList( RedStateAp *state );
- void writeDotFile( );
-
-private:
- /* Writing labels and actions. */
- std::ostream &ONCHAR( Key lowKey, Key highKey );
- std::ostream &TRANS_ACTION( RedStateAp *fromState, RedTransAp *trans );
- std::ostream &ACTION( RedAction *action );
- std::ostream &KEY( Key key );
-
- char *fsmName;
- CodeGenData *cgd;
- RedFsmAp *redFsm;
- std::ostream &out;
-};
-
-
-#endif /* _GVDOTGEN_H */
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- * 2004 Eric Ocean <eric.ocean@ampede.com>
- * 2005 Alan West <alan@alanz.com>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "rlcodegen.h"
-#include "ipgotocodegen.h"
-#include "redfsm.h"
-#include "gendata.h"
-#include "bstmap.h"
-
-void IpGotoCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish )
-{
- ret << "{" << CTRL_FLOW() << "goto st" << gotoDest << ";}";
-}
-
-void IpGotoCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish )
-{
- ret << "{" << STACK() << "[" << TOP() << "++] = " << targState <<
- "; " << CTRL_FLOW() << "goto st" << callDest << ";}";
-}
-
-void IpGotoCodeGen::RET( ostream &ret, bool inFinish )
-{
- ret << "{" << CS() << " = " << STACK() << "[--" << TOP() << "]; " <<
- CTRL_FLOW() << "goto _again;}";
-}
-
-void IpGotoCodeGen::GOTO_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish )
-{
- ret << "{" << CS() << " = (";
- INLINE_LIST( ret, ilItem->children, 0, inFinish );
- ret << "); " << CTRL_FLOW() << "goto _again;}";
-}
-
-void IpGotoCodeGen::CALL_EXPR( ostream &ret, InlineItem *ilItem, int targState, bool inFinish )
-{
- ret << "{" << STACK() << "[" << TOP() << "++] = " << targState << "; " << CS() << " = (";
- INLINE_LIST( ret, ilItem->children, 0, inFinish );
- ret << "); " << CTRL_FLOW() << "goto _again;}";
-}
-
-void IpGotoCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish )
-{
- ret << CS() << " = " << nextDest << ";";
-}
-
-void IpGotoCodeGen::NEXT_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish )
-{
- ret << CS() << " = (";
- INLINE_LIST( ret, ilItem->children, 0, inFinish );
- ret << ");";
-}
-
-void IpGotoCodeGen::CURS( ostream &ret, bool inFinish )
-{
- ret << "(_ps)";
-}
-
-void IpGotoCodeGen::TARGS( ostream &ret, bool inFinish, int targState )
-{
- ret << targState;
-}
-
-void IpGotoCodeGen::BREAK( ostream &ret, int targState )
-{
- ret << CTRL_FLOW() << "goto _out" << targState << ";";
-}
-
-bool IpGotoCodeGen::IN_TRANS_ACTIONS( RedStateAp *state )
-{
- bool anyWritten = false;
-
- /* Emit any transitions that have actions and that go to this state. */
- for ( int it = 0; it < state->numInTrans; it++ ) {
- RedTransAp *trans = state->inTrans[it];
- if ( trans->action != 0 && trans->labelNeeded ) {
- /* Remember that we wrote an action so we know to write the
- * line directive for going back to the output. */
- anyWritten = true;
-
- /* Write the label for the transition so it can be jumped to. */
- out << "tr" << trans->id << ":\n";
-
- /* If the action contains a next, then we must preload the current
- * state since the action may or may not set it. */
- if ( trans->action->anyNextStmt() )
- out << " " << CS() << " = " << trans->targ->id << ";\n";
-
- /* Write each action in the list. */
- for ( ActionTable::Iter item = trans->action->key; item.lte(); item++ )
- ACTION( out, item->value, trans->targ->id, false );
-
- /* If the action contains a next then we need to reload, otherwise
- * jump directly to the target state. */
- if ( trans->action->anyNextStmt() )
- out << "\tgoto _again;\n";
- else
- out << "\tgoto st" << trans->targ->id << ";\n";
- }
- }
-
- return anyWritten;
-}
-
-/* Called from GotoCodeGen::STATE_GOTOS just before writing the gotos for each
- * state. */
-void IpGotoCodeGen::GOTO_HEADER( RedStateAp *state )
-{
- bool anyWritten = IN_TRANS_ACTIONS( state );
-
- if ( state->labelNeeded )
- out << "st" << state->id << ":\n";
-
- if ( state->toStateAction != 0 ) {
- /* Remember that we wrote an action. Write every action in the list. */
- anyWritten = true;
- for ( ActionTable::Iter item = state->toStateAction->key; item.lte(); item++ )
- ACTION( out, item->value, state->id, false );
- }
-
- /* Advance and test buffer pos. */
- if ( state->labelNeeded ) {
- if ( cgd->hasEnd ) {
- out <<
- " if ( ++" << P() << " == " << PE() << " )\n"
- " goto _out" << state->id << ";\n";
- }
- else {
- out <<
- " " << P() << " += 1;\n";
- }
- }
-
- /* Give the state a switch case. */
- out << "case " << state->id << ":\n";
-
- if ( state->fromStateAction != 0 ) {
- /* Remember that we wrote an action. Write every action in the list. */
- anyWritten = true;
- for ( ActionTable::Iter item = state->fromStateAction->key; item.lte(); item++ )
- ACTION( out, item->value, state->id, false );
- }
-
- if ( anyWritten )
- genLineDirective( out );
-
- /* Record the prev state if necessary. */
- if ( state->anyRegCurStateRef() )
- out << " _ps = " << state->id << ";\n";
-}
-
-void IpGotoCodeGen::STATE_GOTO_ERROR()
-{
- /* In the error state we need to emit some stuff that usually goes into
- * the header. */
- RedStateAp *state = redFsm->errState;
- bool anyWritten = IN_TRANS_ACTIONS( state );
-
- /* No case label needed since we don't switch on the error state. */
- if ( anyWritten )
- genLineDirective( out );
-
- if ( state->labelNeeded )
- out << "st" << state->id << ":\n";
-
- /* Break out here. */
- out << " goto _out" << state->id << ";\n";
-}
-
-
-/* Emit the goto to take for a given transition. */
-std::ostream &IpGotoCodeGen::TRANS_GOTO( RedTransAp *trans, int level )
-{
- if ( trans->action != 0 ) {
- /* Go to the transition which will go to the state. */
- out << TABS(level) << "goto tr" << trans->id << ";";
- }
- else {
- /* Go directly to the target state. */
- out << TABS(level) << "goto st" << trans->targ->id << ";";
- }
- return out;
-}
-
-std::ostream &IpGotoCodeGen::EXIT_STATES()
-{
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- if ( st->outNeeded ) {
- outLabelUsed = true;
- out << " _out" << st->id << ": " << CS() << " = " <<
- st->id << "; goto _out; \n";
- }
- }
- return out;
-}
-
-std::ostream &IpGotoCodeGen::AGAIN_CASES()
-{
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- out <<
- " case " << st->id << ": goto st" << st->id << ";\n";
- }
- return out;
-}
-
-std::ostream &IpGotoCodeGen::FINISH_CASES()
-{
- bool anyWritten = false;
-
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- if ( st->eofAction != 0 ) {
- if ( st->eofAction->eofRefs == 0 )
- st->eofAction->eofRefs = new IntSet;
- st->eofAction->eofRefs->insert( st->id );
- }
- }
-
- for ( ActionTableMap::Iter act = redFsm->actionMap; act.lte(); act++ ) {
- if ( act->eofRefs != 0 ) {
- for ( IntSet::Iter pst = *act->eofRefs; pst.lte(); pst++ )
- out << " case " << *pst << ": \n";
-
- /* Remember that we wrote a trans so we know to write the
- * line directive for going back to the output. */
- anyWritten = true;
-
- /* Write each action in the eof action list. */
- for ( ActionTable::Iter item = act->key; item.lte(); item++ )
- ACTION( out, item->value, STATE_ERR_STATE, true );
- out << "\tbreak;\n";
- }
- }
-
- if ( anyWritten )
- genLineDirective( out );
- return out;
-}
-
-void IpGotoCodeGen::setLabelsNeeded( InlineList *inlineList )
-{
- for ( InlineList::Iter item = *inlineList; item.lte(); item++ ) {
- switch ( item->type ) {
- case InlineItem::Goto: case InlineItem::Call: {
- /* Mark the target as needing a label. */
- item->targState->labelNeeded = true;
- break;
- }
- default: break;
- }
-
- if ( item->children != 0 )
- setLabelsNeeded( item->children );
- }
-}
-
-/* Set up labelNeeded flag for each state. */
-void IpGotoCodeGen::setLabelsNeeded()
-{
- /* If we use the _again label, then we the _again switch, which uses all
- * labels. */
- if ( useAgainLabel() ) {
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ )
- st->labelNeeded = true;
- }
- else {
- /* Do not use all labels by default, init all labelNeeded vars to false. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ )
- st->labelNeeded = false;
-
- if ( redFsm->errState != 0 && anyLmSwitchError() )
- redFsm->errState->labelNeeded = true;
-
- /* Walk all transitions and set only those that have targs. */
- for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) {
- /* If there is no action with a next statement, then the label will be
- * needed. */
- if ( trans->action == 0 || !trans->action->anyNextStmt() )
- trans->targ->labelNeeded = true;
-
- /* Need labels for states that have goto or calls in action code
- * invoked on characters (ie, not from out action code). */
- if ( trans->action != 0 ) {
- /* Loop the actions. */
- for ( ActionTable::Iter act = trans->action->key; act.lte(); act++ ) {
- /* Get the action and walk it's tree. */
- setLabelsNeeded( act->value->inlineList );
- }
- }
- }
- }
-
- if ( cgd->hasEnd ) {
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ )
- st->outNeeded = st->labelNeeded;
- }
- else {
- if ( redFsm->errState != 0 )
- redFsm->errState->outNeeded = true;
-
- for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) {
- /* Any state with a transition in that has a break will need an
- * out label. */
- if ( trans->action != 0 && trans->action->anyBreakStmt() )
- trans->targ->outNeeded = true;
- }
- }
-}
-
-void IpGotoCodeGen::writeOutData()
-{
- out <<
- "static const int " << START() << " = " << START_STATE_ID() << ";\n"
- "\n";
-
- if ( cgd->writeFirstFinal ) {
- out <<
- "static const int " << FIRST_FINAL() << " = " << FIRST_FINAL_STATE() << ";\n"
- "\n";
- }
-
- if ( cgd->writeErr ) {
- out <<
- "static const int " << ERROR() << " = " << ERROR_STATE() << ";\n"
- "\n";
- }
-}
-
-void IpGotoCodeGen::writeOutExec()
-{
- outLabelUsed = false;
-
- out << " {\n";
-
- if ( anyRegCurStateRef() )
- out << " int _ps = 0;\n";
-
- if ( anyConditions() )
- out << " " << WIDE_ALPH_TYPE() << " _widec;\n";
-
- if ( cgd->hasEnd ) {
- outLabelUsed = true;
- out <<
- " if ( " << P() << " == " << PE() << " )\n"
- " goto _out;\n";
- }
-
- if ( useAgainLabel() ) {
- out <<
- " goto _resume;\n"
- "\n"
- "_again:\n"
- " switch ( " << CS() << " ) {\n";
- AGAIN_CASES() <<
- " default: break;\n"
- " }\n"
- "\n";
-
- if ( cgd->hasEnd ) {
- outLabelUsed = true;
- out <<
- " if ( ++" << P() << " == " << PE() << " )\n"
- " goto _out;\n";
- }
- else {
- out <<
- " " << P() << " += 1;\n";
- }
-
- out << "_resume:\n";
- }
-
- out <<
- " switch ( " << CS() << " )\n {\n";
- STATE_GOTOS();
- SWITCH_DEFAULT() <<
- " }\n";
- EXIT_STATES() <<
- "\n";
-
- if ( outLabelUsed )
- out << " _out: {}\n";
-
- out <<
- " }\n";
-}
-
-void IpGotoCodeGen::writeOutEOF()
-{
- if ( anyEofActions() ) {
- out <<
- " {\n"
- " switch ( " << CS() << " ) {\n";
- FINISH_CASES();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- "\n";
- }
-}
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- * 2004 Eric Ocean <eric.ocean@ampede.com>
- * 2005 Alan West <alan@alanz.com>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _IPGCODEGEN_H
-#define _IPGCODEGEN_H
-
-#include <iostream>
-#include "gotocodegen.h"
-
-/* Forwards. */
-struct CodeGenData;
-
-/*
- * class FGotoCodeGen
- */
-class IpGotoCodeGen : public GotoCodeGen
-{
-public:
- std::ostream &EXIT_STATES();
- std::ostream &TRANS_GOTO( RedTransAp *trans, int level );
- std::ostream &FINISH_CASES();
- std::ostream &AGAIN_CASES();
-
- void GOTO( ostream &ret, int gotoDest, bool inFinish );
- void CALL( ostream &ret, int callDest, int targState, bool inFinish );
- void NEXT( ostream &ret, int nextDest, bool inFinish );
- void GOTO_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish );
- void NEXT_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish );
- void CALL_EXPR( ostream &ret, InlineItem *ilItem, int targState, bool inFinish );
- void RET( ostream &ret, bool inFinish );
- void CURS( ostream &ret, bool inFinish );
- void TARGS( ostream &ret, bool inFinish, int targState );
- void BREAK( ostream &ret, int targState );
-
- virtual void writeOutData();
- virtual void writeOutEOF();
- virtual void writeOutExec();
-
-protected:
- bool useAgainLabel()
- { return anyRegActionRets() || anyRegActionByValControl() || anyRegNextStmt(); }
-
- /* Called from GotoCodeGen::STATE_GOTOS just before writing the gotos for
- * each state. */
- bool IN_TRANS_ACTIONS( RedStateAp *state );
- void GOTO_HEADER( RedStateAp *state );
- void STATE_GOTO_ERROR();
-
- /* Set up labelNeeded flag for each state. */
- void setLabelsNeeded( InlineList *inlineList );
- void setLabelsNeeded();
-};
-
-
-/*
- * class CIpGotoCodeGen
- */
-struct CIpGotoCodeGen
- : public IpGotoCodeGen, public CCodeGen
-{
-};
-
-/*
- * class DIpGotoCodeGen
- */
-struct DIpGotoCodeGen
- : public IpGotoCodeGen, public DCodeGen
-{
-};
-
-
-#endif /* _IPGCODEGEN_H */
+++ /dev/null
-/*
- * Copyright 2006 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "javacodegen.h"
-#include "rlcodegen.h"
-#include "tabcodegen.h"
-#include "redfsm.h"
-#include "gendata.h"
-
-void JavaTabCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish )
-{
- ret << "{" << CS() << " = " << gotoDest << "; " <<
- CTRL_FLOW() << "break _again;}";
-}
-
-void JavaTabCodeGen::GOTO_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish )
-{
- ret << "{" << CS() << " = (";
- INLINE_LIST( ret, ilItem->children, 0, inFinish );
- ret << "); " << CTRL_FLOW() << "break _again;}";
-}
-
-void JavaTabCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish )
-{
- ret << "{" << STACK() << "[" << TOP() << "++] = " << CS() << "; " << CS() << " = " <<
- callDest << "; " << CTRL_FLOW() << "break _again;}";
-}
-
-void JavaTabCodeGen::CALL_EXPR( ostream &ret, InlineItem *ilItem, int targState, bool inFinish )
-{
- ret << "{" << STACK() << "[" << TOP() << "++] = " << CS() << "; " << CS() << " = (";
- INLINE_LIST( ret, ilItem->children, targState, inFinish );
- ret << "); " << CTRL_FLOW() << "break _again;}";
-}
-
-void JavaTabCodeGen::RET( ostream &ret, bool inFinish )
-{
- ret << "{" << CS() << " = " << STACK() << "[--" << TOP()
- << "]; " << CTRL_FLOW() << "break _again;}";
-}
-
-void JavaTabCodeGen::BREAK( ostream &ret, int targState )
-{
- ret << CTRL_FLOW() << "break _resume;";
-}
-
-void JavaTabCodeGen::COND_TRANSLATE()
-{
- out <<
- " _widec = " << GET_KEY() << ";\n"
- " _keys = " << CO() << "[" << CS() << "]*2\n;"
- " _klen = " << CL() << "[" << CS() << "];\n"
- " if ( _klen > 0 ) {\n"
- " int _lower = _keys\n;"
- " int _mid;\n"
- " int _upper = _keys + (_klen<<1) - 2;\n"
- " while (true) {\n"
- " if ( _upper < _lower )\n"
- " break;\n"
- "\n"
- " _mid = _lower + (((_upper-_lower) >> 1) & ~1);\n"
- " if ( " << GET_WIDE_KEY() << " < " << CK() << "[_mid] )\n"
- " _upper = _mid - 2;\n"
- " else if ( " << GET_WIDE_KEY() << " > " << CK() << "[_mid] )\n"
- " _lower = _mid + 2;\n"
- " else {\n"
- " switch ( " << C() << "[" << CO() << "[" << CS() << "]"
- " + ((_mid - _keys)>>1)] ) {\n"
- ;
-
- for ( CondSpaceList::Iter csi = cgd->condSpaceList; csi.lte(); csi++ ) {
- CondSpace *condSpace = csi;
- out << " case " << condSpace->condSpaceId << ": {\n";
- out << TABS(2) << "_widec = " << KEY(condSpace->baseKey) <<
- " + (" << GET_KEY() << " - " << KEY(keyOps->minKey) << ");\n";
-
- for ( CondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
- out << TABS(2) << "if ( ";
- CONDITION( out, *csi );
- Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize());
- out << " ) _widec += " << condValOffset << ";\n";
- }
-
- out <<
- " break;\n"
- " }\n";
- }
-
- out <<
- " }\n"
- " break;\n"
- " }\n"
- " }\n"
- " }\n"
- "\n";
-}
-
-
-void JavaTabCodeGen::LOCATE_TRANS()
-{
- out <<
- " _match: do {\n"
- " _keys = " << KO() << "[" << CS() << "]" << ";\n"
- " _trans = " << IO() << "[" << CS() << "];\n"
- " _klen = " << SL() << "[" << CS() << "];\n"
- " if ( _klen > 0 ) {\n"
- " int _lower = _keys;\n"
- " int _mid;\n"
- " int _upper = _keys + _klen - 1;\n"
- " while (true) {\n"
- " if ( _upper < _lower )\n"
- " break;\n"
- "\n"
- " _mid = _lower + ((_upper-_lower) >> 1);\n"
- " if ( " << GET_WIDE_KEY() << " < " << K() << "[_mid] )\n"
- " _upper = _mid - 1;\n"
- " else if ( " << GET_WIDE_KEY() << " > " << K() << "[_mid] )\n"
- " _lower = _mid + 1;\n"
- " else {\n"
- " _trans += (_mid - _keys);\n"
- " break _match;\n"
- " }\n"
- " }\n"
- " _keys += _klen;\n"
- " _trans += _klen;\n"
- " }\n"
- "\n"
- " _klen = " << RL() << "[" << CS() << "];\n"
- " if ( _klen > 0 ) {\n"
- " int _lower = _keys;\n"
- " int _mid;\n"
- " int _upper = _keys + (_klen<<1) - 2;\n"
- " while (true) {\n"
- " if ( _upper < _lower )\n"
- " break;\n"
- "\n"
- " _mid = _lower + (((_upper-_lower) >> 1) & ~1);\n"
- " if ( " << GET_WIDE_KEY() << " < " << K() << "[_mid] )\n"
- " _upper = _mid - 2;\n"
- " else if ( " << GET_WIDE_KEY() << " > " << K() << "[_mid+1] )\n"
- " _lower = _mid + 2;\n"
- " else {\n"
- " _trans += ((_mid - _keys)>>1);\n"
- " break _match;\n"
- " }\n"
- " }\n"
- " _trans += _klen;\n"
- " }\n"
- " } while (false);\n"
- "\n";
-}
-
-void JavaTabCodeGen::writeOutExec()
-{
- out <<
- " {\n"
- " int _klen";
-
- if ( anyRegCurStateRef() )
- out << ", _ps";
-
- out <<
- ";\n"
- " int _trans;\n";
-
- if ( anyConditions() )
- out << " int _widec;\n";
-
- if ( anyToStateActions() || anyRegActions() || anyFromStateActions() ) {
- out <<
- " int _acts;\n"
- " int _nacts;\n";
- }
-
- out <<
- " int _keys;\n"
- "\n";
-
- if ( cgd->hasEnd )
- out << " if ( " << P() << " != " << PE() << " ) {\n";
-
- out << " _resume: while ( true ) {\n";
-
- out << " _again: do {\n";
-
- if ( redFsm->errState != 0 ) {
- out <<
- " if ( " << CS() << " == " << redFsm->errState->id << " )\n"
- " break _resume;\n";
- }
-
- if ( anyFromStateActions() ) {
- out <<
- " _acts = " << FSA() << "[" << CS() << "]" << ";\n"
- " _nacts = " << CAST("int") << " " << A() << "[_acts++];\n"
- " while ( _nacts-- > 0 ) {\n"
- " switch ( " << A() << "[_acts++] ) {\n";
- FROM_STATE_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- "\n";
- }
-
- if ( anyConditions() )
- COND_TRANSLATE();
-
- LOCATE_TRANS();
-
- if ( anyRegCurStateRef() )
- out << " _ps = " << CS() << ";\n";
-
- if ( useIndicies )
- out << " _trans = " << I() << "[_trans];\n";
-
- out <<
- " " << CS() << " = " << TT() << "[_trans];\n"
- "\n";
-
- if ( anyRegActions() ) {
- out <<
- " if ( " << TA() << "[_trans] == 0 )\n"
- " break _again;\n"
- "\n"
- " _acts = " << TA() << "[_trans]" << ";\n"
- " _nacts = " << CAST("int") << " " << A() << "[_acts++];\n"
- " while ( _nacts-- > 0 )\n {\n"
- " switch ( " << A() << "[_acts++] )\n"
- " {\n";
- ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- "\n";
- }
-
- /* Again loop, functions as again label. */
- out << " } while (false);\n";
-
- if ( anyToStateActions() ) {
- out <<
- " _acts = " << TSA() << "[" << CS() << "]" << ";\n"
- " _nacts = " << CAST("int") << " " << A() << "[_acts++];\n"
- " while ( _nacts-- > 0 ) {\n"
- " switch ( " << A() << "[_acts++] ) {\n";
- TO_STATE_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- "\n";
- }
-
- if ( cgd->hasEnd ) {
- out <<
- " if ( ++" << P() << " == " << PE() << " )\n"
- " break _resume;\n";
- }
- else {
- out <<
- " " << P() << " += 1;\n";
- }
-
- /* Close the resume loop. */
- out << " }\n";
-
- /* The if guarding on empty string. */
- if ( cgd->hasEnd )
- out << " }\n";
-
- /* The execute block. */
- out << " }\n";
-}
-
-void JavaTabCodeGen::writeOutEOF()
-{
- if ( anyEofActions() ) {
- out <<
- " int _acts = " << EA() << "[" << CS() << "]" << ";\n"
- " int _nacts = " << CAST("int") << " " << A() << "[_acts++];\n"
- " while ( _nacts-- > 0 ) {\n"
- " switch ( " << A() << "[_acts++] ) {\n";
- EOF_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- "\n";
- }
-}
-
+++ /dev/null
-/*
- * Copyright 2006 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _JAVACODEGEN_H
-#define _JAVACODEGEN_H
-
-#include "tabcodegen.h"
-
-/*
- * JavaTabCodeGen
- */
-struct JavaTabCodeGen
- : public TabCodeGen, public JavaCodeGen
-{
- void BREAK( ostream &ret, int targState );
- void GOTO( ostream &ret, int gotoDest, bool inFinish );
- void GOTO_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish );
- void CALL( ostream &ret, int callDest, int targState, bool inFinish );
- void CALL_EXPR( ostream &ret, InlineItem *ilItem, int targState, bool inFinish );
- void RET( ostream &ret, bool inFinish );
-
- void COND_TRANSLATE();
- void LOCATE_TRANS();
- virtual void writeOutExec();
- virtual void writeOutEOF();
-};
-
-
-#endif
+++ /dev/null
-/*
- * Copyright 2001-2005 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <iostream>
-#include <fstream>
-#include <unistd.h>
-
-#include "rlcodegen.h"
-#include "rlcodegen.h"
-#include "xmlparse.h"
-#include "pcheck.h"
-#include "vector.h"
-#include "version.h"
-
-#include "common.cpp"
-
-using std::istream;
-using std::ifstream;
-using std::ostream;
-using std::ios;
-using std::cin;
-using std::cout;
-using std::cerr;
-using std::endl;
-
-/* Target language and output style. */
-OutputFormat outputFormat = OutCode;
-CodeStyleEnum codeStyle = GenTables;
-
-/* Io globals. */
-istream *inStream = 0;
-ostream *outStream = 0;
-output_filter *outFilter = 0;
-char *outputFileName = 0;
-
-/* Graphviz dot file generation. */
-bool graphvizDone = false;
-
-char *gblFileName = "<unknown>";
-
-int numSplitPartitions = 0;
-
-bool printPrintables = false;
-
-/* Print a summary of the options. */
-void usage()
-{
- cout <<
-"usage: rlcodegen [options] file\n"
-"general:\n"
-" -h, -H, -?, --help Print this usage and exit\n"
-" -v, --version Print version information and exit\n"
-" -o <file> Write output to <file>\n"
-"output:\n"
-" -V Generate a Graphviz dotfile instead of code\n"
-" -p Print printable characters in Graphviz output\n"
-"generated code style:\n"
-" -T0 Table driven FSM (default)\n"
-" -T1 Faster table driven FSM\n"
-" -F0 Flat table driven FSM\n"
-" -F1 Faster flat table-driven FSM\n"
-" -G0 Goto-driven FSM\n"
-" -G1 Faster goto-driven FSM\n"
-" -G2 Really fast goto-driven FSM\n"
-" -P<N> N-Way Split really fast goto-driven FSM\n"
- ;
-}
-
-/* Print version information. */
-void version()
-{
- cout << "Ragel Code Generator version " VERSION << " " PUBDATE << endl <<
- "Copyright (c) 2001-2006 by Adrian Thurston" << endl;
-}
-
-/* Scans a string looking for the file extension. If there is a file
- * extension then pointer returned points to inside the string
- * passed in. Otherwise returns null. */
-char *findFileExtension( char *stemFile )
-{
- char *ppos = stemFile + strlen(stemFile) - 1;
-
- /* Scan backwards from the end looking for the first dot.
- * If we encounter a '/' before the first dot, then stop the scan. */
- while ( 1 ) {
- /* If we found a dot or got to the beginning of the string then
- * we are done. */
- if ( ppos == stemFile || *ppos == '.' )
- break;
-
- /* If we hit a / then there is no extension. Done. */
- if ( *ppos == '/' ) {
- ppos = stemFile;
- break;
- }
- ppos--;
- }
-
- /* If we got to the front of the string then bail we
- * did not find an extension */
- if ( ppos == stemFile )
- ppos = 0;
-
- return ppos;
-}
-
-/* Make a file name from a stem. Removes the old filename suffix and
- * replaces it with a new one. Returns a newed up string. */
-char *fileNameFromStem( char *stemFile, char *suffix )
-{
- int len = strlen( stemFile );
- assert( len > 0 );
-
- /* Get the extension. */
- char *ppos = findFileExtension( stemFile );
-
- /* If an extension was found, then shorten what we think the len is. */
- if ( ppos != 0 )
- len = ppos - stemFile;
-
- /* Make the return string from the stem and the suffix. */
- char *retVal = new char[ len + strlen( suffix ) + 1 ];
- strncpy( retVal, stemFile, len );
- strcpy( retVal + len, suffix );
-
- return retVal;
-}
-
-/* Total error count. */
-int gblErrorCount = 0;
-
-/* Print the opening to a program error, then return the error stream. */
-ostream &error()
-{
- gblErrorCount += 1;
- cerr << PROGNAME ": ";
- return cerr;
-}
-
-/* Print the opening to an error in the input, then return the error ostream. */
-//ostream &error( const YYLTYPE &loc )
-//{
-// gblErrorCount += 1;
-// cerr << gblFileName << ":" << loc.first_line << ":" << loc.first_column << ": ";
-// return cerr;
-//}
-
-/* Print the opening to an error in the input, then return the error ostream. */
-//ostream &error( const InputLoc &loc )
-//{
-// gblErrorCount += 1;
-// cerr << gblFileName << ":" << loc.line << ":" << loc.col << ": ";
-// return cerr;
-//}
-
-ostream &error( int first_line, int first_column )
-{
- gblErrorCount += 1;
- cerr << gblFileName << ":" << ":" << first_line << ":" << first_column << ": ";
- return cerr;
-}
-
-ostream &warning( )
-{
- cerr << gblFileName << ":" << ": warning: ";
- return cerr;
-}
-
-ostream &warning( const InputLoc &loc )
-{
- cerr << gblFileName << loc.line << ":" << loc.col << ": warning: ";
- return cerr;
-}
-
-std::ostream &warning( int first_line, int first_column )
-{
- cerr << gblFileName << ":" << first_line << ":" <<
- first_column << ": warning: ";
- return cerr;
-}
-
-//ostream &xml_error( const YYLTYPE &loc )
-//{
-// gblErrorCount += 1;
-// cerr << "<xml-input>:" << loc.first_line << ":" << loc.first_column << ": ";
-// return cerr;
-//}
-
-ostream &xml_error( const InputLoc &loc )
-{
- gblErrorCount += 1;
- cerr << "<xml-input>:" << loc.line << ":" << loc.col << ": ";
- return cerr;
-}
-
-/* Counts newlines before sending sync. */
-int output_filter::sync( )
-{
- line += 1;
- return std::filebuf::sync();
-}
-
-/* Counts newlines before sending data out to file. */
-std::streamsize output_filter::xsputn( const char *s, std::streamsize n )
-{
- for ( int i = 0; i < n; i++ ) {
- if ( s[i] == '\n' )
- line += 1;
- }
- return std::filebuf::xsputn( s, n );
-}
-
-void escapeLineDirectivePath( std::ostream &out, char *path )
-{
- for ( char *pc = path; *pc != 0; pc++ ) {
- if ( *pc == '\\' )
- out << "\\\\";
- else
- out << *pc;
- }
-}
-
-/* Invoked by the parser, after the source file
- * name is taken from XML file. */
-void openOutput( char *inputFile )
-{
- /* If the output format is code and no output file name is given, then
- * make a default. */
- if ( outputFormat == OutCode && outputFileName == 0 ) {
- char *ext = findFileExtension( inputFile );
- if ( ext != 0 && strcmp( ext, ".rh" ) == 0 )
- outputFileName = fileNameFromStem( inputFile, ".h" );
- else {
- char *defExtension = 0;
- switch ( hostLangType ) {
- case CCode: defExtension = ".c"; break;
- case DCode: defExtension = ".d"; break;
- case JavaCode: defExtension = ".java"; break;
- }
- outputFileName = fileNameFromStem( inputFile, defExtension );
- }
- }
-
- /* Make sure we are not writing to the same file as the input file. */
- if ( outputFileName != 0 && strcmp( inputFile, outputFileName ) == 0 ) {
- error() << "output file \"" << outputFileName <<
- "\" is the same as the input file" << endl;
- }
-
- if ( outputFileName != 0 ) {
- /* Create the filter on the output and open it. */
- outFilter = new output_filter;
- outFilter->open( outputFileName, ios::out|ios::trunc );
- if ( !outFilter->is_open() ) {
- error() << "error opening " << outputFileName << " for writing" << endl;
- exit(1);
- }
-
- /* Open the output stream, attaching it to the filter. */
- outStream = new ostream( outFilter );
- }
- else {
- /* Writing out ot std out. */
- outStream = &cout;
- }
-}
-
-/* Main, process args and call yyparse to start scanning input. */
-int main(int argc, char **argv)
-{
- ParamCheck pc("o:VpT:F:G:vHh?-:P:", argc, argv);
- char *xmlInputFileName = 0;
-
- while ( pc.check() ) {
- switch ( pc.state ) {
- case ParamCheck::match:
- switch ( pc.parameter ) {
- /* Output. */
- case 'o':
- if ( *pc.parameterArg == 0 )
- error() << "a zero length output file name was given" << endl;
- else if ( outputFileName != 0 )
- error() << "more than one output file name was given" << endl;
- else {
- /* Ok, remember the output file name. */
- outputFileName = pc.parameterArg;
- }
- break;
-
- /* Output formats. */
- case 'V':
- outputFormat = OutGraphvizDot;
- break;
-
- case 'p':
- printPrintables = true;
- break;
-
- /* Code style. */
- case 'T':
- if ( pc.parameterArg[0] == '0' )
- codeStyle = GenTables;
- else if ( pc.parameterArg[0] == '1' )
- codeStyle = GenFTables;
- else {
- error() << "-T" << pc.parameterArg[0] <<
- " is an invalid argument" << endl;
- exit(1);
- }
- break;
- case 'F':
- if ( pc.parameterArg[0] == '0' )
- codeStyle = GenFlat;
- else if ( pc.parameterArg[0] == '1' )
- codeStyle = GenFFlat;
- else {
- error() << "-F" << pc.parameterArg[0] <<
- " is an invalid argument" << endl;
- exit(1);
- }
- break;
- case 'G':
- if ( pc.parameterArg[0] == '0' )
- codeStyle = GenGoto;
- else if ( pc.parameterArg[0] == '1' )
- codeStyle = GenFGoto;
- else if ( pc.parameterArg[0] == '2' )
- codeStyle = GenIpGoto;
- else {
- error() << "-G" << pc.parameterArg[0] <<
- " is an invalid argument" << endl;
- exit(1);
- }
- break;
- case 'P':
- codeStyle = GenSplit;
- numSplitPartitions = atoi( pc.parameterArg );
- break;
-
- /* Version and help. */
- case 'v':
- version();
- exit(0);
- case 'H': case 'h': case '?':
- usage();
- exit(0);
- case '-':
- if ( strcasecmp(pc.parameterArg, "help") == 0 ) {
- usage();
- exit(0);
- }
- else if ( strcasecmp(pc.parameterArg, "version") == 0 ) {
- version();
- exit(0);
- }
- else {
- error() << "--" << pc.parameterArg <<
- " is an invalid argument" << endl;
- break;
- }
- }
- break;
-
- case ParamCheck::invalid:
- error() << "-" << pc.parameter << " is an invalid argument" << endl;
- break;
-
- case ParamCheck::noparam:
- if ( *pc.curArg == 0 )
- error() << "a zero length input file name was given" << endl;
- else if ( xmlInputFileName != 0 )
- error() << "more than one input file name was given" << endl;
- else {
- /* OK, Remember the filename. */
- xmlInputFileName = pc.curArg;
- }
- break;
- }
- }
-
- /* Bail on above errors. */
- if ( gblErrorCount > 0 )
- exit(1);
-
- /* Open the input file for reading. */
- if ( xmlInputFileName != 0 ) {
- /* Open the input file for reading. */
- ifstream *inFile = new ifstream( xmlInputFileName );
- inStream = inFile;
- if ( ! inFile->is_open() )
- error() << "could not open " << xmlInputFileName << " for reading" << endl;
- }
- else {
- xmlInputFileName = "<stdin>";
- inStream = &cin;
- }
-
- /* Bail on above errors. */
- if ( gblErrorCount > 0 )
- exit(1);
-
- /* Parse the input! */
- xml_parse( *inStream, xmlInputFileName );
-
- /* If writing to a file, delete the ostream, causing it to flush.
- * Standard out is flushed automatically. */
- if ( outputFileName != 0 ) {
- delete outStream;
- delete outFilter;
- }
-
- /* Finished, final check for errors.. */
- if ( gblErrorCount > 0 ) {
- /* If we opened an output file, remove it. */
- if ( outputFileName != 0 )
- unlink( outputFileName );
- exit(1);
- }
- return 0;
-}
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "redfsm.h"
-#include "avlmap.h"
-#include <iostream>
-#include <sstream>
-
-using std::ostringstream;
-
-KeyOps *keyOps = 0;
-
-string Action::nameOrLoc()
-{
- if ( name != 0 )
- return string(name);
- else {
- ostringstream ret;
- ret << loc.line << ":" << loc.col;
- return ret.str();
- }
-}
-
-RedFsmAp::RedFsmAp()
-:
- wantComplete(false),
- forcedErrorState(false),
- nextActionId(0),
- nextTransId(0),
- errState(0),
- errTrans(0),
- firstFinState(0),
- numFinStates(0)
-{
-}
-
-void RedFsmAp::depthFirstOrdering( RedStateAp *state )
-{
- /* Nothing to do if the state is already on the list. */
- if ( state->onStateList )
- return;
-
- /* Doing depth first, put state on the list. */
- state->onStateList = true;
- stateList.append( state );
-
- /* At this point transitions should only be in ranges. */
- assert( state->outSingle.length() == 0 );
- assert( state->defTrans == 0 );
-
- /* Recurse on everything ranges. */
- for ( RedTransList::Iter rtel = state->outRange; rtel.lte(); rtel++ ) {
- if ( rtel->value->targ != 0 )
- depthFirstOrdering( rtel->value->targ );
- }
-}
-
-/* Ordering states by transition connections. */
-void RedFsmAp::depthFirstOrdering()
-{
- /* Init on state list flags. */
- for ( RedStateList::Iter st = stateList; st.lte(); st++ )
- st->onStateList = false;
-
- /* Clear out the state list, we will rebuild it. */
- int stateListLen = stateList.length();
- stateList.abandon();
-
- /* Add back to the state list from the start state and all other entry
- * points. */
- depthFirstOrdering( startState );
- for ( RedStateSet::Iter en = entryPoints; en.lte(); en++ )
- depthFirstOrdering( *en );
- if ( forcedErrorState )
- depthFirstOrdering( errState );
-
- /* Make sure we put everything back on. */
- assert( stateListLen == stateList.length() );
-}
-
-/* Assign state ids by appearance in the state list. */
-void RedFsmAp::sequentialStateIds()
-{
- /* Table based machines depend on the state numbers starting at zero. */
- nextStateId = 0;
- for ( RedStateList::Iter st = stateList; st.lte(); st++ )
- st->id = nextStateId++;
-}
-
-/* Stable sort the states by final state status. */
-void RedFsmAp::sortStatesByFinal()
-{
- /* Move forward through the list and throw final states onto the end. */
- RedStateAp *state = 0;
- RedStateAp *next = stateList.head;
- RedStateAp *last = stateList.tail;
- while ( state != last ) {
- /* Move forward and load up the next. */
- state = next;
- next = state->next;
-
- /* Throw to the end? */
- if ( state->isFinal ) {
- stateList.detach( state );
- stateList.append( state );
- }
- }
-}
-
-/* Assign state ids by final state state status. */
-void RedFsmAp::sortStateIdsByFinal()
-{
- /* Table based machines depend on this starting at zero. */
- nextStateId = 0;
-
- /* First pass to assign non final ids. */
- for ( RedStateList::Iter st = stateList; st.lte(); st++ ) {
- if ( ! st->isFinal )
- st->id = nextStateId++;
- }
-
- /* Second pass to assign final ids. */
- for ( RedStateList::Iter st = stateList; st.lte(); st++ ) {
- if ( st->isFinal )
- st->id = nextStateId++;
- }
-}
-
-/* Find the final state with the lowest id. */
-void RedFsmAp::findFirstFinState()
-{
- for ( RedStateList::Iter st = stateList; st.lte(); st++ ) {
- if ( st->isFinal && (firstFinState == 0 || st->id < firstFinState->id) )
- firstFinState = st;
- }
-}
-
-void RedFsmAp::assignActionLocs()
-{
- int nextLocation = 0;
- for ( ActionTableMap::Iter act = actionMap; act.lte(); act++ ) {
- /* Store the loc, skip over the array and a null terminator. */
- act->location = nextLocation;
- nextLocation += act->key.length() + 1;
- }
-}
-
-/* Check if we can extend the current range by displacing any ranges
- * ahead to the singles. */
-bool RedFsmAp::canExtend( const RedTransList &list, int pos )
-{
- /* Get the transition that we want to extend. */
- RedTransAp *extendTrans = list[pos].value;
-
- /* Look ahead in the transition list. */
- for ( int next = pos + 1; next < list.length(); pos++, next++ ) {
- /* If they are not continuous then cannot extend. */
- Key nextKey = list[next].lowKey;
- nextKey.decrement();
- if ( list[pos].highKey != nextKey )
- break;
-
- /* Check for the extenstion property. */
- if ( extendTrans == list[next].value )
- return true;
-
- /* If the span of the next element is more than one, then don't keep
- * checking, it won't be moved to single. */
- unsigned long long nextSpan = keyOps->span( list[next].lowKey, list[next].highKey );
- if ( nextSpan > 1 )
- break;
- }
- return false;
-}
-
-/* Move ranges to the singles list. */
-void RedFsmAp::moveTransToSingle( RedStateAp *state )
-{
- RedTransList &range = state->outRange;
- RedTransList &single = state->outSingle;
- for ( int rpos = 0; rpos < range.length(); ) {
- /* Check if this is a range we can extend. */
- if ( canExtend( range, rpos ) ) {
- /* Transfer singles over. */
- while ( range[rpos].value != range[rpos+1].value ) {
- /* Transfer the range to single. */
- single.append( range[rpos+1] );
- range.remove( rpos+1 );
- }
-
- /* Extend. */
- range[rpos].highKey = range[rpos+1].highKey;
- range.remove( rpos+1 );
- }
- /* Maybe move it to the singles. */
- else if ( keyOps->span( range[rpos].lowKey, range[rpos].highKey ) == 1 ) {
- single.append( range[rpos] );
- range.remove( rpos );
- }
- else {
- /* Keeping it in the ranges. */
- rpos += 1;
- }
- }
-}
-
-/* Look through ranges and choose suitable single character transitions. */
-void RedFsmAp::chooseSingle()
-{
- /* Loop the states. */
- for ( RedStateList::Iter st = stateList; st.lte(); st++ ) {
- /* Rewrite the transition list taking out the suitable single
- * transtions. */
- moveTransToSingle( st );
- }
-}
-
-void RedFsmAp::makeFlat()
-{
- for ( RedStateList::Iter st = stateList; st.lte(); st++ ) {
- if ( st->stateCondList.length() == 0 ) {
- st->condLowKey = 0;
- st->condHighKey = 0;
- }
- else {
- st->condLowKey = st->stateCondList.head->lowKey;
- st->condHighKey = st->stateCondList.tail->highKey;
-
- unsigned long long span = keyOps->span( st->condLowKey, st->condHighKey );
- st->condList = new CondSpace*[ span ];
- memset( st->condList, 0, sizeof(CondSpace*)*span );
-
- for ( StateCondList::Iter sci = st->stateCondList; sci.lte(); sci++ ) {
- unsigned long long base, trSpan;
- base = keyOps->span( st->condLowKey, sci->lowKey )-1;
- trSpan = keyOps->span( sci->lowKey, sci->highKey );
- for ( unsigned long long pos = 0; pos < trSpan; pos++ )
- st->condList[base+pos] = sci->condSpace;
- }
- }
-
- if ( st->outRange.length() == 0 ) {
- st->lowKey = st->highKey = 0;
- st->transList = 0;
- }
- else {
- st->lowKey = st->outRange[0].lowKey;
- st->highKey = st->outRange[st->outRange.length()-1].highKey;
- unsigned long long span = keyOps->span( st->lowKey, st->highKey );
- st->transList = new RedTransAp*[ span ];
- memset( st->transList, 0, sizeof(RedTransAp*)*span );
-
- for ( RedTransList::Iter trans = st->outRange; trans.lte(); trans++ ) {
- unsigned long long base, trSpan;
- base = keyOps->span( st->lowKey, trans->lowKey )-1;
- trSpan = keyOps->span( trans->lowKey, trans->highKey );
- for ( unsigned long long pos = 0; pos < trSpan; pos++ )
- st->transList[base+pos] = trans->value;
- }
-
- /* Fill in the gaps with the default transition. */
- for ( unsigned long long pos = 0; pos < span; pos++ ) {
- if ( st->transList[pos] == 0 )
- st->transList[pos] = st->defTrans;
- }
- }
- }
-}
-
-
-/* A default transition has been picked, move it from the outRange to the
- * default pointer. */
-void RedFsmAp::moveToDefault( RedTransAp *defTrans, RedStateAp *state )
-{
- /* Rewrite the outRange, omitting any ranges that use
- * the picked default. */
- RedTransList outRange;
- for ( RedTransList::Iter rtel = state->outRange; rtel.lte(); rtel++ ) {
- /* If it does not take the default, copy it over. */
- if ( rtel->value != defTrans )
- outRange.append( *rtel );
- }
-
- /* Save off the range we just created into the state's range. */
- state->outRange.shallowCopy( outRange );
- outRange.abandon();
-
- /* Store the default. */
- state->defTrans = defTrans;
-}
-
-bool RedFsmAp::alphabetCovered( RedTransList &outRange )
-{
- /* Cannot cover without any out ranges. */
- if ( outRange.length() == 0 )
- return false;
-
- /* If the first range doesn't start at the the lower bound then the
- * alphabet is not covered. */
- RedTransList::Iter rtel = outRange;
- if ( keyOps->minKey < rtel->lowKey )
- return false;
-
- /* Check that every range is next to the previous one. */
- rtel.increment();
- for ( ; rtel.lte(); rtel++ ) {
- Key highKey = rtel[-1].highKey;
- highKey.increment();
- if ( highKey != rtel->lowKey )
- return false;
- }
-
- /* The last must extend to the upper bound. */
- RedTransEl *last = &outRange[outRange.length()-1];
- if ( last->highKey < keyOps->maxKey )
- return false;
-
- return true;
-}
-
-RedTransAp *RedFsmAp::chooseDefaultSpan( RedStateAp *state )
-{
- /* Make a set of transitions from the outRange. */
- RedTransSet stateTransSet;
- for ( RedTransList::Iter rtel = state->outRange; rtel.lte(); rtel++ )
- stateTransSet.insert( rtel->value );
-
- /* For each transition in the find how many alphabet characters the
- * transition spans. */
- unsigned long long *span = new unsigned long long[stateTransSet.length()];
- memset( span, 0, sizeof(unsigned long long) * stateTransSet.length() );
- for ( RedTransList::Iter rtel = state->outRange; rtel.lte(); rtel++ ) {
- /* Lookup the transition in the set. */
- RedTransAp **inSet = stateTransSet.find( rtel->value );
- int pos = inSet - stateTransSet.data;
- span[pos] += keyOps->span( rtel->lowKey, rtel->highKey );
- }
-
- /* Find the max span, choose it for making the default. */
- RedTransAp *maxTrans = 0;
- unsigned long long maxSpan = 0;
- for ( RedTransSet::Iter rtel = stateTransSet; rtel.lte(); rtel++ ) {
- if ( span[rtel.pos()] > maxSpan ) {
- maxSpan = span[rtel.pos()];
- maxTrans = *rtel;
- }
- }
-
- delete[] span;
- return maxTrans;
-}
-
-/* Pick default transitions from ranges for the states. */
-void RedFsmAp::chooseDefaultSpan()
-{
- /* Loop the states. */
- for ( RedStateList::Iter st = stateList; st.lte(); st++ ) {
- /* Only pick a default transition if the alphabet is covered. This
- * avoids any transitions in the out range that go to error and avoids
- * the need for an ERR state. */
- if ( alphabetCovered( st->outRange ) ) {
- /* Pick a default transition by largest span. */
- RedTransAp *defTrans = chooseDefaultSpan( st );
-
- /* Rewrite the transition list taking out the transition we picked
- * as the default and store the default. */
- moveToDefault( defTrans, st );
- }
- }
-}
-
-RedTransAp *RedFsmAp::chooseDefaultGoto( RedStateAp *state )
-{
- /* Make a set of transitions from the outRange. */
- RedTransSet stateTransSet;
- for ( RedTransList::Iter rtel = state->outRange; rtel.lte(); rtel++ ) {
- if ( rtel->value->targ == state->next )
- return rtel->value;
- }
- return 0;
-}
-
-void RedFsmAp::chooseDefaultGoto()
-{
- /* Loop the states. */
- for ( RedStateList::Iter st = stateList; st.lte(); st++ ) {
- /* Pick a default transition. */
- RedTransAp *defTrans = chooseDefaultGoto( st );
- if ( defTrans == 0 )
- defTrans = chooseDefaultSpan( st );
-
- /* Rewrite the transition list taking out the transition we picked
- * as the default and store the default. */
- moveToDefault( defTrans, st );
- }
-}
-
-RedTransAp *RedFsmAp::chooseDefaultNumRanges( RedStateAp *state )
-{
- /* Make a set of transitions from the outRange. */
- RedTransSet stateTransSet;
- for ( RedTransList::Iter rtel = state->outRange; rtel.lte(); rtel++ )
- stateTransSet.insert( rtel->value );
-
- /* For each transition in the find how many ranges use the transition. */
- int *numRanges = new int[stateTransSet.length()];
- memset( numRanges, 0, sizeof(int) * stateTransSet.length() );
- for ( RedTransList::Iter rtel = state->outRange; rtel.lte(); rtel++ ) {
- /* Lookup the transition in the set. */
- RedTransAp **inSet = stateTransSet.find( rtel->value );
- numRanges[inSet - stateTransSet.data] += 1;
- }
-
- /* Find the max number of ranges. */
- RedTransAp *maxTrans = 0;
- int maxNumRanges = 0;
- for ( RedTransSet::Iter rtel = stateTransSet; rtel.lte(); rtel++ ) {
- if ( numRanges[rtel.pos()] > maxNumRanges ) {
- maxNumRanges = numRanges[rtel.pos()];
- maxTrans = *rtel;
- }
- }
-
- delete[] numRanges;
- return maxTrans;
-}
-
-void RedFsmAp::chooseDefaultNumRanges()
-{
- /* Loop the states. */
- for ( RedStateList::Iter st = stateList; st.lte(); st++ ) {
- /* Pick a default transition. */
- RedTransAp *defTrans = chooseDefaultNumRanges( st );
-
- /* Rewrite the transition list taking out the transition we picked
- * as the default and store the default. */
- moveToDefault( defTrans, st );
- }
-}
-
-RedTransAp *RedFsmAp::getErrorTrans( )
-{
- /* If the error trans has not been made aready, make it. */
- if ( errTrans == 0 ) {
- /* This insert should always succeed since no transition created by
- * the user can point to the error state. */
- errTrans = new RedTransAp( getErrorState(), 0, nextTransId++ );
- RedTransAp *inRes = transSet.insert( errTrans );
- assert( inRes != 0 );
- }
- return errTrans;
-}
-
-RedStateAp *RedFsmAp::getErrorState()
-{
- /* Check if we need to init the error trans. */
- if ( errState == 0 ) {
- errState = new RedStateAp();
- stateList.append( errState );
- }
- return errState;
-}
-
-
-RedTransAp *RedFsmAp::allocateTrans( RedStateAp *targ, RedAction *action )
-{
- /* Create a reduced trans and look for it in the transiton set. */
- RedTransAp redTrans( targ, action, 0 );
- RedTransAp *inDict = transSet.find( &redTrans );
- if ( inDict == 0 ) {
- inDict = new RedTransAp( targ, action, nextTransId++ );
- transSet.insert( inDict );
- }
- return inDict;
-}
-
-void RedFsmAp::partitionFsm( int nparts )
-{
- /* At this point the states are ordered by a depth-first traversal. We
- * will allocate to partitions based on this ordering. */
- this->nParts = nparts;
- int partSize = stateList.length() / nparts;
- int remainder = stateList.length() % nparts;
- int numInPart = partSize;
- int partition = 0;
- if ( remainder-- > 0 )
- numInPart += 1;
- for ( RedStateList::Iter st = stateList; st.lte(); st++ ) {
- st->partition = partition;
-
- numInPart -= 1;
- if ( numInPart == 0 ) {
- partition += 1;
- numInPart = partSize;
- if ( remainder-- > 0 )
- numInPart += 1;
- }
- }
-}
-
-void RedFsmAp::setInTrans()
-{
- /* First pass counts the number of transitions. */
- for ( TransApSet::Iter trans = transSet; trans.lte(); trans++ )
- trans->targ->numInTrans += 1;
-
- /* Pass over states to allocate the needed memory. Reset the counts so we
- * can use them as the current size. */
- for ( RedStateList::Iter st = stateList; st.lte(); st++ ) {
- st->inTrans = new RedTransAp*[st->numInTrans];
- st->numInTrans = 0;
- }
-
- /* Second pass over transitions copies pointers into the in trans list. */
- for ( TransApSet::Iter trans = transSet; trans.lte(); trans++ )
- trans->targ->inTrans[trans->targ->numInTrans++] = trans;
-}
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _REDFSM_H
-#define _REDFSM_H
-
-#include <assert.h>
-#include <string.h>
-#include <string>
-#include "common.h"
-#include "vector.h"
-#include "dlist.h"
-#include "compare.h"
-#include "bstmap.h"
-#include "bstset.h"
-#include "avlmap.h"
-#include "avltree.h"
-#include "avlbasic.h"
-#include "mergesort.h"
-#include "rlcodegen.h"
-#include "sbstmap.h"
-#include "sbstset.h"
-#include "sbsttable.h"
-
-#define TRANS_ERR_TRANS 0
-#define STATE_ERR_STATE 0
-#define FUNC_NO_FUNC 0
-
-using std::string;
-
-struct RedStateAp;
-struct InlineList;
-struct Action;
-
-/*
- * Inline code tree
- */
-struct InlineItem
-{
- enum Type
- {
- Text, Goto, Call, Next, GotoExpr, CallExpr, NextExpr, Ret,
- PChar, Char, Hold, Exec, HoldTE, ExecTE, Curs, Targs, Entry,
- LmSwitch, LmSetActId, LmSetTokEnd, LmGetTokEnd, LmInitTokStart,
- LmInitAct, LmSetTokStart, SubAction, Break
- };
-
- InlineItem( const InputLoc &loc, Type type ) :
- loc(loc), data(0), targId(0), targState(0),
- lmId(0), children(0), offset(0),
- handlesError(false), type(type) { }
-
- InputLoc loc;
- char *data;
- int targId;
- RedStateAp *targState;
- int lmId;
- InlineList *children;
- int offset;
- bool handlesError;
- Type type;
-
- InlineItem *prev, *next;
-};
-
-/* Normally this would be atypedef, but that would entail including DList from
- * ptreetypes, which should be just typedef forwards. */
-struct InlineList : public DList<InlineItem> { };
-
-/* Element in list of actions. Contains the string for the code to exectute. */
-struct Action
-:
- public DListEl<Action>
-{
- Action( )
- :
- name(0),
- inlineList(0),
- actionId(0),
- numTransRefs(0),
- numToStateRefs(0),
- numFromStateRefs(0),
- numEofRefs(0)
- {
- }
-
- /* Data collected during parse. */
- InputLoc loc;
- char *name;
- InlineList *inlineList;
- int actionId;
-
- string nameOrLoc();
-
- /* Number of references in the final machine. */
- int numRefs()
- { return numTransRefs + numToStateRefs + numFromStateRefs + numEofRefs; }
- int numTransRefs;
- int numToStateRefs;
- int numFromStateRefs;
- int numEofRefs;
-};
-
-
-/* Forwards. */
-struct RedStateAp;
-struct StateAp;
-
-/* Transistion Action Element. */
-typedef SBstMapEl< int, Action* > ActionTableEl;
-
-/* Transition Action Table. */
-struct ActionTable
- : public SBstMap< int, Action*, CmpOrd<int> >
-{
- void setAction( int ordering, Action *action );
- void setActions( int *orderings, Action **actions, int nActs );
- void setActions( const ActionTable &other );
-};
-
-/* Compare of a whole action table element (key & value). */
-struct CmpActionTableEl
-{
- static int compare( const ActionTableEl &action1,
- const ActionTableEl &action2 )
- {
- if ( action1.key < action2.key )
- return -1;
- else if ( action1.key > action2.key )
- return 1;
- else if ( action1.value < action2.value )
- return -1;
- else if ( action1.value > action2.value )
- return 1;
- return 0;
- }
-};
-
-/* Compare for ActionTable. */
-typedef CmpSTable< ActionTableEl, CmpActionTableEl > CmpActionTable;
-
-/* Set of states. */
-typedef BstSet<RedStateAp*> RedStateSet;
-typedef BstSet<int> IntSet;
-
-/* Reduced action. */
-struct RedAction
-:
- public AvlTreeEl<RedAction>
-{
- RedAction( )
- :
- key(),
- eofRefs(0),
- numTransRefs(0),
- numToStateRefs(0),
- numFromStateRefs(0),
- numEofRefs(0),
- bAnyNextStmt(false),
- bAnyCurStateRef(false),
- bAnyBreakStmt(false)
- { }
-
- const ActionTable &getKey()
- { return key; }
-
- ActionTable key;
- int actListId;
- int location;
- IntSet *eofRefs;
-
- /* Number of references in the final machine. */
- bool numRefs()
- { return numTransRefs + numToStateRefs + numFromStateRefs + numEofRefs; }
- int numTransRefs;
- int numToStateRefs;
- int numFromStateRefs;
- int numEofRefs;
-
- bool anyNextStmt() { return bAnyNextStmt; }
- bool anyCurStateRef() { return bAnyCurStateRef; }
- bool anyBreakStmt() { return bAnyBreakStmt; }
-
- bool bAnyNextStmt;
- bool bAnyCurStateRef;
- bool bAnyBreakStmt;
-};
-typedef AvlTree<RedAction, ActionTable, CmpActionTable> ActionTableMap;
-
-/* Reduced transition. */
-struct RedTransAp
-:
- public AvlTreeEl<RedTransAp>
-{
- RedTransAp( RedStateAp *targ, RedAction *action, int id )
- : targ(targ), action(action), id(id), labelNeeded(true) { }
-
- RedStateAp *targ;
- RedAction *action;
- int id;
- bool partitionBoundary;
- bool labelNeeded;
-};
-
-/* Compare of transitions for the final reduction of transitions. Comparison
- * is on target and the pointer to the shared action table. It is assumed that
- * when this is used the action tables have been reduced. */
-struct CmpRedTransAp
-{
- static int compare( const RedTransAp &t1, const RedTransAp &t2 )
- {
- if ( t1.targ < t2.targ )
- return -1;
- else if ( t1.targ > t2.targ )
- return 1;
- else if ( t1.action < t2.action )
- return -1;
- else if ( t1.action > t2.action )
- return 1;
- else
- return 0;
- }
-};
-
-typedef AvlBasic<RedTransAp, CmpRedTransAp> TransApSet;
-
-/* Element in out range. */
-struct RedTransEl
-{
- /* Constructors. */
- RedTransEl( Key lowKey, Key highKey, RedTransAp *value )
- : lowKey(lowKey), highKey(highKey), value(value) { }
-
- Key lowKey, highKey;
- RedTransAp *value;
-};
-
-typedef Vector<RedTransEl> RedTransList;
-typedef Vector<RedStateAp*> RedStateVect;
-
-typedef BstMapEl<RedStateAp*, unsigned long long> RedSpanMapEl;
-typedef BstMap<RedStateAp*, unsigned long long> RedSpanMap;
-
-/* Compare used by span map sort. Reverse sorts by the span. */
-struct CmpRedSpanMapEl
-{
- static int compare( const RedSpanMapEl &smel1, const RedSpanMapEl &smel2 )
- {
- if ( smel1.value > smel2.value )
- return -1;
- else if ( smel1.value < smel2.value )
- return 1;
- else
- return 0;
- }
-};
-
-/* Sorting state-span map entries by span. */
-typedef MergeSort<RedSpanMapEl, CmpRedSpanMapEl> RedSpanMapSort;
-
-/* Set of entry ids that go into this state. */
-typedef Vector<int> EntryIdVect;
-typedef Vector<char*> EntryNameVect;
-
-typedef Vector< Action* > CondSet;
-
-struct Condition
-{
- Condition( )
- : key(0), baseKey(0) {}
-
- Key key;
- Key baseKey;
- CondSet condSet;
-
- Condition *next, *prev;
-};
-typedef DList<Condition> ConditionList;
-
-struct CondSpace
-{
- Key baseKey;
- CondSet condSet;
- int condSpaceId;
-
- CondSpace *next, *prev;
-};
-typedef DList<CondSpace> CondSpaceList;
-
-struct StateCond
-{
- Key lowKey;
- Key highKey;
-
- CondSpace *condSpace;
-
- StateCond *prev, *next;
-};
-typedef DList<StateCond> StateCondList;
-typedef Vector<StateCond*> StateCondVect;
-
-/* Reduced state. */
-struct RedStateAp
-{
- RedStateAp()
- :
- defTrans(0),
- condList(0),
- transList(0),
- isFinal(false),
- labelNeeded(false),
- outNeeded(false),
- onStateList(false),
- toStateAction(0),
- fromStateAction(0),
- eofAction(0),
- id(0),
- bAnyRegCurStateRef(false),
- partitionBoundary(false),
- inTrans(0),
- numInTrans(0)
- { }
-
- /* Transitions out. */
- RedTransList outSingle;
- RedTransList outRange;
- RedTransAp *defTrans;
-
- /* For flat conditions. */
- Key condLowKey, condHighKey;
- CondSpace **condList;
-
- /* For flat keys. */
- Key lowKey, highKey;
- RedTransAp **transList;
-
- /* The list of states that transitions from this state go to. */
- RedStateVect targStates;
-
- bool isFinal;
- bool labelNeeded;
- bool outNeeded;
- bool onStateList;
- RedAction *toStateAction;
- RedAction *fromStateAction;
- RedAction *eofAction;
- int id;
- StateCondList stateCondList;
- StateCondVect stateCondVect;
-
- /* Pointers for the list of states. */
- RedStateAp *prev, *next;
-
- bool anyRegCurStateRef() { return bAnyRegCurStateRef; }
- bool bAnyRegCurStateRef;
-
- int partition;
- bool partitionBoundary;
-
- RedTransAp **inTrans;
- int numInTrans;
-};
-
-/* List of states. */
-typedef DList<RedStateAp> RedStateList;
-
-/* Set of reduced transitons. Comparison is by pointer. */
-typedef BstSet< RedTransAp*, CmpOrd<RedTransAp*> > RedTransSet;
-
-/* Next version of the fsm machine. */
-struct RedFsmAp
-{
- RedFsmAp();
-
- bool wantComplete;
- bool forcedErrorState;
-
- int nextActionId;
- int nextTransId;
-
- /* Next State Id doubles as the total number of state ids. */
- int nextStateId;
-
- TransApSet transSet;
- ActionTableMap actionMap;
- RedStateList stateList;
- RedStateSet entryPoints;
- RedStateAp *startState;
- RedStateAp *errState;
- RedTransAp *errTrans;
- RedTransAp *errActionTrans;
- RedStateAp *firstFinState;
- int numFinStates;
- int nParts;
-
- /* Is is it possible to extend a range by bumping ranges that span only
- * one character to the singles array. */
- bool canExtend( const RedTransList &list, int pos );
-
- /* Pick single transitions from the ranges. */
- void moveTransToSingle( RedStateAp *state );
- void chooseSingle();
-
- void makeFlat();
-
- /* Move a selected transition from ranges to default. */
- void moveToDefault( RedTransAp *defTrans, RedStateAp *state );
-
- /* Pick a default transition by largest span. */
- RedTransAp *chooseDefaultSpan( RedStateAp *state );
- void chooseDefaultSpan();
-
- /* Pick a default transition by most number of ranges. */
- RedTransAp *chooseDefaultNumRanges( RedStateAp *state );
- void chooseDefaultNumRanges();
-
- /* Pick a default transition tailored towards goto driven machine. */
- RedTransAp *chooseDefaultGoto( RedStateAp *state );
- void chooseDefaultGoto();
-
- /* Ordering states by transition connections. */
- void optimizeStateOrdering( RedStateAp *state );
- void optimizeStateOrdering();
-
- /* Ordering states by transition connections. */
- void depthFirstOrdering( RedStateAp *state );
- void depthFirstOrdering();
-
- /* Set state ids. */
- void sequentialStateIds();
- void sortStateIdsByFinal();
-
- /* Arrange states in by final id. This is a stable sort. */
- void sortStatesByFinal();
-
- /* Locating the first final state. This is the final state with the lowest
- * id. */
- void findFirstFinState();
-
- void assignActionLocs();
-
- RedTransAp *getErrorTrans();
- RedStateAp *getErrorState();
-
- /* Is every char in the alphabet covered? */
- bool alphabetCovered( RedTransList &outRange );
-
- RedTransAp *allocateTrans( RedStateAp *targState, RedAction *actionTable );
-
- void partitionFsm( int nParts );
-
- void setInTrans();
-};
-
-
-#endif /* _REDFSM_H */
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _RLCODEGEN_H
-#define _RLCODEGEN_H
-
-#include <stdio.h>
-#include <iostream>
-#include <fstream>
-#include "avltree.h"
-#include "vector.h"
-#include "config.h"
-
-#define PROGNAME "rlcodegen"
-
-/* Target language. */
-enum OutputFormat
-{
- OutCode,
- OutGraphvizDot
-};
-
-/* Target output style. */
-enum CodeStyleEnum
-{
- GenTables,
- GenFTables,
- GenFlat,
- GenFFlat,
- GenGoto,
- GenFGoto,
- GenIpGoto,
- GenSplit
-};
-
-/* Filter on the output stream that keeps track of the number of lines
- * output. */
-class output_filter : public std::filebuf
-{
-public:
- output_filter() : line(1) { }
-
- virtual int sync();
- virtual std::streamsize xsputn(const char* s, std::streamsize n);
-
- int line;
-};
-
-extern OutputFormat outputFormat;
-extern CodeStyleEnum codeStyle;
-
-/* IO filenames and stream. */
-extern char *outputFileName;
-extern std::ostream *outStream;
-extern output_filter *outFilter;
-
-extern bool printPrintables;
-extern bool graphvizDone;
-
-int xml_parse( std::istream &input, char *fileName );
-
-extern int gblErrorCount;
-extern char machineMain[];
-
-extern int numSplitPartitions;
-
-/*
- * Error reporting.
- */
-
-/* Location in an input file. */
-struct InputLoc
-{
- int line;
- int col;
-};
-
-struct AttrMarker
-{
- char *id;
- int idLen;
- char *value;
- int valueLen;
-};
-
-struct Attribute
-{
- char *id;
- char *value;
-};
-
-typedef Vector<AttrMarker> AttrMkList;
-typedef Vector<Attribute> AttrList;
-struct XMLTagHashPair;
-
-struct XMLTag
-{
- enum TagType { Open, Close };
-
- XMLTag( XMLTagHashPair *tagId, TagType type ) :
- tagId(tagId), type(type),
- content(0), attrList(0) {}
-
- Attribute *findAttr( char *id )
- {
- if ( attrList != 0 ) {
- for ( AttrList::Iter attr = *attrList; attr.lte(); attr++ ) {
- if ( strcmp( id, attr->id ) == 0 )
- return attr;
- }
- }
- return 0;
- }
-
- XMLTagHashPair *tagId;
- TagType type;
-
- /* Content is associtated with closing tags. */
- char *content;
-
- /* Attribute lists are associated with opening tags. */
- AttrList *attrList;
-};
-
-
-std::ostream &error();
-//std::ostream &error( const YYLTYPE &loc );
-std::ostream &error( const InputLoc &loc );
-std::ostream &error( int first_line, int first_column );
-std::ostream &warning( );
-std::ostream &warning( const InputLoc &loc );
-std::ostream &warning( int first_line, int first_column );
-std::ostream &xml_error( const InputLoc &loc );
-//std::ostream &xml_error( const YYLTYPE &loc );
-
-
-
-void openOutput( char *inputFile );
-char *fileNameFromStem( char *stemFile, char *suffix );
-
-/* Size of the include stack. */
-#define INCLUDE_STACK_SIZE 32
-
-#endif /* _RLCODEGEN_H */
+++ /dev/null
-/*
- * Copyright 2006 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-
-#include "rlcodegen.h"
-#include "splitcodegen.h"
-#include "gendata.h"
-#include <assert.h>
-
-using std::ostream;
-using std::ios;
-using std::endl;
-
-/* Emit the goto to take for a given transition. */
-std::ostream &SplitCodeGen::TRANS_GOTO( RedTransAp *trans, int level )
-{
- if ( trans->targ->partition == currentPartition ) {
- if ( trans->action != 0 ) {
- /* Go to the transition which will go to the state. */
- out << TABS(level) << "goto tr" << trans->id << ";";
- }
- else {
- /* Go directly to the target state. */
- out << TABS(level) << "goto st" << trans->targ->id << ";";
- }
- }
- else {
- if ( trans->action != 0 ) {
- /* Go to the transition which will go to the state. */
- out << TABS(level) << "goto ptr" << trans->id << ";";
- trans->partitionBoundary = true;
- }
- else {
- /* Go directly to the target state. */
- out << TABS(level) << "goto pst" << trans->targ->id << ";";
- trans->targ->partitionBoundary = true;
- }
- }
- return out;
-}
-
-/* Called from before writing the gotos for each state. */
-void SplitCodeGen::GOTO_HEADER( RedStateAp *state, bool stateInPartition )
-{
- bool anyWritten = IN_TRANS_ACTIONS( state );
-
- if ( state->labelNeeded )
- out << "st" << state->id << ":\n";
-
- if ( state->toStateAction != 0 ) {
- /* Remember that we wrote an action. Write every action in the list. */
- anyWritten = true;
- for ( ActionTable::Iter item = state->toStateAction->key; item.lte(); item++ )
- ACTION( out, item->value, state->id, false );
- }
-
- /* Advance and test buffer pos. */
- if ( state->labelNeeded ) {
- if ( cgd->hasEnd ) {
- out <<
- " if ( ++" << P() << " == " << PE() << " )\n"
- " goto _out" << state->id << ";\n";
- }
- else {
- out <<
- " " << P() << " += 1;\n";
- }
- }
-
- /* Give the state a switch case. */
- out << "case " << state->id << ":\n";
-
- if ( state->fromStateAction != 0 ) {
- /* Remember that we wrote an action. Write every action in the list. */
- anyWritten = true;
- for ( ActionTable::Iter item = state->fromStateAction->key; item.lte(); item++ )
- ACTION( out, item->value, state->id, false );
- }
-
- if ( anyWritten )
- genLineDirective( out );
-
- /* Record the prev state if necessary. */
- if ( state->anyRegCurStateRef() )
- out << " _ps = " << state->id << ";\n";
-}
-
-std::ostream &SplitCodeGen::STATE_GOTOS( int partition )
-{
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- if ( st->partition == partition ) {
- if ( st == redFsm->errState )
- STATE_GOTO_ERROR();
- else {
- /* We call into the base of the goto which calls back into us
- * using virtual functions. Set the current partition rather
- * than coding parameter passing throughout. */
- currentPartition = partition;
-
- /* Writing code above state gotos. */
- GOTO_HEADER( st, st->partition == partition );
-
- if ( st->stateCondVect.length() > 0 ) {
- out << " _widec = " << GET_KEY() << ";\n";
- emitCondBSearch( st, 1, 0, st->stateCondVect.length() - 1 );
- }
-
- /* Try singles. */
- if ( st->outSingle.length() > 0 )
- emitSingleSwitch( st );
-
- /* Default case is to binary search for the ranges, if that fails then */
- if ( st->outRange.length() > 0 )
- emitRangeBSearch( st, 1, 0, st->outRange.length() - 1 );
-
- /* Write the default transition. */
- TRANS_GOTO( st->defTrans, 1 ) << "\n";
- }
- }
- }
- return out;
-}
-
-
-std::ostream &SplitCodeGen::PART_TRANS( int partition )
-{
- for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) {
- if ( trans->partitionBoundary ) {
- out <<
- "ptr" << trans->id << ":\n";
-
- if ( trans->action != 0 ) {
- /* If the action contains a next, then we must preload the current
- * state since the action may or may not set it. */
- if ( trans->action->anyNextStmt() )
- out << " " << CS() << " = " << trans->targ->id << ";\n";
-
- /* Write each action in the list. */
- for ( ActionTable::Iter item = trans->action->key; item.lte(); item++ )
- ACTION( out, item->value, trans->targ->id, false );
- }
-
- out <<
- " goto pst" << trans->targ->id << ";\n";
- trans->targ->partitionBoundary = true;
- }
- }
-
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- if ( st->partitionBoundary ) {
- out <<
- " pst" << st->id << ":\n"
- " " << CS() << " = " << st->id << ";\n";
-
- if ( st->toStateAction != 0 ) {
- /* Remember that we wrote an action. Write every action in the list. */
- for ( ActionTable::Iter item = st->toStateAction->key; item.lte(); item++ )
- ACTION( out, item->value, st->id, false );
- genLineDirective( out );
- }
-
- ptOutLabelUsed = true;
- out << " goto _pt_out; \n";
- }
- }
- return out;
-}
-
-std::ostream &SplitCodeGen::EXIT_STATES( int partition )
-{
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- if ( st->partition == partition && st->outNeeded ) {
- outLabelUsed = true;
- out << " _out" << st->id << ": " << CS() << " = " <<
- st->id << "; goto _out; \n";
- }
- }
- return out;
-}
-
-
-std::ostream &SplitCodeGen::PARTITION( int partition )
-{
- outLabelUsed = false;
- ptOutLabelUsed = false;
-
- /* Initialize the partition boundaries, which get set during the writing
- * of states. After the state writing we will */
- for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ )
- trans->partitionBoundary = false;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ )
- st->partitionBoundary = false;
-
- out << " " << ALPH_TYPE() << " *p = *_pp, *pe = *_ppe;\n";
-
- if ( anyRegCurStateRef() )
- out << " int _ps = 0;\n";
-
- if ( anyConditions() )
- out << " " << WIDE_ALPH_TYPE() << " _widec;\n";
-
- if ( useAgainLabel() ) {
- out <<
- " goto _resume;\n"
- "\n"
- "_again:\n"
- " switch ( " << CS() << " ) {\n";
- AGAIN_CASES() <<
- " default: break;\n"
- " }\n"
- "\n";
-
-
- if ( cgd->hasEnd ) {
- outLabelUsed = true;
- out <<
- " if ( ++" << P() << " == " << PE() << " )\n"
- " goto _out;\n";
-
- }
- else {
- out <<
- " " << P() << " += 1;\n";
- }
-
- out <<
- "_resume:\n";
- }
-
- out <<
- " switch ( " << CS() << " )\n {\n";
- STATE_GOTOS( partition );
- SWITCH_DEFAULT() <<
- " }\n";
- PART_TRANS( partition );
- EXIT_STATES( partition );
-
- if ( outLabelUsed ) {
- out <<
- "\n"
- " _out:\n"
- " *_pp = p;\n"
- " *_ppe = pe;\n"
- " return 0;\n";
- }
-
- if ( ptOutLabelUsed ) {
- out <<
- "\n"
- " _pt_out:\n"
- " *_pp = p;\n"
- " *_ppe = pe;\n"
- " return 1;\n";
- }
-
- return out;
-}
-
-std::ostream &SplitCodeGen::PART_MAP()
-{
- int *partMap = new int[redFsm->stateList.length()];
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ )
- partMap[st->id] = st->partition;
-
- out << "\t";
- int totalItem = 0;
- for ( int i = 0; i < redFsm->stateList.length(); i++ ) {
- out << partMap[i];
- if ( i != redFsm->stateList.length() - 1 ) {
- out << ", ";
- if ( ++totalItem % IALL == 0 )
- out << "\n\t";
- }
- }
-
- delete[] partMap;
- return out;
-}
-
-void SplitCodeGen::writeOutData()
-{
- out <<
- "static const int " << START() << " = " << START_STATE_ID() << ";\n"
- "\n";
-
- if ( cgd->writeFirstFinal ) {
- out <<
- "static const int " << FIRST_FINAL() << " = " << FIRST_FINAL_STATE() << ";\n"
- "\n";
- }
-
- if ( cgd->writeErr ) {
- out <<
- "static const int " << ERROR() << " = " << ERROR_STATE() << ";\n"
- "\n";
- }
-
-
- OPEN_ARRAY( ARRAY_TYPE(numSplitPartitions), PM() );
- PART_MAP();
- CLOSE_ARRAY() <<
- "\n";
-
- for ( int p = 0; p < redFsm->nParts; p++ ) {
- out << "int partition" << p << "( " << ALPH_TYPE() << " **_pp, " << ALPH_TYPE() <<
- " **_ppe, struct " << FSM_NAME() << " *fsm );\n";
- }
- out << "\n";
-}
-
-std::ostream &SplitCodeGen::ALL_PARTITIONS()
-{
- /* compute the format string. */
- int width = 0, high = redFsm->nParts - 1;
- while ( high > 0 ) {
- width++;
- high /= 10;
- }
- assert( width <= 8 );
- char suffFormat[] = "_%6.6d.c";
- suffFormat[2] = suffFormat[4] = ( '0' + width );
-
- for ( int p = 0; p < redFsm->nParts; p++ ) {
- char suffix[10];
- sprintf( suffix, suffFormat, p );
- char *fn = fileNameFromStem( cgd->fileName, suffix );
- char *include = fileNameFromStem( cgd->fileName, ".h" );
-
- /* Create the filter on the output and open it. */
- output_filter *partFilter = new output_filter;
- partFilter->open( fn, ios::out|ios::trunc );
- if ( !outFilter->is_open() ) {
- error() << "error opening " << fn << " for writing" << endl;
- exit(1);
- }
-
- /* Attach the new file to the output stream. */
- std::streambuf *prev_rdbuf = out.rdbuf( partFilter );
-
- out <<
- "#include \"" << include << "\"\n"
- "int partition" << p << "( " << ALPH_TYPE() << " **_pp, " << ALPH_TYPE() <<
- " **_ppe, struct " << FSM_NAME() << " *fsm )\n"
- "{\n";
- PARTITION( p ) <<
- "}\n\n";
- out.flush();
-
- /* Fix the output stream. */
- out.rdbuf( prev_rdbuf );
- }
- return out;
-}
-
-
-void SplitCodeGen::writeOutExec()
-{
- out <<
- " {\n"
- " int _stat = 0;\n";
-
- if ( cgd->hasEnd ) {
- out <<
- " if ( " << P() << " == " << PE() << " )\n"
- " goto _out;\n";
- }
-
- out << " goto _resume;\n";
-
- /* In this reentry, to-state actions have already been executed on the
- * partition-switch exit from the last partition. */
- out << "_reenter:\n";
-
- if ( cgd->hasEnd ) {
- out <<
- " if ( ++" << P() << " == " << PE() << " )\n"
- " goto _out;\n";
- }
- else {
- out <<
- " " << P() << " += 1;\n";
- }
-
- out << "_resume:\n";
-
- out <<
- " switch ( " << PM() << "[" << CS() << "] ) {\n";
- for ( int p = 0; p < redFsm->nParts; p++ ) {
- out <<
- " case " << p << ":\n"
- " _stat = partition" << p << "( &p, &pe, fsm );\n"
- " break;\n";
- }
- out <<
- " }\n"
- " if ( _stat )\n"
- " goto _reenter;\n";
-
- if ( cgd->hasEnd )
- out << " _out: {}\n";
-
- out <<
- " }\n";
-
- ALL_PARTITIONS();
-}
-
-void SplitCodeGen::setLabelsNeeded( RedStateAp *fromState, InlineList *inlineList )
-{
- for ( InlineList::Iter item = *inlineList; item.lte(); item++ ) {
- switch ( item->type ) {
- case InlineItem::Goto: case InlineItem::Call: {
- /* In split code gen we only need labels for transitions across
- * partitions. */
- if ( fromState->partition == item->targState->partition ){
- /* Mark the target as needing a label. */
- item->targState->labelNeeded = true;
- }
- break;
- }
- default: break;
- }
-
- if ( item->children != 0 )
- setLabelsNeeded( fromState, item->children );
- }
-}
-
-void SplitCodeGen::setLabelsNeeded( RedStateAp *fromState, RedTransAp *trans )
-{
- /* In the split code gen we don't need labels for transitions across
- * partitions. */
- if ( fromState->partition == trans->targ->partition ) {
- /* If there is no action with a next statement, then the label will be
- * needed. */
- trans->labelNeeded = true;
- if ( trans->action == 0 || !trans->action->anyNextStmt() )
- trans->targ->labelNeeded = true;
- }
-
- /* Need labels for states that have goto or calls in action code
- * invoked on characters (ie, not from out action code). */
- if ( trans->action != 0 ) {
- /* Loop the actions. */
- for ( ActionTable::Iter act = trans->action->key; act.lte(); act++ ) {
- /* Get the action and walk it's tree. */
- setLabelsNeeded( fromState, act->value->inlineList );
- }
- }
-}
-
-/* Set up labelNeeded flag for each state. */
-void SplitCodeGen::setLabelsNeeded()
-{
- /* If we use the _again label, then we the _again switch, which uses all
- * labels. */
- if ( useAgainLabel() ) {
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ )
- st->labelNeeded = true;
- }
- else {
- /* Do not use all labels by default, init all labelNeeded vars to false. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ )
- st->labelNeeded = false;
- for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ )
- trans->labelNeeded = false;
-
- if ( redFsm->errState != 0 && anyLmSwitchError() )
- redFsm->errState->labelNeeded = true;
-
- /* Walk all transitions and set only those that have targs. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- for ( RedTransList::Iter tel = st->outRange; tel.lte(); tel++ )
- setLabelsNeeded( st, tel->value );
-
- for ( RedTransList::Iter tel = st->outSingle; tel.lte(); tel++ )
- setLabelsNeeded( st, tel->value );
-
- if ( st->defTrans != 0 )
- setLabelsNeeded( st, st->defTrans );
- }
- }
-
- if ( cgd->hasEnd ) {
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ )
- st->outNeeded = st->labelNeeded;
- }
- else {
- if ( redFsm->errState != 0 )
- redFsm->errState->outNeeded = true;
-
- for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ ) {
- /* Any state with a transition in that has a break will need an
- * out label. */
- if ( trans->action != 0 && trans->action->anyBreakStmt() )
- trans->targ->outNeeded = true;
- }
- }
-}
-
+++ /dev/null
-/*
- * Copyright 2006 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _SPLITCODEGEN_H
-#define _SPLITCODEGEN_H
-
-#include "ipgotocodegen.h"
-
-class SplitCodeGen : public IpGotoCodeGen
-{
-public:
- bool ptOutLabelUsed;
-
- std::ostream &PART_MAP();
- std::ostream &EXIT_STATES( int partition );
- std::ostream &PART_TRANS( int partition );
- std::ostream &TRANS_GOTO( RedTransAp *trans, int level );
- void GOTO_HEADER( RedStateAp *state, bool stateInPartition );
- std::ostream &STATE_GOTOS( int partition );
- std::ostream &PARTITION( int partition );
- std::ostream &ALL_PARTITIONS();
- void writeOutData();
- void writeOutExec();
- void writeOutParts();
-
- void setLabelsNeeded( RedStateAp *fromState, InlineList *inlineList );
- void setLabelsNeeded( RedStateAp *fromState, RedTransAp *trans );
- void setLabelsNeeded();
-
- int currentPartition;
-};
-
-struct CSplitCodeGen
- : public SplitCodeGen, public CCodeGen
-{
-};
-
-/*
- * class DIpGotoCodeGen
- */
-struct DSplitCodeGen
- : public IpGotoCodeGen, public DCodeGen
-{
-};
-
-
-#endif /* _SPLITCODEGEN_H */
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- * 2004 Eric Ocean <eric.ocean@ampede.com>
- * 2005 Alan West <alan@alanz.com>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "rlcodegen.h"
-#include "tabcodegen.h"
-#include "redfsm.h"
-#include "gendata.h"
-
-/* Determine if we should use indicies or not. */
-void TabCodeGen::calcIndexSize()
-{
- int sizeWithInds = 0, sizeWithoutInds = 0;
-
- /* Calculate cost of using with indicies. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- int totalIndex = st->outSingle.length() + st->outRange.length() +
- (st->defTrans == 0 ? 0 : 1);
- sizeWithInds += arrayTypeSize(maxIndex) * totalIndex;
- }
- sizeWithInds += arrayTypeSize(maxState) * redFsm->transSet.length();
- if ( anyActions() )
- sizeWithInds += arrayTypeSize(maxActionLoc) * redFsm->transSet.length();
-
- /* Calculate the cost of not using indicies. */
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- int totalIndex = st->outSingle.length() + st->outRange.length() +
- (st->defTrans == 0 ? 0 : 1);
- sizeWithoutInds += arrayTypeSize(maxState) * totalIndex;
- if ( anyActions() )
- sizeWithoutInds += arrayTypeSize(maxActionLoc) * totalIndex;
- }
-
- /* If using indicies reduces the size, use them. */
- useIndicies = sizeWithInds < sizeWithoutInds;
-}
-
-std::ostream &TabCodeGen::TO_STATE_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->toStateAction != 0 )
- act = state->toStateAction->location+1;
- out << act;
- return out;
-}
-
-std::ostream &TabCodeGen::FROM_STATE_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->fromStateAction != 0 )
- act = state->fromStateAction->location+1;
- out << act;
- return out;
-}
-
-std::ostream &TabCodeGen::EOF_ACTION( RedStateAp *state )
-{
- int act = 0;
- if ( state->eofAction != 0 )
- act = state->eofAction->location+1;
- out << act;
- return out;
-}
-
-
-std::ostream &TabCodeGen::TRANS_ACTION( RedTransAp *trans )
-{
- /* If there are actions, emit them. Otherwise emit zero. */
- int act = 0;
- if ( trans->action != 0 )
- act = trans->action->location+1;
- out << act;
- return out;
-}
-
-std::ostream &TabCodeGen::TO_STATE_ACTION_SWITCH()
-{
- /* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = cgd->actionList; act.lte(); act++ ) {
- /* Write out referenced actions. */
- if ( act->numToStateRefs > 0 ) {
- /* Write the case label, the action and the case break. */
- out << "\tcase " << act->actionId << ":\n";
- ACTION( out, act, 0, false );
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-std::ostream &TabCodeGen::FROM_STATE_ACTION_SWITCH()
-{
- /* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = cgd->actionList; act.lte(); act++ ) {
- /* Write out referenced actions. */
- if ( act->numFromStateRefs > 0 ) {
- /* Write the case label, the action and the case break. */
- out << "\tcase " << act->actionId << ":\n";
- ACTION( out, act, 0, false );
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-std::ostream &TabCodeGen::EOF_ACTION_SWITCH()
-{
- /* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = cgd->actionList; act.lte(); act++ ) {
- /* Write out referenced actions. */
- if ( act->numEofRefs > 0 ) {
- /* Write the case label, the action and the case break. */
- out << "\tcase " << act->actionId << ":\n";
- ACTION( out, act, 0, true );
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-
-std::ostream &TabCodeGen::ACTION_SWITCH()
-{
- /* Walk the list of functions, printing the cases. */
- for ( ActionList::Iter act = cgd->actionList; act.lte(); act++ ) {
- /* Write out referenced actions. */
- if ( act->numTransRefs > 0 ) {
- /* Write the case label, the action and the case break. */
- out << "\tcase " << act->actionId << ":\n";
- ACTION( out, act, 0, false );
- out << "\tbreak;\n";
- }
- }
-
- genLineDirective( out );
- return out;
-}
-
-std::ostream &TabCodeGen::COND_OFFSETS()
-{
- out << "\t";
- int totalStateNum = 0, curKeyOffset = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Write the key offset. */
- out << curKeyOffset;
- if ( !st.last() ) {
- out << ", ";
- if ( ++totalStateNum % IALL == 0 )
- out << "\n\t";
- }
-
- /* Move the key offset ahead. */
- curKeyOffset += st->stateCondList.length();
- }
- out << "\n";
- return out;
-}
-
-std::ostream &TabCodeGen::KEY_OFFSETS()
-{
- out << "\t";
- int totalStateNum = 0, curKeyOffset = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Write the key offset. */
- out << curKeyOffset;
- if ( !st.last() ) {
- out << ", ";
- if ( ++totalStateNum % IALL == 0 )
- out << "\n\t";
- }
-
- /* Move the key offset ahead. */
- curKeyOffset += st->outSingle.length() + st->outRange.length()*2;
- }
- out << "\n";
- return out;
-}
-
-
-std::ostream &TabCodeGen::INDEX_OFFSETS()
-{
- out << "\t";
- int totalStateNum = 0, curIndOffset = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Write the index offset. */
- out << curIndOffset;
- if ( !st.last() ) {
- out << ", ";
- if ( ++totalStateNum % IALL == 0 )
- out << "\n\t";
- }
-
- /* Move the index offset ahead. */
- curIndOffset += st->outSingle.length() + st->outRange.length();
- if ( st->defTrans != 0 )
- curIndOffset += 1;
- }
- out << "\n";
- return out;
-}
-
-std::ostream &TabCodeGen::COND_LENS()
-{
- out << "\t";
- int totalStateNum = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Write singles length. */
- out << st->stateCondList.length();
- if ( !st.last() ) {
- out << ", ";
- if ( ++totalStateNum % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- return out;
-}
-
-
-std::ostream &TabCodeGen::SINGLE_LENS()
-{
- out << "\t";
- int totalStateNum = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Write singles length. */
- out << st->outSingle.length();
- if ( !st.last() ) {
- out << ", ";
- if ( ++totalStateNum % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- return out;
-}
-
-std::ostream &TabCodeGen::RANGE_LENS()
-{
- out << "\t";
- int totalStateNum = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Emit length of range index. */
- out << st->outRange.length();
- if ( !st.last() ) {
- out << ", ";
- if ( ++totalStateNum % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- return out;
-}
-
-std::ostream &TabCodeGen::TO_STATE_ACTIONS()
-{
- out << "\t";
- int totalStateNum = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Write any eof action. */
- TO_STATE_ACTION(st);
- if ( !st.last() ) {
- out << ", ";
- if ( ++totalStateNum % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- return out;
-}
-
-std::ostream &TabCodeGen::FROM_STATE_ACTIONS()
-{
- out << "\t";
- int totalStateNum = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Write any eof action. */
- FROM_STATE_ACTION(st);
- if ( !st.last() ) {
- out << ", ";
- if ( ++totalStateNum % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- return out;
-}
-
-std::ostream &TabCodeGen::EOF_ACTIONS()
-{
- out << "\t";
- int totalStateNum = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Write any eof action. */
- EOF_ACTION(st);
- if ( !st.last() ) {
- out << ", ";
- if ( ++totalStateNum % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- return out;
-}
-
-std::ostream &TabCodeGen::COND_KEYS()
-{
- out << '\t';
- int totalTrans = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Loop the state's transitions. */
- for ( StateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
- /* Lower key. */
- out << KEY( sc->lowKey ) << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
-
- /* Upper key. */
- out << KEY( sc->highKey ) << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
- }
-
- /* Output one last number so we don't have to figure out when the last
- * entry is and avoid writing a comma. */
- out << 0 << "\n";
- return out;
-}
-
-std::ostream &TabCodeGen::COND_SPACES()
-{
- out << '\t';
- int totalTrans = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Loop the state's transitions. */
- for ( StateCondList::Iter sc = st->stateCondList; sc.lte(); sc++ ) {
- /* Cond Space id. */
- out << sc->condSpace->condSpaceId << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
- }
-
- /* Output one last number so we don't have to figure out when the last
- * entry is and avoid writing a comma. */
- out << 0 << "\n";
- return out;
-}
-
-std::ostream &TabCodeGen::KEYS()
-{
- out << '\t';
- int totalTrans = 0;
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Loop the singles. */
- for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) {
- out << KEY( stel->lowKey ) << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
-
- /* Loop the state's transitions. */
- for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) {
- /* Lower key. */
- out << KEY( rtel->lowKey ) << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
-
- /* Upper key. */
- out << KEY( rtel->highKey ) << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
- }
-
- /* Output one last number so we don't have to figure out when the last
- * entry is and avoid writing a comma. */
- out << 0 << "\n";
- return out;
-}
-
-std::ostream &TabCodeGen::INDICIES()
-{
- int totalTrans = 0;
- out << '\t';
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Walk the singles. */
- for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) {
- out << stel->value->id << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
-
- /* Walk the ranges. */
- for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) {
- out << rtel->value->id << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
-
- /* The state's default index goes next. */
- if ( st->defTrans != 0 ) {
- out << st->defTrans->id << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
- }
-
- /* Output one last number so we don't have to figure out when the last
- * entry is and avoid writing a comma. */
- out << 0 << "\n";
- return out;
-}
-
-std::ostream &TabCodeGen::TRANS_TARGS()
-{
- int totalTrans = 0;
- out << '\t';
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Walk the singles. */
- for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) {
- RedTransAp *trans = stel->value;
- out << trans->targ->id << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
-
- /* Walk the ranges. */
- for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) {
- RedTransAp *trans = rtel->value;
- out << trans->targ->id << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
-
- /* The state's default target state. */
- if ( st->defTrans != 0 ) {
- RedTransAp *trans = st->defTrans;
- out << trans->targ->id << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
- }
-
- /* Output one last number so we don't have to figure out when the last
- * entry is and avoid writing a comma. */
- out << 0 << "\n";
- return out;
-}
-
-
-std::ostream &TabCodeGen::TRANS_ACTIONS()
-{
- int totalTrans = 0;
- out << '\t';
- for ( RedStateList::Iter st = redFsm->stateList; st.lte(); st++ ) {
- /* Walk the singles. */
- for ( RedTransList::Iter stel = st->outSingle; stel.lte(); stel++ ) {
- RedTransAp *trans = stel->value;
- TRANS_ACTION( trans ) << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
-
- /* Walk the ranges. */
- for ( RedTransList::Iter rtel = st->outRange; rtel.lte(); rtel++ ) {
- RedTransAp *trans = rtel->value;
- TRANS_ACTION( trans ) << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
-
- /* The state's default index goes next. */
- if ( st->defTrans != 0 ) {
- RedTransAp *trans = st->defTrans;
- TRANS_ACTION( trans ) << ", ";
- if ( ++totalTrans % IALL == 0 )
- out << "\n\t";
- }
- }
-
- /* Output one last number so we don't have to figure out when the last
- * entry is and avoid writing a comma. */
- out << 0 << "\n";
- return out;
-}
-
-std::ostream &TabCodeGen::TRANS_TARGS_WI()
-{
- /* Transitions must be written ordered by their id. */
- RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()];
- for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ )
- transPtrs[trans->id] = trans;
-
- /* Keep a count of the num of items in the array written. */
- out << '\t';
- int totalStates = 0;
- for ( int t = 0; t < redFsm->transSet.length(); t++ ) {
- /* Write out the target state. */
- RedTransAp *trans = transPtrs[t];
- out << trans->targ->id;
- if ( t < redFsm->transSet.length()-1 ) {
- out << ", ";
- if ( ++totalStates % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- delete[] transPtrs;
- return out;
-}
-
-
-std::ostream &TabCodeGen::TRANS_ACTIONS_WI()
-{
- /* Transitions must be written ordered by their id. */
- RedTransAp **transPtrs = new RedTransAp*[redFsm->transSet.length()];
- for ( TransApSet::Iter trans = redFsm->transSet; trans.lte(); trans++ )
- transPtrs[trans->id] = trans;
-
- /* Keep a count of the num of items in the array written. */
- out << '\t';
- int totalAct = 0;
- for ( int t = 0; t < redFsm->transSet.length(); t++ ) {
- /* Write the function for the transition. */
- RedTransAp *trans = transPtrs[t];
- TRANS_ACTION( trans );
- if ( t < redFsm->transSet.length()-1 ) {
- out << ", ";
- if ( ++totalAct % IALL == 0 )
- out << "\n\t";
- }
- }
- out << "\n";
- delete[] transPtrs;
- return out;
-}
-
-void TabCodeGen::LOCATE_TRANS()
-{
- out <<
- " _keys = " << ARR_OFF( K(), KO() + "[" + CS() + "]" ) << ";\n"
- " _trans = " << IO() << "[" << CS() << "];\n"
- "\n"
- " _klen = " << SL() << "[" << CS() << "];\n"
- " if ( _klen > 0 ) {\n"
- " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_lower = _keys;\n"
- " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_mid;\n"
- " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_upper = _keys + _klen - 1;\n"
- " while (1) {\n"
- " if ( _upper < _lower )\n"
- " break;\n"
- "\n"
- " _mid = _lower + ((_upper-_lower) >> 1);\n"
- " if ( " << GET_WIDE_KEY() << " < *_mid )\n"
- " _upper = _mid - 1;\n"
- " else if ( " << GET_WIDE_KEY() << " > *_mid )\n"
- " _lower = _mid + 1;\n"
- " else {\n"
- " _trans += (_mid - _keys);\n"
- " goto _match;\n"
- " }\n"
- " }\n"
- " _keys += _klen;\n"
- " _trans += _klen;\n"
- " }\n"
- "\n"
- " _klen = " << RL() << "[" << CS() << "];\n"
- " if ( _klen > 0 ) {\n"
- " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_lower = _keys;\n"
- " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_mid;\n"
- " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_upper = _keys + (_klen<<1) - 2;\n"
- " while (1) {\n"
- " if ( _upper < _lower )\n"
- " break;\n"
- "\n"
- " _mid = _lower + (((_upper-_lower) >> 1) & ~1);\n"
- " if ( " << GET_WIDE_KEY() << " < _mid[0] )\n"
- " _upper = _mid - 2;\n"
- " else if ( " << GET_WIDE_KEY() << " > _mid[1] )\n"
- " _lower = _mid + 2;\n"
- " else {\n"
- " _trans += ((_mid - _keys)>>1);\n"
- " goto _match;\n"
- " }\n"
- " }\n"
- " _trans += _klen;\n"
- " }\n"
- "\n";
-}
-
-void TabCodeGen::GOTO( ostream &ret, int gotoDest, bool inFinish )
-{
- ret << "{" << CS() << " = " << gotoDest << "; " <<
- CTRL_FLOW() << "goto _again;}";
-}
-
-void TabCodeGen::GOTO_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish )
-{
- ret << "{" << CS() << " = (";
- INLINE_LIST( ret, ilItem->children, 0, inFinish );
- ret << "); " << CTRL_FLOW() << "goto _again;}";
-}
-
-void TabCodeGen::CURS( ostream &ret, bool inFinish )
-{
- ret << "(_ps)";
-}
-
-void TabCodeGen::TARGS( ostream &ret, bool inFinish, int targState )
-{
- ret << "(" << CS() << ")";
-}
-
-void TabCodeGen::NEXT( ostream &ret, int nextDest, bool inFinish )
-{
- ret << CS() << " = " << nextDest << ";";
-}
-
-void TabCodeGen::NEXT_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish )
-{
- ret << CS() << " = (";
- INLINE_LIST( ret, ilItem->children, 0, inFinish );
- ret << ");";
-}
-
-void TabCodeGen::CALL( ostream &ret, int callDest, int targState, bool inFinish )
-{
- ret << "{" << STACK() << "[" << TOP() << "++] = " << CS() << "; " << CS() << " = " <<
- callDest << "; " << CTRL_FLOW() << "goto _again;}";
-}
-
-void TabCodeGen::CALL_EXPR( ostream &ret, InlineItem *ilItem, int targState, bool inFinish )
-{
- ret << "{" << STACK() << "[" << TOP() << "++] = " << CS() << "; " << CS() << " = (";
- INLINE_LIST( ret, ilItem->children, targState, inFinish );
- ret << "); " << CTRL_FLOW() << "goto _again;}";
-}
-
-void TabCodeGen::RET( ostream &ret, bool inFinish )
-{
- ret << "{" << CS() << " = " << STACK() << "[--" <<
- TOP() << "]; " << CTRL_FLOW() << "goto _again;}";
-}
-
-void TabCodeGen::BREAK( ostream &ret, int targState )
-{
- outLabelUsed = true;
- ret << CTRL_FLOW() << "goto _out;";
-}
-
-void TabCodeGen::writeOutData()
-{
- /* If there are any transtion functions then output the array. If there
- * are none, don't bother emitting an empty array that won't be used. */
- if ( anyActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActArrItem), A() );
- ACTIONS_ARRAY();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- if ( anyConditions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxCondOffset), CO() );
- COND_OFFSETS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxCondLen), CL() );
- COND_LENS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( WIDE_ALPH_TYPE(), CK() );
- COND_KEYS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxCondSpaceId), C() );
- COND_SPACES();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- OPEN_ARRAY( ARRAY_TYPE(maxKeyOffset), KO() );
- KEY_OFFSETS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( WIDE_ALPH_TYPE(), K() );
- KEYS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxSingleLen), SL() );
- SINGLE_LENS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxRangeLen), RL() );
- RANGE_LENS();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxIndexOffset), IO() );
- INDEX_OFFSETS();
- CLOSE_ARRAY() <<
- "\n";
-
- if ( useIndicies ) {
- OPEN_ARRAY( ARRAY_TYPE(maxIndex), I() );
- INDICIES();
- CLOSE_ARRAY() <<
- "\n";
-
- OPEN_ARRAY( ARRAY_TYPE(maxState), TT() );
- TRANS_TARGS_WI();
- CLOSE_ARRAY() <<
- "\n";
-
- if ( anyActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), TA() );
- TRANS_ACTIONS_WI();
- CLOSE_ARRAY() <<
- "\n";
- }
- }
- else {
- OPEN_ARRAY( ARRAY_TYPE(maxState), TT() );
- TRANS_TARGS();
- CLOSE_ARRAY() <<
- "\n";
-
- if ( anyActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), TA() );
- TRANS_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
- }
-
- if ( anyToStateActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), TSA() );
- TO_STATE_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- if ( anyFromStateActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), FSA() );
- FROM_STATE_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- if ( anyEofActions() ) {
- OPEN_ARRAY( ARRAY_TYPE(maxActionLoc), EA() );
- EOF_ACTIONS();
- CLOSE_ARRAY() <<
- "\n";
- }
-
- STATIC_VAR( "int", START() ) << " = " << START_STATE_ID() << ";\n"
- "\n";
-
- if ( cgd->writeFirstFinal ) {
- STATIC_VAR( "int" , FIRST_FINAL() ) << " = " << FIRST_FINAL_STATE() << ";\n"
- "\n";
- }
-
- if ( cgd->writeErr ) {
- STATIC_VAR( "int", ERROR() ) << " = " << ERROR_STATE() << ";\n"
- "\n";
- }
-}
-
-void TabCodeGen::COND_TRANSLATE()
-{
- out <<
- " _widec = " << GET_KEY() << ";\n"
- " _klen = " << CL() << "[" << CS() << "];\n"
- " _keys = " << ARR_OFF( CK(), "(" + CO() + "[" + CS() + "]*2)" ) << ";\n"
- " if ( _klen > 0 ) {\n"
- " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_lower = _keys;\n"
- " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_mid;\n"
- " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_upper = _keys + (_klen<<1) - 2;\n"
- " while (1) {\n"
- " if ( _upper < _lower )\n"
- " break;\n"
- "\n"
- " _mid = _lower + (((_upper-_lower) >> 1) & ~1);\n"
- " if ( " << GET_WIDE_KEY() << " < _mid[0] )\n"
- " _upper = _mid - 2;\n"
- " else if ( " << GET_WIDE_KEY() << " > _mid[1] )\n"
- " _lower = _mid + 2;\n"
- " else {\n"
- " switch ( " << C() << "[" << CO() << "[" << CS() << "]"
- " + ((_mid - _keys)>>1)] ) {\n";
-
- for ( CondSpaceList::Iter csi = cgd->condSpaceList; csi.lte(); csi++ ) {
- CondSpace *condSpace = csi;
- out << " case " << condSpace->condSpaceId << ": {\n";
- out << TABS(2) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" <<
- KEY(condSpace->baseKey) << " + (" << GET_KEY() <<
- " - " << KEY(keyOps->minKey) << "));\n";
-
- for ( CondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) {
- out << TABS(2) << "if ( ";
- CONDITION( out, *csi );
- Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize());
- out << " ) _widec += " << condValOffset << ";\n";
- }
-
- out <<
- " break;\n"
- " }\n";
- }
-
- SWITCH_DEFAULT();
-
- out <<
- " }\n"
- " break;\n"
- " }\n"
- " }\n"
- " }\n"
- "\n";
-}
-
-void TabCodeGen::writeOutExec()
-{
- outLabelUsed = false;
-
- out <<
- " {\n"
- " int _klen";
-
- if ( anyRegCurStateRef() )
- out << ", _ps";
-
- out <<
- ";\n"
- " " << UINT() << " _trans;\n";
-
- if ( anyConditions() )
- out << " " << WIDE_ALPH_TYPE() << " _widec;\n";
-
- if ( anyToStateActions() || anyRegActions() || anyFromStateActions() ) {
- out <<
- " " << PTR_CONST() << ARRAY_TYPE(maxActArrItem) << POINTER() << "_acts;\n"
- " " << UINT() << " _nacts;\n";
- }
-
- out <<
- " " << PTR_CONST() << WIDE_ALPH_TYPE() << POINTER() << "_keys;\n"
- "\n";
-
- if ( cgd->hasEnd ) {
- outLabelUsed = true;
- out <<
- " if ( " << P() << " == " << PE() << " )\n"
- " goto _out;\n";
- }
-
- out << "_resume:\n";
-
- if ( redFsm->errState != 0 ) {
- outLabelUsed = true;
- out <<
- " if ( " << CS() << " == " << redFsm->errState->id << " )\n"
- " goto _out;\n";
- }
-
- if ( anyFromStateActions() ) {
- out <<
- " _acts = " << ARR_OFF( A(), FSA() + "[" + CS() + "]" ) << ";\n"
- " _nacts = " << CAST(UINT()) << " *_acts++;\n"
- " while ( _nacts-- > 0 ) {\n"
- " switch ( *_acts++ ) {\n";
- FROM_STATE_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- "\n";
- }
-
- if ( anyConditions() )
- COND_TRANSLATE();
-
- LOCATE_TRANS();
-
- out << "_match:\n";
-
- if ( anyRegCurStateRef() )
- out << " _ps = " << CS() << ";\n";
-
- if ( useIndicies )
- out << " _trans = " << I() << "[_trans];\n";
-
- out <<
- " " << CS() << " = " << TT() << "[_trans];\n"
- "\n";
-
- if ( anyRegActions() ) {
- out <<
- " if ( " << TA() << "[_trans] == 0 )\n"
- " goto _again;\n"
- "\n"
- " _acts = " << ARR_OFF( A(), TA() + "[_trans]" ) << ";\n"
- " _nacts = " << CAST(UINT()) << " *_acts++;\n"
- " while ( _nacts-- > 0 )\n {\n"
- " switch ( *_acts++ )\n {\n";
- ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- "\n";
- }
-
- if ( anyRegActions() || anyActionGotos() || anyActionCalls() || anyActionRets() )
- out << "_again:\n";
-
- if ( anyToStateActions() ) {
- out <<
- " _acts = " << ARR_OFF( A(), TSA() + "[" + CS() + "]" ) << ";\n"
- " _nacts = " << CAST(UINT()) << " *_acts++;\n"
- " while ( _nacts-- > 0 ) {\n"
- " switch ( *_acts++ ) {\n";
- TO_STATE_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- "\n";
- }
-
- if ( cgd->hasEnd ) {
- out <<
- " if ( ++" << P() << " != " << PE() << " )\n"
- " goto _resume;\n";
- }
- else {
- out <<
- " " << P() << " += 1;\n"
- " goto _resume;\n";
- }
-
- if ( outLabelUsed )
- out << " _out: {}\n";
-
- out << " }\n";
-}
-
-
-void TabCodeGen::writeOutEOF()
-{
- if ( anyEofActions() ) {
- out <<
- " {\n"
- " " << PTR_CONST() << ARRAY_TYPE(maxActArrItem) << POINTER() << "_acts = " <<
- ARR_OFF( A(), EA() + "[" + CS() + "]" ) << ";\n"
- " " << UINT() << " _nacts = " << CAST(UINT()) << " *_acts++;\n"
- " while ( _nacts-- > 0 ) {\n"
- " switch ( *_acts++ ) {\n";
- EOF_ACTION_SWITCH();
- SWITCH_DEFAULT() <<
- " }\n"
- " }\n"
- " }\n"
- "\n";
- }
-}
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- * 2004 Eric Ocean <eric.ocean@ampede.com>
- * 2005 Alan West <alan@alanz.com>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef _TABCODEGEN_H
-#define _TABCODEGEN_H
-
-#include <iostream>
-#include "fsmcodegen.h"
-
-/* Forwards. */
-struct CodeGenData;
-struct NameInst;
-struct RedTransAp;
-struct RedStateAp;
-
-/*
- * TabCodeGen
- */
-class TabCodeGen : virtual public FsmCodeGen
-{
-public:
- virtual ~TabCodeGen() { }
- virtual void writeOutData();
- virtual void writeOutExec();
-
-protected:
- std::ostream &TO_STATE_ACTION_SWITCH();
- std::ostream &FROM_STATE_ACTION_SWITCH();
- std::ostream &EOF_ACTION_SWITCH();
- std::ostream &ACTION_SWITCH();
-
- std::ostream &COND_KEYS();
- std::ostream &COND_SPACES();
- std::ostream &KEYS();
- std::ostream &INDICIES();
- std::ostream &COND_OFFSETS();
- std::ostream &KEY_OFFSETS();
- std::ostream &INDEX_OFFSETS();
- std::ostream &COND_LENS();
- std::ostream &SINGLE_LENS();
- std::ostream &RANGE_LENS();
- std::ostream &TO_STATE_ACTIONS();
- std::ostream &FROM_STATE_ACTIONS();
- std::ostream &EOF_ACTIONS();
- std::ostream &TRANS_TARGS();
- std::ostream &TRANS_ACTIONS();
- std::ostream &TRANS_TARGS_WI();
- std::ostream &TRANS_ACTIONS_WI();
- void LOCATE_TRANS();
-
- void COND_TRANSLATE();
-
- void GOTO( ostream &ret, int gotoDest, bool inFinish );
- void CALL( ostream &ret, int callDest, int targState, bool inFinish );
- void NEXT( ostream &ret, int nextDest, bool inFinish );
- void GOTO_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish );
- void NEXT_EXPR( ostream &ret, InlineItem *ilItem, bool inFinish );
- void CALL_EXPR( ostream &ret, InlineItem *ilItem, int targState, bool inFinish );
- void CURS( ostream &ret, bool inFinish );
- void TARGS( ostream &ret, bool inFinish, int targState );
- void RET( ostream &ret, bool inFinish );
- void BREAK( ostream &ret, int targState );
-
- virtual std::ostream &TO_STATE_ACTION( RedStateAp *state );
- virtual std::ostream &FROM_STATE_ACTION( RedStateAp *state );
- virtual std::ostream &EOF_ACTION( RedStateAp *state );
- virtual std::ostream &TRANS_ACTION( RedTransAp *trans );
- virtual void calcIndexSize();
- virtual void writeOutEOF();
-};
-
-
-/*
- * CTabCodeGen
- */
-struct CTabCodeGen
- : public TabCodeGen, public CCodeGen
-{
-};
-
-/*
- * DTabCodeGen
- */
-struct DTabCodeGen
- : public TabCodeGen, public DCodeGen
-{
-};
-
-
-#endif /* _TABCODEGEN_H */
+++ /dev/null
-/*
- * Copyright 2001-2007 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#ifndef _XMLPARSE_H
-#define _XMLPARSE_H
-
-#include "vector.h"
-#include "rlcodegen.h"
-#include "gendata.h"
-#include <iostream>
-
-using std::ostream;
-
-struct XMLTagHashPair
-{
- char *name;
- int id;
-};
-
-struct Token
-{
- XMLTag *tag;
- InputLoc loc;
-};
-
-struct InlineItem;
-struct InlineList;
-
-struct LmSwitchVect;
-struct LmSwitchAction;
-
-//#include "xmlpdefs.h"
-
-/* These come from the scanner and point back into the parser. We will borrow
- * them for error reporting. */
-//extern YYSTYPE *yylval;
-//extern YYLTYPE *yylloc;
-
-//int yylex( YYSTYPE *, YYLTYPE *);
-void scannerInit();
-
-extern char *lelNames[];
-
-struct LangEl;
-
-struct Parser
-{
- %%{
- parser Parser;
-
- token TAG_unknown, TAG_ragel, TAG_ragel_def, TAG_host, TAG_state_list,
- TAG_state, TAG_trans_list, TAG_t, TAG_machine, TAG_start_state,
- TAG_action_list, TAG_action_table_list, TAG_action,
- TAG_action_table, TAG_alphtype, TAG_element, TAG_getkey,
- TAG_state_actions, TAG_entry_points, TAG_sub_action,
- TAG_cond_space_list, TAG_cond_space, TAG_cond_list, TAG_c;
-
- # Inline block tokens.
- token TAG_text, TAG_goto, TAG_call, TAG_next, TAG_goto_expr,
- TAG_call_expr, TAG_next_expr, TAG_ret, TAG_pchar, TAG_char,
- TAG_hold, TAG_exec, TAG_holdte, TAG_execte, TAG_curs, TAG_targs,
- TAG_entry, TAG_data, TAG_lm_switch, TAG_init_act, TAG_set_act,
- TAG_set_tokend, TAG_get_tokend, TAG_init_tokstart,
- TAG_set_tokstart, TAG_write, TAG_curstate, TAG_access, TAG_break,
- TAG_option;
-
- interface;
- }%%
-
- Parser( char *fileName )
- : fileName(fileName), sourceFileName(0)
- {
- //pd = new ParseData( fileName, sectionName, sectionLoc );
- }
-
- int token( int id );
- int token( int tokenId, Token &token );
- int token( XMLTag *tag, int col, int line );
-
- /* Report an error encountered by the parser. */
- ostream &error();
- ostream &error( const InputLoc &loc );
- ostream &parser_error( int tokId, Token &token );
-
- /* The name of the root section, this does not change during an include. */
- char *fileName;
-
- /* Collected during parsing. */
- char *sourceFileName;
- char *attrKey;
- char *attrValue;
- int curAction;
- int curActionTable;
- int curTrans;
- int curState;
- int curCondSpace;
- int curStateCond;
-
- CodeGenMap codeGenMap;
-};
-
-#endif /* _XMLPARSE_H */
+++ /dev/null
-/*
- * Copyright 2001-2007 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "xmlparse.h"
-#include "rlcodegen.h"
-#include "common.h"
-#include "gendata.h"
-#include <iostream>
-
-using std::cout;
-using std::ostream;
-using std::istream;
-using std::cerr;
-using std::endl;
-
-Key readKey( char *td, char **end );
-long readOffsetPtr( char *td, char **end );
-unsigned long readLength( char *td );
-
-%%{
-
-parser Parser;
-
-include "xmlparse.kh";
-
-start: tag_ragel;
-start:
- final {
- /* If we get no input the assumption is that the frontend died and
- * emitted an error. */
- gblErrorCount += 1;
- };
-
-tag_ragel: tag_ragel_head host_or_def_list '/' TAG_ragel;
-
-tag_ragel_head: TAG_ragel
- final {
- Attribute *fileNameAttr = $1->tag->findAttr( "filename" );
- if ( fileNameAttr == 0 ) {
- xml_error($1->loc) << "tag <ragel> requires a filename attribute" << endl;
- exit(1);
- }
- else
- sourceFileName = fileNameAttr->value;
-
- Attribute *langAttr = $1->tag->findAttr( "lang" );
- if ( langAttr == 0 )
- xml_error($1->loc) << "tag <ragel> requires a lang attribute" << endl;
- else {
- if ( strcmp( langAttr->value, "C" ) == 0 ) {
- hostLangType = CCode;
- hostLang = &hostLangC;
- }
- else if ( strcmp( langAttr->value, "D" ) == 0 ) {
- hostLangType = DCode;
- hostLang = &hostLangD;
- }
- else if ( strcmp( langAttr->value, "Java" ) == 0 ) {
- hostLangType = JavaCode;
- hostLang = &hostLangJava;
- }
- }
-
- /* Eventually more types will be supported. */
- if ( hostLangType == JavaCode && codeStyle != GenTables ) {
- error() << "java: only the table code style -T0 is "
- "currently supported" << endl;
- }
-
- openOutput( sourceFileName );
- };
-
-host_or_def_list: host_or_def_list host_or_def;
-host_or_def_list: ;
-
-host_or_def: host;
-host_or_def: ragel_def;
-
-host:
- TAG_host '/' TAG_host
- final {
- Attribute *lineAttr = $1->tag->findAttr( "line" );
- if ( lineAttr == 0 )
- xml_error($1->loc) << "tag <host> requires a line attribute" << endl;
- else {
- int line = atoi( lineAttr->value );
- if ( outputFormat == OutCode )
- lineDirective( *outStream, sourceFileName, line );
- }
-
- if ( outputFormat == OutCode )
- *outStream << $3->tag->content;
- };
-
-ragel_def:
- tag_ragel_def_head ragel_def_item_list '/' TAG_ragel_def
- final {
- if ( gblErrorCount == 0 )
- cgd->generate();
- };
-
-tag_ragel_def_head: TAG_ragel_def
- final {
- bool wantComplete = outputFormat != OutGraphvizDot;
-
- char *fsmName = 0;
- Attribute *nameAttr = $1->tag->findAttr( "name" );
- if ( nameAttr != 0 ) {
- fsmName = nameAttr->value;
-
- CodeGenMapEl *mapEl = codeGenMap.find( fsmName );
- if ( mapEl != 0 )
- cgd = mapEl->value;
- else {
- cgd = new CodeGenData( sourceFileName, fsmName, wantComplete );
- codeGenMap.insert( fsmName, cgd );
- }
- }
- else {
- cgd = new CodeGenData( sourceFileName, fsmName, wantComplete );
- }
-
- cgd->writeOps = 0;
- cgd->writeData = false;
- cgd->writeInit = false;
- cgd->writeExec = false;
- cgd->writeEOF = false;
- ::keyOps = &cgd->thisKeyOps;
- };
-
-ragel_def_item_list: ragel_def_item_list ragel_def_item;
-ragel_def_item_list: ;
-
-ragel_def_item: tag_alph_type;
-ragel_def_item: tag_getkey_expr;
-ragel_def_item: tag_access_expr;
-ragel_def_item: tag_curstate_expr;
-ragel_def_item: tag_machine;
-ragel_def_item: tag_write;
-
-tag_alph_type: TAG_alphtype '/' TAG_alphtype
- final {
- if ( ! cgd->setAlphType( $3->tag->content ) )
- xml_error($1->loc) << "tag <alphtype> specifies unknown alphabet type" << endl;
- };
-
-tag_getkey_expr: TAG_getkey inline_list '/' TAG_getkey
- final {
- cgd->getKeyExpr = $2->inlineList;
- };
-
-tag_access_expr: TAG_access inline_list '/' TAG_access
- final {
- cgd->accessExpr = $2->inlineList;
- };
-
-tag_curstate_expr: TAG_curstate inline_list '/' TAG_curstate
- final {
- cgd->curStateExpr = $2->inlineList;
- };
-
-tag_write: TAG_write write_option_list '/' TAG_write
- final {
- Attribute *what = $1->tag->findAttr( "what" );
- if ( what == 0 ) {
- xml_error($1->loc) << "tag <write> requires a what attribute" << endl;
- }
- else {
- if ( strcmp( what->value, "data" ) == 0 )
- cgd->writeData = true;
- else if ( strcmp( what->value, "init" ) == 0 )
- cgd->writeInit = true;
- else if ( strcmp( what->value, "exec" ) == 0 )
- cgd->writeExec = true;
- else if ( strcmp( what->value, "eof" ) == 0 )
- cgd->writeEOF = true;
- }
- };
-
-write_option_list: write_option_list tag_option;
-write_option_list: ;
-
-tag_option: TAG_option '/' TAG_option
- final {
- char *content = $3->tag->content;
- if ( strcmp( content, "noend" ) == 0 )
- cgd->writeOps |= WO_NOEND;
- else if ( strcmp( content, "noerror" ) == 0 )
- cgd->writeOps |= WO_NOERROR;
- else if ( strcmp( content, "noprefix" ) == 0 )
- cgd->writeOps |= WO_NOPREFIX;
- else if ( strcmp( content, "nofinal" ) == 0 )
- cgd->writeOps |= WO_NOFF;
- else {
- warning() << "unrecognized write option" << endl;
- }
- };
-
-tag_machine: tag_machine_head machine_item_list '/' TAG_machine
- final {
- cgd->finishMachine();
- };
-
-tag_machine_head: TAG_machine
- final {
- cgd->createMachine();
- };
-
-machine_item_list: machine_item_list machine_item;
-machine_item_list: ;
-
-machine_item: tag_start_state;
-machine_item: tag_entry_points;
-machine_item: tag_state_list;
-machine_item: tag_action_list;
-machine_item: tag_action_table_list;
-machine_item: tag_cond_space_list;
-
-#
-# States.
-#
-
-tag_start_state: TAG_start_state '/' TAG_start_state
- final {
- unsigned long startState = strtoul( $3->tag->content, 0, 10 );
- cgd->setStartState( startState );
- };
-
-tag_entry_points: TAG_entry_points entry_point_list '/' TAG_entry_points
- final {
- Attribute *errorAttr = $1->tag->findAttr( "error" );
- if ( errorAttr != 0 )
- cgd->setForcedErrorState();
- };
-
-entry_point_list: entry_point_list tag_entry;
-entry_point_list: ;
-
-tag_entry: TAG_entry '/' TAG_entry
- final {
- Attribute *nameAttr = $1->tag->findAttr( "name" );
- if ( nameAttr == 0 ) {
- xml_error($1->loc) << "tag <entry_points>::<entry> "
- "requires a name attribute" << endl;
- }
- else {
- char *data = $3->tag->content;
- unsigned long entry = strtoul( data, &data, 10 );
- cgd->addEntryPoint( nameAttr->value, entry );
- }
- };
-
-tag_state_list: tag_state_list_head state_list '/' TAG_state_list;
-
-tag_state_list_head: TAG_state_list
- final {
- Attribute *lengthAttr = $1->tag->findAttr( "length" );
- if ( lengthAttr == 0 )
- xml_error($1->loc) << "tag <state_list> requires a length attribute" << endl;
- else {
- unsigned long length = strtoul( lengthAttr->value, 0, 10 );
- cgd->initStateList( length );
- curState = 0;
- }
- };
-
-state_list: state_list tag_state;
-state_list: ;
-
-tag_state: TAG_state state_item_list '/' TAG_state
- final {
- Attribute *lengthAttr = $1->tag->findAttr( "final" );
- if ( lengthAttr != 0 )
- cgd->setFinal( curState );
- curState += 1;
- };
-
-state_item_list: state_item_list state_item;
-state_item_list: ;
-
-state_item: tag_state_actions;
-state_item: tag_state_cond_list;
-state_item: tag_trans_list;
-
-tag_state_actions: TAG_state_actions '/' TAG_state_actions
- final {
- char *ad = $3->tag->content;
-
- long toStateAction = readOffsetPtr( ad, &ad );
- long fromStateAction = readOffsetPtr( ad, &ad );
- long eofAction = readOffsetPtr( ad, &ad );
-
- cgd->setStateActions( curState, toStateAction,
- fromStateAction, eofAction );
- };
-
-tag_state_cond_list: tag_state_cond_list_head state_cond_list '/' TAG_cond_list;
-
-tag_state_cond_list_head: TAG_cond_list
- final {
- Attribute *lengthAttr = $1->tag->findAttr( "length" );
- if ( lengthAttr == 0 )
- xml_error($1->loc) << "tag <cond_list> requires a length attribute" << endl;
- else {
- ulong length = readLength( lengthAttr->value );
- cgd->initStateCondList( curState, length );
- curStateCond = 0;
- }
- };
-
-state_cond_list: state_cond_list state_cond;
-state_cond_list: ;
-
-state_cond: TAG_c '/' TAG_c
- final {
- char *td = $3->tag->content;
- Key lowKey = readKey( td, &td );
- Key highKey = readKey( td, &td );
- long condId = readOffsetPtr( td, &td );
- cgd->addStateCond( curState, lowKey, highKey, condId );
- };
-
-tag_trans_list: tag_trans_list_head trans_list '/' TAG_trans_list
- final {
- cgd->finishTransList( curState );
- };
-
-tag_trans_list_head: TAG_trans_list
- final {
- Attribute *lengthAttr = $1->tag->findAttr( "length" );
- if ( lengthAttr == 0 )
- xml_error($1->loc) << "tag <trans_list> requires a length attribute" << endl;
- else {
- unsigned long length = strtoul( lengthAttr->value, 0, 10 );
- cgd->initTransList( curState, length );
- curTrans = 0;
- }
- };
-
-trans_list: trans_list tag_trans;
-trans_list: ;
-
-tag_trans: TAG_t '/' TAG_t
- final {
- char *td = $3->tag->content;
- Key lowKey = readKey( td, &td );
- Key highKey = readKey( td, &td );
- long targ = readOffsetPtr( td, &td );
- long action = readOffsetPtr( td, &td );
-
- cgd->newTrans( curState, curTrans++, lowKey, highKey, targ, action );
- };
-
-#
-# Action Lists.
-#
-
-tag_action_list: tag_action_list_head action_list '/' TAG_action_list;
-
-tag_action_list_head: TAG_action_list
- final {
- Attribute *lengthAttr = $1->tag->findAttr( "length" );
- if ( lengthAttr == 0 )
- xml_error($1->loc) << "tag <action_list> requires a length attribute" << endl;
- else {
- unsigned long length = strtoul( lengthAttr->value, 0, 10 );
- cgd->initActionList( length );
- curAction = 0;
- }
- };
-
-action_list: action_list tag_action;
-action_list: ;
-
-#
-# Actions.
-#
-
-tag_action: TAG_action inline_list '/' TAG_action
- final {
- Attribute *lineAttr = $1->tag->findAttr( "line" );
- Attribute *colAttr = $1->tag->findAttr( "col" );
- Attribute *nameAttr = $1->tag->findAttr( "name" );
- if ( lineAttr == 0 || colAttr == 0)
- xml_error($1->loc) << "tag <action> requires a line and col attributes" << endl;
- else {
- unsigned long line = strtoul( lineAttr->value, 0, 10 );
- unsigned long col = strtoul( colAttr->value, 0, 10 );
-
- char *name = 0;
- if ( nameAttr != 0 )
- name = nameAttr->value;
-
- cgd->newAction( curAction++, name, line, col, $2->inlineList );
- }
- };
-
-nonterm inline_list
-{
- InlineList *inlineList;
-};
-
-
-inline_list: inline_list inline_item
- final {
- /* Append the item to the list, return the list. */
- $1->inlineList->append( $2->inlineItem );
- $$->inlineList = $1->inlineList;
- };
-
-inline_list:
- final {
- /* Start with empty list. */
- $$->inlineList = new InlineList;
- };
-
-nonterm inline_item_type
-{
- InlineItem *inlineItem;
-};
-
-nonterm inline_item uses inline_item_type;
-
-inline_item: tag_text final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_goto final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_call final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_next final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_goto_expr final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_call_expr final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_next_expr final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_ret final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_break final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_pchar final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_char final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_hold final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_exec final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_holdte final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_execte final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_curs final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_targs final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_il_entry final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_init_tokstart final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_init_act final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_get_tokend final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_set_tokstart final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_set_tokend final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_set_act final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_sub_action final { $$->inlineItem = $1->inlineItem; };
-inline_item: tag_lm_switch final { $$->inlineItem = $1->inlineItem; };
-
-nonterm tag_text uses inline_item_type;
-nonterm tag_goto uses inline_item_type;
-nonterm tag_call uses inline_item_type;
-nonterm tag_next uses inline_item_type;
-nonterm tag_goto_expr uses inline_item_type;
-nonterm tag_call_expr uses inline_item_type;
-nonterm tag_next_expr uses inline_item_type;
-nonterm tag_ret uses inline_item_type;
-nonterm tag_break uses inline_item_type;
-nonterm tag_pchar uses inline_item_type;
-nonterm tag_char uses inline_item_type;
-nonterm tag_hold uses inline_item_type;
-nonterm tag_exec uses inline_item_type;
-nonterm tag_holdte uses inline_item_type;
-nonterm tag_execte uses inline_item_type;
-nonterm tag_curs uses inline_item_type;
-nonterm tag_targs uses inline_item_type;
-nonterm tag_il_entry uses inline_item_type;
-nonterm tag_init_tokstart uses inline_item_type;
-nonterm tag_init_act uses inline_item_type;
-nonterm tag_get_tokend uses inline_item_type;
-nonterm tag_set_tokstart uses inline_item_type;
-nonterm tag_set_tokend uses inline_item_type;
-nonterm tag_set_act uses inline_item_type;
-nonterm tag_sub_action uses inline_item_type;
-nonterm tag_lm_switch uses inline_item_type;
-
-tag_text: TAG_text '/' TAG_text
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::Text );
- $$->inlineItem->data = $3->tag->content;
- };
-
-tag_goto: TAG_goto '/' TAG_goto
- final {
- int targ = strtol( $3->tag->content, 0, 10 );
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::Goto );
- $$->inlineItem->targId = targ;
- };
-
-tag_call: TAG_call '/' TAG_call
- final {
- int targ = strtol( $3->tag->content, 0, 10 );
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::Call );
- $$->inlineItem->targId = targ;
- };
-
-tag_next: TAG_next '/' TAG_next
- final {
- int targ = strtol( $3->tag->content, 0, 10 );
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::Next );
- $$->inlineItem->targId = targ;
- };
-
-tag_goto_expr: TAG_goto_expr inline_list '/' TAG_goto_expr
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::GotoExpr );
- $$->inlineItem->children = $2->inlineList;
- };
-
-tag_call_expr: TAG_call_expr inline_list '/' TAG_call_expr
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::CallExpr );
- $$->inlineItem->children = $2->inlineList;
- };
-
-tag_next_expr: TAG_next_expr inline_list '/' TAG_next_expr
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::NextExpr );
- $$->inlineItem->children = $2->inlineList;
- };
-
-tag_ret: TAG_ret '/' TAG_ret
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::Ret );
- };
-
-tag_break: TAG_break '/' TAG_break
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::Break );
- };
-
-tag_pchar: TAG_pchar '/' TAG_pchar
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::PChar );
- };
-
-tag_char: TAG_char '/' TAG_char
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::Char );
- };
-
-tag_hold: TAG_hold '/' TAG_hold
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::Hold );
- };
-
-tag_exec: TAG_exec inline_list '/' TAG_exec
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::Exec );
- $$->inlineItem->children = $2->inlineList;
- };
-
-tag_holdte: TAG_holdte '/' TAG_holdte
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::HoldTE );
- };
-
-tag_execte: TAG_execte inline_list '/' TAG_execte
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::ExecTE );
- $$->inlineItem->children = $2->inlineList;
- };
-
-tag_curs: TAG_curs '/' TAG_curs
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::Curs );
- };
-
-tag_targs: TAG_targs '/' TAG_targs
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::Targs );
- };
-
-tag_il_entry: TAG_entry '/' TAG_entry
- final {
- int targ = strtol( $3->tag->content, 0, 10 );
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::Entry );
- $$->inlineItem->targId = targ;
- };
-
-tag_init_tokstart: TAG_init_tokstart '/' TAG_init_tokstart
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::LmInitTokStart );
- };
-
-tag_init_act: TAG_init_act '/' TAG_init_act
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::LmInitAct );
- };
-
-tag_get_tokend: TAG_get_tokend '/' TAG_get_tokend
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::LmGetTokEnd );
- };
-
-tag_set_tokstart: TAG_set_tokstart '/' TAG_set_tokstart
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::LmSetTokStart );
- cgd->hasLongestMatch = true;
- };
-
-tag_set_tokend: TAG_set_tokend '/' TAG_set_tokend
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::LmSetTokEnd );
- $$->inlineItem->offset = strtol( $3->tag->content, 0, 10 );
- };
-
-tag_set_act: TAG_set_act '/' TAG_set_act
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::LmSetActId );
- $$->inlineItem->lmId = strtol( $3->tag->content, 0, 10 );
- };
-
-tag_sub_action: TAG_sub_action inline_list '/' TAG_sub_action
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::SubAction );
- $$->inlineItem->children = $2->inlineList;
- };
-
-# Action switches.
-tag_lm_switch: TAG_lm_switch lm_action_list '/' TAG_lm_switch
- final {
- bool handlesError = false;
- Attribute *handlesErrorAttr = $1->tag->findAttr( "handles_error" );
- if ( handlesErrorAttr != 0 )
- handlesError = true;
-
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::LmSwitch );
- $$->inlineItem->children = $2->inlineList;
- $$->inlineItem->handlesError = handlesError;
- };
-
-nonterm lm_action_list
-{
- InlineList *inlineList;
-};
-
-lm_action_list: lm_action_list tag_inline_action
- final {
- $$->inlineList = $1->inlineList;
- $$->inlineList->append( $2->inlineItem );
- };
-lm_action_list:
- final {
- $$->inlineList = new InlineList;
- };
-
-nonterm tag_inline_action uses inline_item_type;
-
-tag_inline_action: TAG_sub_action inline_list '/' TAG_sub_action
- final {
- $$->inlineItem = new InlineItem( InputLoc(), InlineItem::SubAction );
- $$->inlineItem->children = $2->inlineList;
-
- Attribute *idAttr = $1->tag->findAttr( "id" );
- if ( idAttr != 0 ) {
- unsigned long id = strtoul( idAttr->value, 0, 10 );
- $$->inlineItem->lmId = id;
- }
- };
-
-#
-# Lists of Actions.
-#
-
-tag_action_table_list:
- tag_action_table_list_head action_table_list '/' TAG_action_table_list;
-
-tag_action_table_list_head: TAG_action_table_list
- final {
- Attribute *lengthAttr = $1->tag->findAttr( "length" );
- if ( lengthAttr == 0 ) {
- xml_error($1->loc) << "tag <action_table_list> requires "
- "a length attribute" << endl;
- }
- else {
- unsigned long length = strtoul( lengthAttr->value, 0, 10 );
- cgd->initActionTableList( length );
- curActionTable = 0;
- }
- };
-
-action_table_list: action_table_list tag_action_table;
-action_table_list: ;
-
-tag_action_table: TAG_action_table '/' TAG_action_table
- final {
- /* Find the length of the action table. */
- Attribute *lengthAttr = $1->tag->findAttr( "length" );
- if ( lengthAttr == 0 )
- xml_error($1->loc) << "tag <at> requires a length attribute" << endl;
- else {
- unsigned long length = strtoul( lengthAttr->value, 0, 10 );
-
- /* Collect the action table. */
- RedAction *redAct = cgd->allActionTables + curActionTable;
- redAct->actListId = curActionTable;
- redAct->key.setAsNew( length );
- char *ptr = $3->tag->content;
- int pos = 0;
- while ( *ptr != 0 ) {
- unsigned long actionId = strtoul( ptr, &ptr, 10 );
- redAct->key[pos].key = 0;
- redAct->key[pos].value = cgd->allActions+actionId;
- pos += 1;
- }
-
- /* Insert into the action table map. */
- cgd->redFsm->actionMap.insert( redAct );
- }
-
- curActionTable += 1;
- };
-
-#
-# Conditions.
-#
-
-tag_cond_space_list: tag_cond_space_list_head cond_space_list '/' TAG_cond_space_list;
-
-tag_cond_space_list_head: TAG_cond_space_list
- final {
- Attribute *lengthAttr = $1->tag->findAttr( "length" );
- if ( lengthAttr == 0 ) {
- xml_error($1->loc) << "tag <cond_space_list> "
- "requires a length attribute" << endl;
- }
- else {
- ulong length = readLength( lengthAttr->value );
- cgd->initCondSpaceList( length );
- curCondSpace = 0;
- }
- };
-
-cond_space_list: cond_space_list tag_cond_space;
-cond_space_list: tag_cond_space;
-
-tag_cond_space: TAG_cond_space '/' TAG_cond_space
- final {
- Attribute *lengthAttr = $1->tag->findAttr( "length" );
- Attribute *idAttr = $1->tag->findAttr( "id" );
- if ( lengthAttr == 0 )
- xml_error($1->loc) << "tag <cond_space> requires a length attribute" << endl;
- else {
- if ( lengthAttr == 0 )
- xml_error($1->loc) << "tag <cond_space> requires an id attribute" << endl;
- else {
- unsigned long condSpaceId = strtoul( idAttr->value, 0, 10 );
- ulong length = readLength( lengthAttr->value );
-
- char *td = $3->tag->content;
- Key baseKey = readKey( td, &td );
-
- cgd->newCondSpace( curCondSpace, condSpaceId, baseKey );
- for ( ulong a = 0; a < length; a++ ) {
- long actionOffset = readOffsetPtr( td, &td );
- cgd->condSpaceItem( curCondSpace, actionOffset );
- }
- curCondSpace += 1;
- }
- }
- };
-
-}%%
-
-unsigned long readLength( char *td )
-{
- return strtoul( td, 0, 10 );
-}
-
-Key readKey( char *td, char **end )
-{
- if ( keyOps->isSigned )
- return Key( strtol( td, end, 10 ) );
- else
- return Key( strtoul( td, end, 10 ) );
-}
-
-long readOffsetPtr( char *td, char **end )
-{
- while ( *td == ' ' || *td == '\t' )
- td++;
-
- if ( *td == 'x' ) {
- if ( end != 0 )
- *end = td + 1;
- return -1;
- }
-
- return strtol( td, end, 10 );
-}
-
-ostream &Parser::error()
-{
- gblErrorCount += 1;
- cerr << PROGNAME ": ";
- return cerr;
-}
-
-ostream &Parser::error( const InputLoc &loc )
-{
- gblErrorCount += 1;
- assert( fileName != 0 );
- cerr << fileName << ":" << loc.line << ":" << loc.col << ": ";
- return cerr;
-}
-
-ostream &Parser::parser_error( int tokId, Token &token )
-{
- gblErrorCount += 1;
- assert( fileName != 0 );
- cerr << fileName << ":" << token.loc.line << ":" << token.loc.col;
- if ( token.tag != 0 ) {
- if ( token.tag->tagId == 0 )
- cerr << ": at unknown tag";
- else
- cerr << ": at tag <" << token.tag->tagId->name << ">";
- }
- cerr << ": ";
-
- return cerr;
-}
-
-int Parser::token( int tokenId, Token &tok )
-{
- int res = parseLangEl( tokenId, tok );
- if ( res < 0 ) {
- parser_error( tokenId, tok ) << "parse error" << endl;
- exit(1);
- }
- return res;
-}
-
-int Parser::token( int tokenId )
-{
- Token tok;
- tok.tag = 0;
- return token( tokenId, tok );
-}
-
-int Parser::token( XMLTag *tag, int col, int line )
-{
- Token tok;
- tok.loc.col = col;
- tok.loc.line = line;
- tok.tag = tag;
-
- if ( tag->type == XMLTag::Close ) {
- int res = token( '/', tok );
- if ( res < 0 )
- return res;
- }
-
- tok.tag = tag;
- return token( tag->tagId != 0 ? tag->tagId->id : TAG_unknown, tok );
-}
+++ /dev/null
-/*
- * Copyright 2005-2006 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-%{
-
-#include <iostream>
-#include <stdlib.h>
-#include <limits.h>
-#include <errno.h>
-#include "rlcodegen.h"
-#include "vector.h"
-#include "xmlparse.h"
-#include "gendata.h"
-
-using std::cerr;
-using std::endl;
-
-char *sourceFileName;
-char *attrKey;
-char *attrValue;
-int curAction;
-int curActionTable;
-int curTrans;
-int curState;
-int curCondSpace;
-int curStateCond;
-
-Key readKey( char *td, char **end );
-long readOffsetPtr( char *td, char **end );
-unsigned long readLength( char *td );
-
-CodeGenMap codeGenMap;
-
-%}
-
-%pure-parser
-
-%union {
- /* General data types. */
- char c;
- char *data;
- int integer;
- AttrList *attrList;
-
- /* Inline parse tree items. */
- InlineItem *ilitem;
- InlineList *illist;
-}
-
-%token TAG_unknown
-%token TAG_ragel
-%token TAG_ragel_def
-%token TAG_host
-%token TAG_state_list
-%token TAG_state
-%token TAG_trans_list
-%token TAG_t
-%token TAG_machine
-%token TAG_start_state
-%token TAG_action_list
-%token TAG_action_table_list
-%token TAG_action
-%token TAG_action_table
-%token TAG_alphtype
-%token TAG_element
-%token TAG_getkey
-%token TAG_state_actions
-%token TAG_entry_points
-%token TAG_sub_action
-%token TAG_cond_space_list
-%token TAG_cond_space
-%token TAG_cond_list
-%token TAG_c
-
-/* Inline block tokens. */
-%token TAG_text
-%token TAG_goto
-%token TAG_call
-%token TAG_next
-%token TAG_goto_expr
-%token TAG_call_expr
-%token TAG_next_expr
-%token TAG_ret
-%token TAG_pchar
-%token TAG_char
-%token TAG_hold
-%token TAG_exec
-%token TAG_holdte
-%token TAG_execte
-%token TAG_curs
-%token TAG_targs
-%token TAG_entry
-%token TAG_data
-%token TAG_lm_switch
-%token TAG_init_act
-%token TAG_set_act
-%token TAG_set_tokend
-%token TAG_get_tokend
-%token TAG_init_tokstart
-%token TAG_set_tokstart
-%token TAG_write
-%token TAG_curstate
-%token TAG_access
-%token TAG_break
-%token TAG_option
-
-%token <data> XML_Word
-%token <data> XML_Literal
-%type <attrList> AttributeList
-
-%type <illist> InlineList
-%type <ilitem> InlineItem
-%type <illist> LmActionList
-
-%type <ilitem> TagText
-%type <ilitem> TagGoto
-%type <ilitem> TagCall
-%type <ilitem> TagNext
-%type <ilitem> TagGotoExpr
-%type <ilitem> TagCallExpr
-%type <ilitem> TagNextExpr
-%type <ilitem> TagRet
-%type <ilitem> TagBreak
-%type <ilitem> TagPChar
-%type <ilitem> TagChar
-%type <ilitem> TagHold
-%type <ilitem> TagExec
-%type <ilitem> TagHoldTE
-%type <ilitem> TagExecTE
-%type <ilitem> TagCurs
-%type <ilitem> TagTargs
-%type <ilitem> TagIlEntry
-%type <ilitem> TagLmSwitch
-%type <ilitem> TagLmSetActId
-%type <ilitem> TagLmGetTokEnd
-%type <ilitem> TagLmSetTokEnd
-%type <ilitem> TagLmInitTokStart
-%type <ilitem> TagLmInitAct
-%type <ilitem> TagLmSetTokStart
-%type <ilitem> TagInlineAction
-%type <ilitem> TagSubAction
-
-%%
-
-/* Input is any number of input sections. An empty file is accepted. */
-input:
- TagRagel |
- /* Nothing */ {
- /* Assume the frontend died if we get no input. It will emit an error.
- * Cause us to return an error code. */
- gblErrorCount += 1;
- };
-
-TagRagel:
- TagRagelHead
- HostOrDefList
- '<' '/' TAG_ragel '>';
-
-TagRagelHead:
- '<' TAG_ragel AttributeList '>' {
- Attribute *fileNameAttr = $3->find( "filename" );
- if ( fileNameAttr == 0 )
- xml_error(@2) << "tag <ragel> requires a filename attribute" << endl;
- else
- sourceFileName = fileNameAttr->value;
-
- Attribute *langAttr = $3->find( "lang" );
- if ( langAttr == 0 )
- xml_error(@2) << "tag <ragel> requires a lang attribute" << endl;
- else {
- if ( strcmp( langAttr->value, "C" ) == 0 ) {
- hostLangType = CCode;
- hostLang = &hostLangC;
- }
- else if ( strcmp( langAttr->value, "D" ) == 0 ) {
- hostLangType = DCode;
- hostLang = &hostLangD;
- }
- else if ( strcmp( langAttr->value, "Java" ) == 0 ) {
- hostLangType = JavaCode;
- hostLang = &hostLangJava;
- }
- }
-
- /* Eventually more types will be supported. */
- if ( hostLangType == JavaCode && codeStyle != GenTables ) {
- error() << "java: only the table code style -T0 is "
- "currently supported" << endl;
- }
-
- openOutput( sourceFileName );
- };
-
-AttributeList:
- AttributeList Attribute {
- $$ = $1;
- $$->append( Attribute( attrKey, attrValue ) );
- } |
- /* Nothing */ {
- $$ = new AttrList;
- };
-
-Attribute:
- XML_Word '=' XML_Literal {
- attrKey = $1;
- attrValue = $3;
- };
-
-HostOrDefList:
- HostOrDefList HostOrDef |
- /* Nothing */;
-
-HostOrDef:
- TagHost | TagRagelDef;
-
-TagHost:
- TagHostHead
- '<' '/' TAG_host '>' {
- if ( outputFormat == OutCode )
- *outStream << xmlData.data;
- };
-
-TagHostHead:
- '<' TAG_host AttributeList '>' {
- Attribute *lineAttr = $3->find( "line" );
- if ( lineAttr == 0 )
- xml_error(@2) << "tag <host> requires a line attribute" << endl;
- else {
- int line = atoi( lineAttr->value );
- if ( outputFormat == OutCode )
- lineDirective( *outStream, sourceFileName, line );
- }
- };
-
-TagRagelDef:
- RagelDefHead
- RagelDefItemList
- '<' '/' TAG_ragel_def '>' {
- if ( gblErrorCount == 0 )
- cgd->generate();
- };
-
-RagelDefHead:
- '<' TAG_ragel_def AttributeList '>' {
- bool wantComplete = outputFormat != OutGraphvizDot;
-
- char *fsmName = 0;
- Attribute *nameAttr = $3->find( "name" );
- if ( nameAttr != 0 ) {
- fsmName = nameAttr->value;
-
- CodeGenMapEl *mapEl = codeGenMap.find( fsmName );
- if ( mapEl != 0 )
- cgd = mapEl->value;
- else {
- cgd = new CodeGenData( sourceFileName, fsmName, wantComplete );
- codeGenMap.insert( fsmName, cgd );
- }
- }
- else {
- cgd = new CodeGenData( sourceFileName, fsmName, wantComplete );
- }
-
- cgd->writeOps = 0;
- cgd->writeData = false;
- cgd->writeInit = false;
- cgd->writeExec = false;
- cgd->writeEOF = false;
- ::keyOps = &cgd->thisKeyOps;
- };
-
-RagelDefItemList:
- RagelDefItemList RagelDefItem |
- /* Nothing */;
-
-RagelDefItem:
- TagAlphType |
- TagGetKeyExpr |
- TagAccessExpr |
- TagCurStateExpr |
- TagMachine |
- TagWrite;
-
-TagWrite:
- '<' TAG_write AttributeList '>'
- OptionList
- '<' '/' TAG_write '>' {
- Attribute *what = $3->find( "what" );
- if ( what == 0 ) {
- xml_error(@2) << "tag <write> requires a what attribute" << endl;
- }
- else {
- if ( strcmp( what->value, "data" ) == 0 )
- cgd->writeData = true;
- else if ( strcmp( what->value, "init" ) == 0 )
- cgd->writeInit = true;
- else if ( strcmp( what->value, "exec" ) == 0 )
- cgd->writeExec = true;
- else if ( strcmp( what->value, "eof" ) == 0 )
- cgd->writeEOF = true;
- }
- };
-
-OptionList:
- OptionList TagOption |
- /* Nothing */;
-
-TagOption:
- '<' TAG_option '>'
- '<' '/' TAG_option '>' {
- if ( strcmp( xmlData.data, "noend" ) == 0 )
- cgd->writeOps |= WO_NOEND;
- else if ( strcmp( xmlData.data, "noerror" ) == 0 )
- cgd->writeOps |= WO_NOERROR;
- else if ( strcmp( xmlData.data, "noprefix" ) == 0 )
- cgd->writeOps |= WO_NOPREFIX;
- else if ( strcmp( xmlData.data, "nofinal" ) == 0 )
- cgd->writeOps |= WO_NOFF;
- else {
- warning() << "unrecognized write option" << endl;
- }
- };
-
-
-TagAlphType:
- '<' TAG_alphtype '>'
- '<' '/' TAG_alphtype '>' {
- if ( ! cgd->setAlphType( xmlData.data ) )
- xml_error(@2) << "tag <alphtype> specifies unknown alphabet type" << endl;
- };
-
-TagGetKeyExpr:
- '<' TAG_getkey '>'
- InlineList
- '<' '/' TAG_getkey '>' {
- cgd->getKeyExpr = $4;
- };
-
-TagAccessExpr:
- '<' TAG_access '>'
- InlineList
- '<' '/' TAG_access '>' {
- cgd->accessExpr = $4;
- };
-
-TagCurStateExpr:
- '<' TAG_curstate '>'
- InlineList
- '<' '/' TAG_curstate '>' {
- cgd->curStateExpr = $4;
- };
-
-TagMachine:
- TagMachineHead
- MachineItemList
- '<' '/' TAG_machine '>' {
- cgd->finishMachine();
- };
-
-TagMachineHead:
- '<' TAG_machine '>' {
- cgd->createMachine();
- };
-
-MachineItemList:
- MachineItemList MachineItem |
- /* Nothing */;
-
-MachineItem:
- TagStartState |
- TagEntryPoints |
- TagStateList |
- TagActionList |
- TagActionTableList |
- TagCondSpaceList;
-
-TagStartState:
- '<' TAG_start_state '>'
- '<' '/' TAG_start_state '>' {
- unsigned long startState = strtoul( xmlData.data, 0, 10 );
- cgd->setStartState( startState );
- };
-
-TagEntryPoints:
- '<' TAG_entry_points AttributeList '>'
- EntryPointList
- '<' '/' TAG_entry_points '>' {
- Attribute *errorAttr = $3->find( "error" );
- if ( errorAttr != 0 )
- cgd->setForcedErrorState();
- };
-
-EntryPointList:
- EntryPointList TagEntry |
- /* Nothing */;
-
-TagEntry:
- '<' TAG_entry AttributeList '>'
- '<' '/' TAG_entry '>' {
- Attribute *nameAttr = $3->find( "name" );
- if ( nameAttr == 0 )
- xml_error(@2) << "tag <entry_points>::<entry> requires a name attribute" << endl;
- else {
- char *data = xmlData.data;
- unsigned long entry = strtoul( data, &data, 10 );
- cgd->addEntryPoint( nameAttr->value, entry );
- }
- };
-
-TagStateList:
- TagStateListHead
- StateList
- '<' '/' TAG_state_list '>';
-
-TagStateListHead:
- '<' TAG_state_list AttributeList '>' {
- Attribute *lengthAttr = $3->find( "length" );
- if ( lengthAttr == 0 )
- xml_error(@2) << "tag <state_list> requires a length attribute" << endl;
- else {
- unsigned long length = strtoul( lengthAttr->value, 0, 10 );
- cgd->initStateList( length );
- curState = 0;
- }
- };
-
-StateList:
- StateList TagState |
- /* Nothing */;
-
-TagState:
- TagStateHead
- StateItemList
- '<' '/' TAG_state '>' {
- curState += 1;
- };
-
-TagStateHead:
- '<' TAG_state AttributeList '>' {
- Attribute *lengthAttr = $3->find( "final" );
- if ( lengthAttr != 0 )
- cgd->setFinal( curState );
- };
-
-StateItemList:
- StateItemList StateItem |
- /* Nothing */;
-
-StateItem:
- TagStateActions |
- TagStateCondList |
- TagTransList;
-
-TagStateActions:
- '<' TAG_state_actions '>'
- '<' '/' TAG_state_actions '>' {
- char *ad = xmlData.data;
-
- long toStateAction = readOffsetPtr( ad, &ad );
- long fromStateAction = readOffsetPtr( ad, &ad );
- long eofAction = readOffsetPtr( ad, &ad );
-
- cgd->setStateActions( curState, toStateAction,
- fromStateAction, eofAction );
- };
-
-TagStateCondList:
- TagStateCondListHead
- StateCondList
- '<' '/' TAG_cond_list '>';
-
-TagStateCondListHead:
- '<' TAG_cond_list AttributeList '>' {
- Attribute *lengthAttr = $3->find( "length" );
- if ( lengthAttr == 0 )
- xml_error(@2) << "tag <cond_list> requires a length attribute" << endl;
- else {
- ulong length = readLength( lengthAttr->value );
- cgd->initStateCondList( curState, length );
- curStateCond = 0;
- }
- }
-
-StateCondList:
- StateCondList StateCond |
- /* Empty */;
-
-StateCond:
- '<' TAG_c '>'
- '<' '/' TAG_c '>' {
- char *td = xmlData.data;
- Key lowKey = readKey( td, &td );
- Key highKey = readKey( td, &td );
- long condId = readOffsetPtr( td, &td );
- cgd->addStateCond( curState, lowKey, highKey, condId );
- }
-
-TagTransList:
- TagTransListHead
- TransList
- '<' '/' TAG_trans_list '>' {
- cgd->finishTransList( curState );
- };
-
-TagTransListHead:
- '<' TAG_trans_list AttributeList '>' {
- Attribute *lengthAttr = $3->find( "length" );
- if ( lengthAttr == 0 )
- xml_error(@2) << "tag <trans_list> requires a length attribute" << endl;
- else {
- unsigned long length = strtoul( lengthAttr->value, 0, 10 );
- cgd->initTransList( curState, length );
- curTrans = 0;
- }
- };
-
-TransList:
- TransList TagTrans |
- /* Nothing */;
-
-TagTrans:
- '<' TAG_t AttributeList '>'
- '<' '/' TAG_t '>' {
- char *td = xmlData.data;
- Key lowKey = readKey( td, &td );
- Key highKey = readKey( td, &td );
- long targ = readOffsetPtr( td, &td );
- long action = readOffsetPtr( td, &td );
-
- cgd->newTrans( curState, curTrans++, lowKey, highKey, targ, action );
- };
-
-TagActionList:
- TagActionListHead
- ActionList
- '<' '/' TAG_action_list '>';
-
-TagActionListHead:
- '<' TAG_action_list AttributeList '>' {
- Attribute *lengthAttr = $3->find( "length" );
- if ( lengthAttr == 0 )
- xml_error(@2) << "tag <action_list> requires a length attribute" << endl;
- else {
- unsigned long length = strtoul( lengthAttr->value, 0, 10 );
- cgd->initActionList( length );
- curAction = 0;
- }
- };
-
-ActionList:
- ActionList TagAction |
- /* Nothing */;
-
-TagAction:
- '<' TAG_action AttributeList '>'
- InlineList
- '<' '/' TAG_action '>' {
- Attribute *lineAttr = $3->find( "line" );
- Attribute *colAttr = $3->find( "col" );
- Attribute *nameAttr = $3->find( "name" );
- if ( lineAttr == 0 || colAttr == 0)
- xml_error(@2) << "tag <action> requires a line and col attributes" << endl;
- else {
- unsigned long line = strtoul( lineAttr->value, 0, 10 );
- unsigned long col = strtoul( colAttr->value, 0, 10 );
-
- char *name = 0;
- if ( nameAttr != 0 )
- name = nameAttr->value;
-
- cgd->newAction( curAction++, name, line, col, $5 );
- }
- };
-
-InlineList:
- InlineList InlineItem {
- /* Append the item to the list, return the list. */
- $1->append( $2 );
- $$ = $1;
- } |
- /* Nothing */ {
- /* Start with empty list. */
- $$ = new InlineList;
- };
-
-InlineItem:
- TagText |
- TagGoto |
- TagCall |
- TagNext |
- TagGotoExpr |
- TagCallExpr |
- TagNextExpr |
- TagRet |
- TagBreak |
- TagPChar |
- TagChar |
- TagHold |
- TagExec |
- TagHoldTE |
- TagExecTE |
- TagCurs |
- TagTargs |
- TagIlEntry |
- TagLmSwitch |
- TagLmSetActId |
- TagLmSetTokEnd |
- TagLmGetTokEnd |
- TagSubAction |
- TagLmInitTokStart |
- TagLmInitAct |
- TagLmSetTokStart;
-
-TagText:
- '<' TAG_text AttributeList '>'
- '<' '/' TAG_text '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::Text );
- $$->data = strdup(xmlData.data);
- };
-
-TagGoto:
- '<' TAG_goto '>'
- '<' '/' TAG_goto '>' {
- int targ = strtol( xmlData.data, 0, 10 );
- $$ = new InlineItem( InputLoc(), InlineItem::Goto );
- $$->targId = targ;
- };
-
-TagCall:
- '<' TAG_call '>'
- '<' '/' TAG_call '>' {
- int targ = strtol( xmlData.data, 0, 10 );
- $$ = new InlineItem( InputLoc(), InlineItem::Call );
- $$->targId = targ;
- };
-
-TagNext:
- '<' TAG_next '>'
- '<' '/' TAG_next '>' {
- int targ = strtol( xmlData.data, 0, 10 );
- $$ = new InlineItem( InputLoc(), InlineItem::Next );
- $$->targId = targ;
- };
-
-TagGotoExpr:
- '<' TAG_goto_expr '>'
- InlineList
- '<' '/' TAG_goto_expr '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::GotoExpr );
- $$->children = $4;
- };
-
-TagCallExpr:
- '<' TAG_call_expr '>'
- InlineList
- '<' '/' TAG_call_expr '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::CallExpr );
- $$->children = $4;
- };
-
-TagNextExpr:
- '<' TAG_next_expr '>'
- InlineList
- '<' '/' TAG_next_expr '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::NextExpr );
- $$->children = $4;
- };
-
-TagRet:
- '<' TAG_ret '>'
- '<' '/' TAG_ret '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::Ret );
- };
-
-TagPChar:
- '<' TAG_pchar '>'
- '<' '/' TAG_pchar '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::PChar );
- };
-
-TagChar:
- '<' TAG_char '>'
- '<' '/' TAG_char '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::Char );
- };
-
-TagHold:
- '<' TAG_hold '>'
- '<' '/' TAG_hold '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::Hold );
- };
-
-TagExec:
- '<' TAG_exec '>'
- InlineList
- '<' '/' TAG_exec '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::Exec );
- $$->children = $4;
- };
-
-TagHoldTE:
- '<' TAG_holdte '>'
- '<' '/' TAG_holdte '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::HoldTE );
- };
-
-TagExecTE:
- '<' TAG_execte '>'
- InlineList
- '<' '/' TAG_execte '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::ExecTE );
- $$->children = $4;
- };
-
-TagCurs:
- '<' TAG_curs '>'
- '<' '/' TAG_curs '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::Curs );
- };
-
-TagTargs:
- '<' TAG_targs '>'
- '<' '/' TAG_targs '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::Targs );
- };
-
-TagIlEntry:
- '<' TAG_entry '>'
- '<' '/' TAG_entry '>' {
- int targ = strtol( xmlData.data, 0, 10 );
- $$ = new InlineItem( InputLoc(), InlineItem::Entry );
- $$->targId = targ;
- };
-
-TagBreak:
- '<' TAG_break '>'
- '<' '/' TAG_break '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::Break );
- };
-
-
-TagLmSwitch:
- '<' TAG_lm_switch AttributeList '>'
- LmActionList
- '<' '/' TAG_lm_switch '>' {
- bool handlesError = false;
- Attribute *handlesErrorAttr = $3->find( "handles_error" );
- if ( handlesErrorAttr != 0 )
- handlesError = true;
-
- $$ = new InlineItem( InputLoc(), InlineItem::LmSwitch );
- $$->children = $5;
- $$->handlesError = handlesError;
- };
-
-LmActionList:
- LmActionList TagInlineAction {
- $$ = $1;
- $$->append( $2 );
- } |
- /* Nothing */ {
- $$ = new InlineList;
- };
-
-TagInlineAction:
- '<' TAG_sub_action AttributeList '>'
- InlineList
- '<' '/' TAG_sub_action '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::SubAction );
- $$->children = $5;
-
- Attribute *idAttr = $3->find( "id" );
- if ( idAttr != 0 ) {
- unsigned long id = strtoul( idAttr->value, 0, 10 );
- $$->lmId = id;
- }
- };
-
-TagLmSetActId:
- '<' TAG_set_act '>'
- '<' '/' TAG_set_act '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::LmSetActId );
- $$->lmId = strtol( xmlData.data, 0, 10 );
- };
-
-TagLmGetTokEnd:
- '<' TAG_get_tokend '>'
- '<' '/' TAG_get_tokend '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::LmGetTokEnd );
- };
-
-TagLmSetTokEnd:
- '<' TAG_set_tokend '>'
- '<' '/' TAG_set_tokend '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::LmSetTokEnd );
- $$->offset = strtol( xmlData.data, 0, 10 );
- };
-
-TagSubAction:
- '<' TAG_sub_action '>'
- InlineList
- '<' '/' TAG_sub_action '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::SubAction );
- $$->children = $4;
- };
-
-TagLmInitTokStart:
- '<' TAG_init_tokstart '>'
- '<' '/' TAG_init_tokstart '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::LmInitTokStart );
- };
-
-TagLmInitAct:
- '<' TAG_init_act '>'
- '<' '/' TAG_init_act '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::LmInitAct );
- };
-
-TagLmSetTokStart:
- '<' TAG_set_tokstart '>'
- '<' '/' TAG_set_tokstart '>' {
- $$ = new InlineItem( InputLoc(), InlineItem::LmSetTokStart );
- cgd->hasLongestMatch = true;
- };
-
-TagActionTableList:
- TagActionTableListHead
- ActionTableList
- '<' '/' TAG_action_table_list '>';
-
-TagActionTableListHead:
- '<' TAG_action_table_list AttributeList '>' {
- Attribute *lengthAttr = $3->find( "length" );
- if ( lengthAttr == 0 )
- xml_error(@2) << "tag <action_table_list> requires a length attribute" << endl;
- else {
- unsigned long length = strtoul( lengthAttr->value, 0, 10 );
- cgd->initActionTableList( length );
- curActionTable = 0;
- }
- };
-
-ActionTableList:
- ActionTableList TagActionTable |
- /* Nothing */;
-
-TagActionTable:
- '<' TAG_action_table AttributeList '>'
- '<' '/' TAG_action_table '>' {
- /* Find the length of the action table. */
- Attribute *lengthAttr = $3->find( "length" );
- if ( lengthAttr == 0 )
- xml_error(@2) << "tag <at> requires a length attribute" << endl;
- else {
- unsigned long length = strtoul( lengthAttr->value, 0, 10 );
-
- /* Collect the action table. */
- RedAction *redAct = cgd->allActionTables + curActionTable;
- redAct->actListId = curActionTable;
- redAct->key.setAsNew( length );
- char *ptr = xmlData.data;
- int pos = 0;
- while ( *ptr != 0 ) {
- unsigned long actionId = strtoul( ptr, &ptr, 10 );
- redAct->key[pos].key = 0;
- redAct->key[pos].value = cgd->allActions+actionId;
- pos += 1;
- }
-
- /* Insert into the action table map. */
- cgd->redFsm->actionMap.insert( redAct );
- }
-
- curActionTable += 1;
- };
-
-TagCondSpaceList:
- TagCondSpaceListHead
- CondSpaceList
- '<' '/' TAG_cond_space_list '>';
-
-TagCondSpaceListHead:
- '<' TAG_cond_space_list AttributeList '>' {
- Attribute *lengthAttr = $3->find( "length" );
- if ( lengthAttr == 0 )
- xml_error(@2) << "tag <cond_space_list> requires a length attribute" << endl;
- else {
- ulong length = readLength( lengthAttr->value );
- cgd->initCondSpaceList( length );
- curCondSpace = 0;
- }
- };
-
-CondSpaceList:
- CondSpaceList TagCondSpace |
- TagCondSpace;
-
-TagCondSpace:
- '<' TAG_cond_space AttributeList '>'
- '<' '/' TAG_cond_space '>' {
- Attribute *lengthAttr = $3->find( "length" );
- Attribute *idAttr = $3->find( "id" );
- if ( lengthAttr == 0 )
- xml_error(@2) << "tag <cond_space> requires a length attribute" << endl;
- else {
- if ( lengthAttr == 0 )
- xml_error(@2) << "tag <cond_space> requires an id attribute" << endl;
- else {
- unsigned long condSpaceId = strtoul( idAttr->value, 0, 10 );
- ulong length = readLength( lengthAttr->value );
-
- char *td = xmlData.data;
- Key baseKey = readKey( td, &td );
-
- cgd->newCondSpace( curCondSpace, condSpaceId, baseKey );
- for ( ulong a = 0; a < length; a++ ) {
- long actionOffset = readOffsetPtr( td, &td );
- cgd->condSpaceItem( curCondSpace, actionOffset );
- }
- curCondSpace += 1;
- }
- }
- };
-
-%%
-
-unsigned long readLength( char *td )
-{
- return strtoul( td, 0, 10 );
-}
-
-Key readKey( char *td, char **end )
-{
- if ( keyOps->isSigned )
- return Key( strtol( td, end, 10 ) );
- else
- return Key( strtoul( td, end, 10 ) );
-}
-
-long readOffsetPtr( char *td, char **end )
-{
- while ( *td == ' ' || *td == '\t' )
- td++;
-
- if ( *td == 'x' ) {
- if ( end != 0 )
- *end = td + 1;
- return -1;
- }
-
- return strtol( td, end, 10 );
-}
-
-void yyerror( char *err )
-{
- /* Bison won't give us the location, but in the last call to the scanner we
- * saved a pointer to the locationn variable. Use that. instead. */
- error(::yylloc->first_line, ::yylloc->first_column) << err << endl;
-}
-
+++ /dev/null
-/*
- * Copyright 2001-2006 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-%{
-
-#define YY_NEVER_INTERACTIVE 1
-//#define WANT_TOKEN_WRITE
-
-#include <iostream>
-#include "vector.h"
-#include "rlcodegen.h"
-#include "xmlparse.h"
-#include "buffer.h"
-
-using std::cout;
-using std::cerr;
-using std::endl;
-
-Buffer tokbuf;
-int builtinBrace = 0;
-bool inlineWhitespace = true;
-bool handlingInclude = false;
-
-YYSTYPE *yylval;
-YYLTYPE *yylloc;
-
-void garble();
-
-void extendToken();
-void extendToken( char *data, int len );
-
-int emitToken( int token, char *data, int len );
-int emitNoData( int token );
-int emitTag( char *data, int len, bool isOpen );
-void passThrough( char *data );
-void popInclude();
-void scannerInit();
-
-enum InlineBlockType {
- CurlyDelimited,
- SemiTerminated
-} inlineBlockType;
-
-/* Using a wrapper for the parser, must the lex declaration. */
-#define YY_DECL int rlcodegen_lex()
-
-class Perfect_Hash
-{
-private:
- static inline unsigned int hash (const char *str, unsigned int len);
-
-public:
- static struct XMLTagHashPair *in_word_set (const char *str, unsigned int len);
-};
-
-Vector<bool> shouldEmitXMLData;
-
-int first_line = 1;
-int first_column = 1;
-int last_line = 1;
-int last_column = 0;
-
-Buffer xmlData;
-
-%}
-
-%x OPEN_TAG
-%x CLOSE_TAG1
-%x CLOSE_TAG2
-%x ATTR_LIST
-%x ATTR_LITERAL
-
-WSCHAR [\t\n\v\f\r ]
-IDENT [a-zA-Z_][a-zA-Z_0-9\-]*
-
-%%
-
- /* Numbers in outter code. */
-<INITIAL>"<" {
- BEGIN(OPEN_TAG);
- shouldEmitXMLData.prepend( false );
- return emitNoData( *yytext );
-}
-
-<INITIAL>[^<&]+ {
- if ( shouldEmitXMLData[0] )
- xmlData.append( yytext, yyleng );
- garble();
-}
-<INITIAL>"&" {
- if ( shouldEmitXMLData[0] )
- xmlData.append( "&", 1 );
- garble();
-}
-<INITIAL>"<" {
- if ( shouldEmitXMLData[0] )
- xmlData.append( "<", 1 );
- garble();
-}
-<INITIAL>">" {
- if ( shouldEmitXMLData[0] )
- xmlData.append( ">", 1 );
- garble();
-}
-
- /*
- * Tags
- */
-
-<OPEN_TAG>"/" {
- BEGIN(CLOSE_TAG1);
- xmlData.append(0);
- return emitNoData( *yytext );
-}
-
-<OPEN_TAG>{IDENT} {
- BEGIN( ATTR_LIST );
- return emitTag( yytext, yyleng, true );
-}
-
-<OPEN_TAG,CLOSE_TAG1>{WSCHAR}+ {
- garble();
-}
-
-<CLOSE_TAG1>{IDENT} {
- BEGIN( CLOSE_TAG2 );
- return emitTag( yytext, yyleng, false );
-}
-
-<CLOSE_TAG2>">" {
- shouldEmitXMLData.remove( 0 );
- BEGIN(INITIAL);
- return emitNoData( *yytext );
-}
-
-<ATTR_LIST>{IDENT} {
- return emitToken( XML_Word, yytext, yyleng );
-}
-
-<ATTR_LIST>\" {
- BEGIN(ATTR_LITERAL);
- extendToken();
-}
-<ATTR_LITERAL>\\. extendToken( yytext+1, 1 );
-<ATTR_LITERAL>\\\n extendToken( yytext+1, 1 );
-<ATTR_LITERAL>[^\\"]+ extendToken( yytext, yyleng );
-
- /* Terminate a double literal */
-<ATTR_LITERAL>\" {
- BEGIN(ATTR_LIST);
- return emitToken( XML_Literal, 0, 0 );
-}
-
-<ATTR_LIST>{WSCHAR}+ {
- garble();
-}
-
-<ATTR_LIST>">" {
- BEGIN(INITIAL);
- return emitNoData( *yytext );
-}
-
-<ATTR_LIST>. {
- return emitNoData( *yytext );
-}
-
-%%
-
-/* Write out token data, escaping special charachters. */
-#ifdef WANT_TOKEN_WRITE
-void writeToken( int token, char *data )
-{
- cout << "token id " << token << " at " << id->fileName << ":" <<
- yylloc->first_line << ":" << yylloc->first_column << "-" <<
- yylloc->last_line << ":" << yylloc->last_column << " ";
-
- if ( data != 0 ) {
- while ( *data != 0 ) {
- switch ( *data ) {
- case '\n': cout << "\\n"; break;
- case '\t': cout << "\\t"; break;
- default: cout << *data; break;
- }
- data += 1;
- }
- }
- cout << endl;
-}
-#endif
-
-/* Caclulate line info from yytext. Called on every pattern match. */
-void updateLineInfo()
-{
- /* yytext should always have at least wone char. */
- assert( yytext[0] != 0 );
-
- /* Scan through yytext up to the last character. */
- char *p = yytext;
- for ( ; p[1] != 0; p++ ) {
- if ( p[0] == '\n' ) {
- last_line += 1;
- last_column = 0;
- }
- else {
- last_column += 1;
- }
- }
-
- /* Always consider the last character as not a newline. Newlines at the
- * end of a token are as any old character at the end of the line. */
- last_column += 1;
-
- /* The caller may be about to emit a token, be prepared to pass the line
- * info to the parser. */
- yylloc->first_line = first_line;
- yylloc->first_column = first_column;
- yylloc->last_line = last_line;
- yylloc->last_column = last_column;
-
- /* If the last character was indeed a newline, then wrap ahead now. */
- if ( p[0] == '\n' ) {
- last_line += 1;
- last_column = 0;
- }
-}
-
-
-/* Eat up a matched pattern that will not be part of a token. */
-void garble()
-{
- /* Update line information from yytext. */
- updateLineInfo();
-
- /* The next token starts ahead of the last token. */
- first_line = last_line;
- first_column = last_column + 1;
-}
-
-/* Extend a token, but don't add any data to it, more token data expected. */
-void extendToken()
-{
- /* Update line information from yytext. */
- updateLineInfo();
-}
-
-/* Append data to the end of the token. More token data expected. */
-void extendToken( char *data, int len )
-{
- if ( data != 0 && len > 0 )
- tokbuf.append( data, len );
-
- /* Update line information from yytext. */
- updateLineInfo();
-}
-
-
-/* Append data to the end of a token and emitToken it to the parser. */
-int emitToken( int token, char *data, int len )
-{
- /* Append the data and null terminate. */
- if ( data != 0 && len > 0 )
- tokbuf.append( data, len );
- tokbuf.append( 0 );
-
- /* Duplicate the buffer. */
- yylval->data = new char[tokbuf.length];
- strcpy( yylval->data, tokbuf.data );
-
- /* Update line information from yytext. */
- updateLineInfo();
-
- /* Write token info. */
-#ifdef WANT_TOKEN_WRITE
- writeToken( token, tokbuf.data );
-#endif
-
- /* Clear out the buffer. */
- tokbuf.clear();
-
- /* The next token starts ahead of the last token. */
- first_line = last_line;
- first_column = last_column + 1;
-
- return token;
-}
-
-/* Append data to the end of a token and emitToken it to the parser. */
-int emitTag( char *data, int len, bool isOpen )
-{
- /* Lookup the tag. */
- int token = TAG_unknown;
-
- XMLTagHashPair *tag = Perfect_Hash::in_word_set( data, len );
- if ( tag != 0 )
- token = tag->id;
-
- if ( isOpen ) {
- switch ( token ) {
- case TAG_host: case TAG_t: case TAG_start_state:
- case TAG_action_table:
- case TAG_alphtype: case TAG_state_actions:
- case TAG_entry_points:
- case TAG_text: case TAG_goto:
- case TAG_call: case TAG_next:
- case TAG_set_act: case TAG_set_tokend:
- case TAG_entry: case TAG_option:
- case TAG_cond_space: case TAG_c:
- shouldEmitXMLData[0] = true;
- xmlData.clear();
- }
- }
-
- return emitToken( token, data, len );
-}
-
-/* Emit a token with no data to the parser. */
-int emitNoData( int token )
-{
- /* Return null to the parser. */
- yylval->data = 0;
-
- /* Update line information from yytext. */
- updateLineInfo();
-
- /* Write token info. */
-#ifdef WANT_TOKEN_WRITE
- writeToken( token, 0 );
-#endif
-
- /* Clear out the buffer. */
- tokbuf.clear();
-
- /* The next token starts ahead of the last token. */
- first_line = last_line;
- first_column = last_column + 1;
-
- return token;
-}
-
-/* Pass tokens in outter code through to the output. */
-void passThrough( char *data )
-{
- /* If no errors, we are emitting code and we are at the bottom of the
- * include stack (the source file listed on the command line) then write
- * out the data. */
- if ( gblErrorCount == 0 && outputFormat == OutCode )
- *outStream << data;
-}
-
-/* Init a buffer. */
-Buffer::Buffer()
-:
- data(0),
- length(0),
- allocated(0)
-{
-}
-
-/* Empty out a buffer on destruction. */
-Buffer::~Buffer()
-{
- empty();
-}
-
-/* Free the space allocated for the buffer. */
-void Buffer::empty()
-{
- if ( data != 0 ) {
- free( data );
-
- data = 0;
- length = 0;
- allocated = 0;
- }
-}
-
-/* Grow the buffer when to len allocation. */
-void Buffer::upAllocate( int len )
-{
- if ( data == 0 )
- data = (char*) malloc( len );
- else
- data = (char*) realloc( data, len );
- allocated = len;
-}
-
-int yywrap()
-{
- /* Once processessing of the input is done, signal no more. */
- return 1;
-}
-
-/* Here simply to suppress the unused yyunpt warning. */
-void thisFuncIsNeverCalled()
-{
- yyunput(0, 0);
-}
-
-void scannerInit()
-{
- /* Set this up in case we are initially given something other
- * than an opening tag. */
- shouldEmitXMLData.prepend( false );
-}
-
-/* Wrapper for the lexer which stores the locations of the value and location
- * variables of the parser into globals. The parser is reentrant, however the scanner
- * does not need to be, so globals work fine. This saves us passing them around
- * all the helper functions. */
-int yylex( YYSTYPE *yylval, YYLTYPE *yylloc )
-{
- ::yylval = yylval;
- ::yylloc = yylloc;
- return rlcodegen_lex();
-}
+++ /dev/null
-/*
- * Copyright 2001-2007 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#include <iostream>
-#include <string.h>
-#include "vector.h"
-#include "xmlparse.h"
-#include "rlcodegen.h"
-#include "buffer.h"
-
-using std::istream;
-using std::cout;
-using std::endl;
-
-#define BUFSIZE 4096
-
-%%{
- machine Scanner;
- write data;
-}%%
-
-class Perfect_Hash
-{
-private:
- static inline unsigned int hash (const char *str, unsigned int len);
-
-public:
- static struct XMLTagHashPair *in_word_set (const char *str, unsigned int len);
-};
-
-struct Scanner
-{
- Scanner( istream &input ) :
- input(input),
- curline(1),
- curcol(1),
- p(0), pe(0),
- done(false),
- data(0), data_len(0),
- value(0)
- {
- %%{
- machine Scanner;
- write init;
- }%%
- }
-
- int scan();
- void adjustAttrPointers( int distance );
-
- istream &input;
-
- /* Scanner State. */
- int cs, act, have, curline, curcol;
- char *tokstart, *tokend;
- char *p, *pe;
- int done;
-
- /* Token data */
- char *data;
- int data_len;
- int value;
- AttrMkList attrMkList;
- Buffer buffer;
- char *tag_id_start;
- int tag_id_len;
- int token_col, token_line;
-
- char buf[BUFSIZE];
-};
-
-
-#define TK_NO_TOKEN (-1)
-#define TK_ERR 1
-#define TK_EOF 2
-#define TK_OpenTag 3
-#define TK_CloseTag 4
-
-#define ret_tok( _tok ) token = (_tok); data = tokstart
-
-void Scanner::adjustAttrPointers( int distance )
-{
- for ( AttrMkList::Iter attr = attrMkList; attr.lte(); attr++ ) {
- attr->id -= distance;
- attr->value -= distance;
- }
-}
-
-int Scanner::scan( )
-{
- int token = TK_NO_TOKEN;
- int space, readlen;
- char *attr_id_start;
- char *attr_value_start;
- int attr_id_len;
- int attr_value_len;
-
- attrMkList.empty();
- buffer.clear();
-
- while ( 1 ) {
- if ( p == pe ) {
- //printf("scanner: need more data\n");
-
- if ( tokstart == 0 )
- have = 0;
- else {
- /* There is data that needs to be shifted over. */
- //printf("scanner: buffer broken mid token\n");
- have = pe - tokstart;
- memmove( buf, tokstart, have );
-
- int distance = tokstart - buf;
- tokend -= distance;
- tag_id_start -= distance;
- attr_id_start -= distance;
- attr_value_start -= distance;
- adjustAttrPointers( distance );
- tokstart = buf;
- }
-
- p = buf + have;
- space = BUFSIZE - have;
-
- if ( space == 0 ) {
- /* We filled up the buffer trying to scan a token. */
- //printf("scanner: out of buffer space, you have a really long tag\n");
- return TK_ERR;
- }
-
- if ( done ) {
- //printf("scanner: end of file\n");
- p[0] = 0;
- readlen = 1;
- }
- else {
- input.read( p, space );
- readlen = input.gcount();
- if ( input.eof() ) {
- //printf("scanner: setting done flag\n");
- done = 1;
- }
- }
-
- pe = p + readlen;
- }
-
- /* There is no claim that this is a proper XML parser, but it is good
- * enough for our purposes. */
- %%{
- machine Scanner;
-
- action colup { curcol++; }
- action start_tok { token_col = curcol; token_line = curline; }
- NL = '\n' @{ curcol = 0; curline++; };
-
- WS = [\r\t ] | NL;
- id = [_a-zA-Z][_a-zA-Z0-9]*;
- literal = '"' ( [^"] | NL )* '"';
-
- # Attribute identifiers.
- action start_attr_id { attr_id_start = p; }
- action leave_attr_id { attr_id_len = p - attr_id_start; }
-
- attr_id = id >start_attr_id %leave_attr_id;
-
- # Attribute values
- action start_attr_value { attr_value_start = p; }
- action leave_attr_value
- {
- attr_value_len = p - attr_value_start;
-
- AttrMarker newAttr;
- newAttr.id = attr_id_start;
- newAttr.idLen = attr_id_len;
- newAttr.value = attr_value_start;
- newAttr.valueLen = attr_value_len;
- attrMkList.append( newAttr );
- }
-
- attr_value = literal >start_attr_value %leave_attr_value;
-
- # Attribute list.
- attribute = attr_id WS* '=' WS* attr_value WS*;
-
- # Tag identifiers.
- action tag_id_start { tag_id_start = p; }
- action leave_tag_id { tag_id_len = p - tag_id_start; }
-
- tag_id = id >tag_id_start %leave_tag_id;
-
- main := |*
- # Tags
- ( '<' WS* tag_id ( WS+ attribute* )? '>' ) >start_tok $colup
- => { ret_tok( TK_OpenTag ); fbreak; };
-
- ( '<' WS* '/' WS* tag_id WS* '>' ) >start_tok $colup
- => { ret_tok( TK_CloseTag ); fbreak; };
-
- # Data in between tags.
- ( [^<&\0] | NL ) $colup
- => { buffer.append( *p ); };
-
- # Specials.
- "&" $colup
- => { buffer.append( '&' ); };
- "<" $colup
- => { buffer.append( '<' ); };
- ">" $colup
- => { buffer.append( '>' ); };
-
- # EOF
- 0 >start_tok => { ret_tok( TK_EOF ); fbreak; };
-
- *|;
-
- write exec;
- }%%
-
- if ( cs == Scanner_error )
- return TK_ERR;
-
- if ( token != TK_NO_TOKEN ) {
- /* fbreak does not advance p, so we do it manually. */
- p = p + 1;
- data_len = p - data;
- return token;
- }
- }
-}
-
-
-int xml_parse( istream &input, char *fileName )
-{
- Scanner scanner( input );
- Parser parser( fileName );
-
- parser.init();
-
- while ( 1 ) {
- int token = scanner.scan();
- if ( token == TK_EOF ) {
- //cout << "parser_driver: EOF" << endl;
- parser.token( _eof );
- break;
- }
- else if ( token == TK_ERR ) {
- //cout << "parser_driver: ERR" << endl;
- break;
- }
- else {
- /* All other tokens are either open or close tags. */
- XMLTagHashPair *tagId = Perfect_Hash::in_word_set(
- scanner.tag_id_start, scanner.tag_id_len );
-
- XMLTag *tag = new XMLTag( tagId, token == TK_OpenTag ?
- XMLTag::Open : XMLTag::Close );
-
- if ( tagId != 0 ) {
- /* Get attributes for open tags. */
- if ( token == TK_OpenTag && scanner.attrMkList.length() > 0 ) {
- tag->attrList = new AttrList;
- for ( AttrMkList::Iter attr = scanner.attrMkList;
- attr.lte(); attr++ )
- {
- Attribute newAttr;
- newAttr.id = new char[attr->idLen+1];
- memcpy( newAttr.id, attr->id, attr->idLen );
- newAttr.id[attr->idLen] = 0;
-
- /* Exclude the surrounding quotes. */
- newAttr.value = new char[attr->valueLen-1];
- memcpy( newAttr.value, attr->value+1, attr->valueLen-2 );
- newAttr.value[attr->valueLen-2] = 0;
-
- tag->attrList->append( newAttr );
- }
- }
-
- /* Get content for closing tags. */
- if ( token == TK_CloseTag ) {
- switch ( tagId->id ) {
- case TAG_host: case TAG_option:
- case TAG_t: case TAG_alphtype:
- case TAG_text: case TAG_goto:
- case TAG_call: case TAG_next:
- case TAG_entry: case TAG_set_tokend:
- case TAG_set_act: case TAG_start_state:
- case TAG_state_actions: case TAG_action_table:
- case TAG_cond_space: case TAG_c:
- tag->content = new char[scanner.buffer.length+1];
- memcpy( tag->content, scanner.buffer.data,
- scanner.buffer.length );
- tag->content[scanner.buffer.length] = 0;
- break;
- }
- }
- }
-
- #if 0
- cout << "parser_driver: " << (tag->type == XMLTag::Open ? "open" : "close") <<
- ": " << tag->tagId->name << endl;
- if ( tag->attrList != 0 ) {
- for ( AttrList::Iter attr = *tag->attrList; attr.lte(); attr++ )
- cout << " " << attr->id << ": " << attr->value << endl;
- }
- if ( tag->content != 0 )
- cout << " content: " << tag->content << endl;
- #endif
-
- parser.token( tag, scanner.token_col, scanner.token_line );
- }
- }
-
- return 0;
-}
+++ /dev/null
-/*
- * Copyright 2005 Adrian Thurston <thurston@cs.queensu.ca>
- */
-
-/* This file is part of Ragel.
- *
- * Ragel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Ragel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Ragel; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-
-%{
-#include <string.h>
-#include "xmlparse.h"
-%}
-%compare-strncmp
-struct XMLTagHashPair;
-%%
-ragel, TAG_ragel
-ragel_def, TAG_ragel_def
-host, TAG_host
-state_list, TAG_state_list
-state, TAG_state
-trans_list, TAG_trans_list
-t, TAG_t
-machine, TAG_machine
-start_state, TAG_start_state
-action_list, TAG_action_list
-action, TAG_action
-action_table_list, TAG_action_table_list
-action_table, TAG_action_table
-alphtype, TAG_alphtype
-getkey, TAG_getkey
-state_actions, TAG_state_actions
-entry_points, TAG_entry_points
-text, TAG_text
-goto, TAG_goto
-call, TAG_call
-next, TAG_next
-goto_expr, TAG_goto_expr
-call_expr, TAG_call_expr
-next_expr, TAG_next_expr
-ret, TAG_ret
-pchar, TAG_pchar
-char, TAG_char
-hold, TAG_hold
-exec, TAG_exec
-holdte, TAG_holdte
-execte, TAG_execte
-curs, TAG_curs
-targs, TAG_targs
-entry, TAG_entry
-data, TAG_data
-lm_switch, TAG_lm_switch
-sub_action, TAG_sub_action
-init_act, TAG_init_act
-set_act, TAG_set_act
-get_tokend, TAG_get_tokend
-set_tokend, TAG_set_tokend
-init_tokstart, TAG_init_tokstart
-set_tokstart, TAG_set_tokstart
-write, TAG_write
-curstate, TAG_curstate
-access, TAG_access
-break, TAG_break
-option, TAG_option
-cond_space_list, TAG_cond_space_list
-cond_space, TAG_cond_space
-cond_list, TAG_cond_list
-c, TAG_c
+++ /dev/null
-#
-# Copyright 2002-2006 Adrian Thurston <thurston@cs.queensu.ca>
-#
-
-# This file is part of Ragel.
-#
-# Ragel is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Ragel is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ragel; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-test:
- @./runtests
-
-clean:
- rm -f *.c *.cpp *.m *.d *.java *.bin *.class *.exp \
- *.out *_c.rl *_d.rl *_java.rl
-
-distclean: clean
- rm -f Makefile
+++ /dev/null
-/*
- * @LANG: c
- */
-
-/*
- * Test of a transition going to the error state.
- */
-
-#include <stdio.h>
-#define BUFSIZE 2048
-
-struct errintrans
-{
- int cs;
-};
-
-%%{
- machine errintrans;
- variable curstate fsm->cs;
-
- char = any - (digit | '\n');
- line = char* "\n";
- main := line+;
-}%%
-
-%% write data;
-
-void errintrans_init( struct errintrans *fsm )
-{
- %% write init;
-}
-
-void errintrans_execute( struct errintrans *fsm, const char *_data, int _len )
-{
- const char *p = _data;
- const char *pe = _data+_len;
-
- %% write exec;
-}
-
-int errintrans_finish( struct errintrans *fsm )
-{
- %% write eof;
-
- if ( fsm->cs == errintrans_error )
- return -1;
- if ( fsm->cs >= errintrans_first_final )
- return 1;
- return 0;
-}
-
-
-struct errintrans fsm;
-#include <string.h>
-
-void test( char *buf )
-{
- int len = strlen( buf );
- errintrans_init( &fsm );
- errintrans_execute( &fsm, buf, len );
- if ( errintrans_finish( &fsm ) > 0 )
- printf("ACCEPT\n");
- else
- printf("FAIL\n");
-}
-
-
-int main()
-{
- test(
- "good, does not have numbers\n"
- );
-
- test(
- "bad, has numbers 666\n"
- );
-
- return 0;
-}
-
-#ifdef _____OUTPUT_____
-ACCEPT
-FAIL
-#endif
+++ /dev/null
-#!/bin/bash
-
-#
-# Copyright 2006 Adrian Thurston <thurston@cs.queensu.ca>
-#
-
-# This file is part of Ragel.
-#
-# Ragel is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Ragel is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ragel; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-while getopts "gcnmleT:F:G:P:CDJ" opt; do
- case $opt in
- T|F|G|P)
- genflags="$genflags -$opt$OPTARG"
- options="$options -$opt$OPTARG"
- ;;
- n|m|l|e)
- minflags="$minflags -$opt"
- options="$options -$opt"
- ;;
- c)
- compile_only="true"
- options="$options -$opt"
- ;;
- g)
- allow_generated="true"
- ;;
- C|D|J)
- langflags="$langflags -$opt"
- ;;
- esac
-done
-
-[ -z "$minflags" ] && minflags="-n -m -l -e"
-[ -z "$genflags" ] && genflags="-T0 -T1 -F0 -F1 -G0 -G1 -G2"
-[ -z "$langflags" ] && langflags="-C -D -J"
-
-shift $((OPTIND - 1));
-
-[ -z "$*" ] && set -- *.rl
-
-# find the config file
-config=../common/config.h
-ragel=../ragel/ragel
-rlcodegen=../rlcodegen/rlcodegen
-if ! [ -d ../common ]; then
- config=../$config
- ragel=../$ragel
- rlcodegen=../$rlcodegen
-fi
-
-cxx_compiler=`sed '/^#define CXX/s/#define CXX *//p;d' $config`
-c_compiler=`sed '/^#define CC/s/#define CC *//p;d' $config`
-objc_compiler=`sed '/^#define GOBJC/s/#define GOBJC *//p;d' $config`
-d_compiler=`sed '/^#define GDC/s/#define GDC *//p;d' $config`
-java_compiler=`sed '/#define JAVAC/s/#define JAVAC *//p;d' $config`
-txl_engine=`sed '/^#define TXL/s/#define TXL *//p;d' $config`
-
-function test_error
-{
- exit 1;
-}
-
-for test_case; do
- root=${test_case%.rl};
-
- if ! [ -f "$test_case" ]; then
- echo "runtests: not a file: $test_case"; >&2
- exit 1;
- fi
-
- # Check if we should ignore the test case
- ignore=`sed '/@IGNORE:/s/^.*: *//p;d' $test_case`
- if [ "$ignore" = yes ]; then
- continue;
- fi
-
- # If the generated flag is given make sure that the test case is generated.
- is_generated=`sed '/@GENERATED:/s/^.*: *//p;d' $test_case`
- if [ "$is_generated" = yes ] && [ "$allow_generated" != true ]; then
- continue;
- fi
-
- expected_out=$root.exp;
- sed '1,/_____OUTPUT_____/d;$d' $test_case > $expected_out
-
- lang=`sed '/@LANG:/s/^.*: *//p;d' $test_case`
- if [ -z "$lang" ]; then
- echo "$test_case: language unset"; >&2
- exit 1;
- fi
-
- case $lang in
- c++)
- code_suffix=cpp;
- compiler=$cxx_compiler;
- lang_opt=-C;
- cflags="-pedantic -ansi -Wall -O3"
- ;;
- d)
- code_suffix=d;
- compiler=$d_compiler;
- lang_opt=-D;
- cflags="-Wall -O3"
- ;;
- c)
- code_suffix=c;
- compiler=$c_compiler;
- lang_opt=-C;
- cflags="-pedantic -ansi -Wall -O3"
- ;;
- obj-c)
- code_suffix=m;
- compiler=$objc_compiler
- lang_opt=-C;
- cflags="-Wall -O3 -fno-strict-aliasing -lobjc"
- ;;
- java)
- code_suffix=java;
- compiler=$java_compiler
- lang_opt=-J;
- cflags=""
- ;;
- indep)
- # If we have no compiler for the source program then skip it.
- [ -z "$txl_engine" ] && continue
- for lang in c d java; do
- case $lang in
- c) lf="-C";;
- d) lf="-D";;
- java) lf="-J";;
- esac
-
- echo "$langflags" | grep -e $lf >/dev/null || continue
-
- targ=${root}_$lang.rl
- echo "./langtrans_$lang.sh $test_case > $targ"
- if ! ./langtrans_$lang.sh $test_case > $targ; then
- test_error
- fi
- echo "./runtests -g $options $targ"
- if ! ./runtests -g $options $targ; then
- test_error
- fi
- done
- continue;
- ;;
- *)
- echo "$test_case: unknown language type $lang" >&2
- exit 1;
- ;;
- esac
-
- # Make sure that we are interested in the host language.
- echo "$langflags" | grep -e $lang_opt >/dev/null || continue
-
- code_src=$root.$code_suffix;
- binary=$root.bin;
- output=$root.out;
-
- # If we have no compiler for the source program then skip it.
- [ -z "$compiler" ] && continue
-
- additional_cflags=`sed '/@CFLAGS:/s/^.*: *//p;d' $test_case`
- [ -n "$additional_cflags" ] && cflags="$cflags $additional_cflags"
-
- allow_minflags=`sed '/@ALLOW_MINFLAGS:/s/^.*: *//p;d' $test_case`
- [ -z "$allow_minflags" ] && allow_minflags="-n -m -l -e"
-
- allow_genflags=`sed '/@ALLOW_GENFLAGS:/s/^.*: *//p;d' $test_case`
- [ -z "$allow_genflags" ] && allow_genflags="-T0 -T1 -F0 -F1 -G0 -G1 -G2"
-
- for min_opt in $minflags; do
- for gen_opt in $genflags; do
- echo "$allow_minflags" | grep -e $min_opt >/dev/null || continue
-
- grep_gen_opt=${gen_opt}
- split_iters=${gen_opt#-P}
- if test $split_iters != $gen_opt; then
- grep_gen_opt="-P";
- fi
- echo "$allow_genflags" | grep -e $grep_gen_opt >/dev/null || continue
-
- echo "$ragel $min_opt $lang_opt $test_case | $rlcodegen $gen_opt -o $code_src"
- if ! $ragel $min_opt $lang_opt $test_case | $rlcodegen $gen_opt -o $code_src; then
- test_error;
- fi
-
- split_objs=""
- if test $split_iters != $gen_opt; then
- n=0;
- while test $n -lt $split_iters; do
- part_root=${root}_`awk 'BEGIN {
- width = 0;
- high = '$split_iters' - 1;
- while ( high > 0 ) {
- width = width + 1;
- high = int(high / 10);
- }
- suffFormat = "%" width "." width "d\n";
- printf( suffFormat, '$n' );
- exit 0;
- }'`
- part_src=${part_root}.c
- part_bin=${part_root}.o
- echo "$compiler -c $cflags -o $part_bin $part_src"
- if ! $compiler -c $cflags -o $part_bin $part_src; then
- test_error;
- fi
- split_objs="$split_objs $part_bin"
- n=$((n+1))
- done
- fi
-
- out_args=""
- [ $lang != java ] && out_args="-o ${binary}";
-
- echo "$compiler ${cflags} ${out_args} ${code_src}"
- if ! $compiler ${cflags} ${out_args} ${code_src}; then
- test_error;
- fi
-
- if [ "$compile_only" != "true" ]; then
- echo -n "running $root ... ";
-
- exec_cmd=./$binary
- [ $lang = java ] && exec_cmd="java $root"
-
- $exec_cmd 2>&1 > $output;
- if diff $expected_out $output > /dev/null; then
- echo "passed";
- else
- echo "FAILED";
- test_error;
- fi;
- fi
- done
- done
-done
+++ /dev/null
-VERSION = 5.16
-PUBDATE = November 2006