summaryrefslogtreecommitdiff
path: root/minie
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2018-12-25 22:05:16 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2018-12-25 22:05:16 +0100
commit62d6644b2ab51ee8dda46752f1e7c8d422b65e04 (patch)
treed822f7bd56327e5537a33dbadbcecc864dbe1c4e /minie
parent06afd5e79163efd295d18dfbf79d6160c9dc3026 (diff)
downloadcompilertests-62d6644b2ab51ee8dda46752f1e7c8d422b65e04.tar.gz
compilertests-62d6644b2ab51ee8dda46752f1e7c8d422b65e04.tar.bz2
added comments
added test7 with string length function, not working yet
Diffstat (limited to 'minie')
-rw-r--r--minie/README5
-rwxr-xr-xminie/build.sh2
-rw-r--r--minie/e2c.c19
-rw-r--r--minie/test4.e2
4 files changed, 27 insertions, 1 deletions
diff --git a/minie/README b/minie/README
index c8fe74e..9905329 100644
--- a/minie/README
+++ b/minie/README
@@ -19,4 +19,7 @@ test2: syntax error, no module definition
test3: module definition lacking a module name
test4: general expressions and variables
test5: basic system input/output, import of pseudo module 'system'
-test6: string functions, internal function 'length'
+test6: internal function 'length', system functions for stdio and stdin
+test7: a proper string length function using 'length' and introducing
+ a function taking array of arbitrary length
+
diff --git a/minie/build.sh b/minie/build.sh
index 898cb5a..12fde40 100755
--- a/minie/build.sh
+++ b/minie/build.sh
@@ -7,9 +7,11 @@ gcc -g -O0 -Wall -pedantic -std=c89 -Wno-return-type -o e2c e2c.c
./e2c < test4.e
./e2c < test5.e
./e2c < test6.e
+./e2c < test7.e
./e2c < test5.e > test5.c && gcc -g -o test5 test5.c && ./test5
./e2c < test6.e > test6.c && gcc -g -o test6 test6.c && ./test6
+./e2c < test7.e > test7.c && gcc -g -o test7 test7.c && ./test7
./e2c < ec.e
./e2c < ec.e > ec.c && gcc -o ec ec.c
diff --git a/minie/e2c.c b/minie/e2c.c
index 0001c4f..09b151d 100644
--- a/minie/e2c.c
+++ b/minie/e2c.c
@@ -228,8 +228,23 @@ static void string( void )
look = getChar( );
}
+static void skipComment( void )
+{
+ look = getChar( );
+cont:
+ while( look != '*' ) {
+ look = getChar( );
+ }
+ look = getChar( );
+ if( look != ')' ) {
+ goto cont;
+ }
+ look = getChar( );
+}
+
static Symbol getSym( void )
{
+next:
skipWhite( );
/*
num = 0;
@@ -389,6 +404,10 @@ static Symbol getSym( void )
return S_slash;
case '(':
look = getChar( );
+ if( look == '*' ) {
+ skipComment( );
+ goto next;
+ }
return S_lparen;
case ')':
look = getChar( );
diff --git a/minie/test4.e b/minie/test4.e
index 2dc3722..24281c0 100644
--- a/minie/test4.e
+++ b/minie/test4.e
@@ -1,5 +1,7 @@
module test4;
+(* data types, assignment and if statement *)
+
var
x : integer;
y : integer;