summaryrefslogtreecommitdiff
path: root/minie
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2018-12-27 21:55:12 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2018-12-27 21:55:12 +0100
commit4c640f3dbc1c9f95578ff7ebe9110002d8b0434d (patch)
tree4440007a5986decde51c3eb4cd6e2a5cd65d9852 /minie
parent214c24ffe26af7c2434a43c4624cc69ef6f5121f (diff)
downloadcompilertests-4c640f3dbc1c9f95578ff7ebe9110002d8b0434d.tar.gz
compilertests-4c640f3dbc1c9f95578ff7ebe9110002d8b0434d.tar.bz2
added char pseudo-function to create non-printable character constants
Diffstat (limited to 'minie')
-rw-r--r--minie/e2c.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/minie/e2c.c b/minie/e2c.c
index e4bfa05..f5394e6 100644
--- a/minie/e2c.c
+++ b/minie/e2c.c
@@ -626,6 +626,12 @@ static void register_internal_functions( void )
type.details.function.params[0] = TYPE_ARRAY;
type.details.function.internal = 1;
insert_symbol( type, "length" );
+
+ type.type = TYPE_FUNCTION;
+ type.details.function.len = 1;
+ type.details.function.params[0] = TYPE_CHAR;
+ type.details.function.internal = 1;
+ insert_symbol( type, "char" );
}
static void register_internal_constants( void )
@@ -901,6 +907,7 @@ static void parameterList( void )
/* prologue of 1-parameter function or procedure */
if( sym != S_comma ) {
+ /* handle internal 0-parameter functions and procedures */
/* TODO: add internal function maps as symbols and procedures */
if( strcmp( funcName, "length" ) == 0 ) {
/* we don't allow expression here, only simple variables */
@@ -908,7 +915,13 @@ static void parameterList( void )
emit( "%d", length( varName ) );
Expect( S_rparen );
return;
- /* handle internal 0-parameter functions and procedures */
+ /* constructor for non-printable characters */
+ } else if( strcmp( funcName, "char" ) == 0 ) {
+ number( );
+ emit( "(char)%d", num );
+ sym = getSym( );
+ Expect( S_rparen );
+ return;
} else if( strcmp( funcName, "system.writeline" ) == 0 ) {
emit( "printf( \"%%s\\n\", " );
} else if( strcmp( funcName, "system.writestring" ) == 0 ) {