1. Corentin Derbois
  2. SmallCC

Commits

Corentin Derbois  committed 575f7ee

Add scrypt to make test on c file

  • Participants
  • Parent commits 94f42e3
  • Branches develop

Comments (0)

Files changed (7)

File Makefile

View file
  • Ignore whitespace
 
 distclean:
 	@make -C src distclean
+
+.PHONY: test
+test:
+	@cd test && ./test.sh

File src/lexer.mll

View file
  • Ignore whitespace
 
 | L(L|D*)*   {IDENTIFIER(get lexbuf)}
 | D+        {CONSTANT(get lexbuf)}
-| L?['"']L*['"'] {STRING_LITERAL}
+| L?['"']L*['"'] {STRING_LITERAL(get lexbuf)}
 
 (* end of Not totaly ... *)
 

File src/parser.mly

View file
  • Ignore whitespace
 
 %token <string> IDENTIFIER
 %token <string> CONSTANT
-%token STRING_LITERAL SIZEOF
+%token <string> STRING_LITERAL 
+%token SIZEOF
 %token PTR_OP INC_OP DEC_OP LEFT_OP RIGHT_OP LE_OP GE_OP EQ_OP NE_OP
 %token AND_OP OR_OP MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN
 %token SUB_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN

File src/wrapper.ml

View file
  • Ignore whitespace
       this#from_lexbuf lexbuf ()
     with
       ParseError(exn, (line, col, tok)) -> 
-        Printf.printf "Error line:%d col:%d token:\"%s\"\n" line col tok;
+        Printf.fprintf stderr "Error line:%d col:%d token:\"%s\"\n" line col tok;
         raise exn
 
   method from_channel fdin () = 

File test/print.c

View file
  • Ignore whitespace
 int print(void)
 {
-  printf("Hello World!\n");
+  printf("HelloWorld");
   return 1;
 }
 

File test/static.c

View file
  • Ignore whitespace
+static int i = 0;
+
+int main(void)
+{
+  return i;
+}

File test/test.sh

View file
  • Ignore whitespace
+#/bin/sh
+
+exe=../scc
+
+err=`mktemp`
+out=`mktemp`
+
+onefile () {
+  $exe $1 1>$out 2>$err
+  strerr=`cat $err`
+  if [ "$strerr" != "" ]; then
+    echo "[FAIL]" $1
+    echo "============================================="
+    $exe $1 1>/dev/null
+    echo "============================================="
+    return 0
+  fi
+  echo "[PASSE]" $1
+}
+
+onefile main.c
+onefile print.c
+onefile static.c
+
+exit 0