Tizen 2.0 Release
[external/ragel.git] / test / langtrans_c.sh
index 7d9cf41..2523b0a 100755 (executable)
@@ -5,17 +5,28 @@ file=$1
 
 [ -f $file ] || exit 1
 
-# Get the amchine name.
+# Get the machine name.
 machine=`sed -n 's/^[\t ]*machine[\t ]*\([a-zA-Z_0-9]*\)[\t ]*;[\t ]*$/\1/p' $file`
 
-# Make a temporary version of the test case the C language translations.
+# Make a temporary version of the test case using the C language translations.
 sed -n '/\/\*/,/\*\//d;p' $file | txl -q stdin langtrans_c.txl > $file.pr
 
+needs_eof=`sed '/@NEEDS_EOF/s/^.*$/yes/p;d' $file`
+if [ "$needs_eof" != 'yes' ]; then
+       needs_eof=`sed -n '/\/\*/,/\*\//d;p' $file | txl -q stdin checkeofact.txl`
+fi
+
 # Begin writing out the test case.
 cat << EOF
 /*
  * @LANG: c
  * @GENERATED: yes
+EOF
+
+grep '@ALLOW_GENFLAGS:' $file
+grep '@ALLOW_MINFLAGS:' $file
+
+cat << EOF
  */
 #include <string.h>
 #include <stdio.h>
@@ -35,7 +46,7 @@ void init()
 {
 EOF
 
-sed -n '1,/^%%$/d; /^%%{$/q; {s/^/\t/;p}' $file.pr
+sed -n '0,/^%%$/d; /^%%{$/q; {s/^/\t/;p}' $file.pr
 
 cat << EOF
        %% write init;
@@ -45,12 +56,16 @@ void exec( char *data, int len )
 {
        char *p = data;
        char *pe = data + len;
+EOF
+
+[ "$needs_eof" = "yes" ] && echo "char *eof = pe;"
+
+cat << EOF
        %% write exec;
 }
 
 void finish( )
 {
-       %% write eof;
        if ( cs >= ${machine}_first_final )
                printf( "ACCEPT\\n" );
        else
@@ -59,7 +74,7 @@ void finish( )
 EOF
 
 # Write out the test data.
-sed -n '1,/\/\* _____INPUT_____/d; /_____INPUT_____ \*\//q; p;' $file | awk '
+sed -n '0,/\/\* _____INPUT_____/d; /_____INPUT_____ \*\//q; p;' $file | awk '
 BEGIN {
        print "char *inp[] = {"
 }
@@ -89,7 +104,7 @@ int main( )
 EOF
 
 # Write out the expected output.
-sed -n '1,/\/\* _____OUTPUT_____/d; /_____OUTPUT_____ \*\//q; p;' $file
+sed -n '0,/\/\* _____OUTPUT_____/d; /_____OUTPUT_____ \*\//q; p;' $file
 echo "#endif"
 
 # Don't need this language-specific file anymore.