From e6234f0793c3e7d9978831d884d420a5dbb5bfb1 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Wed, 25 Sep 2019 20:31:31 -0400 Subject: Add io functions to base scope --- pc.l | 16 ++++++++++++++++ pc.y | 9 +++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/pc.l b/pc.l index ec5b947..701e469 100644 --- a/pc.l +++ b/pc.l @@ -34,6 +34,22 @@ id [A-Za-z][A-Za-z0-9_]* return PROG; } +input { + node *tmp; + tmp = scope_insert(cur_scope, "write"); + tmp->func_info = malloc(sizeof(struct fi)); + + return IO; +} + +output { + node *tmp; + tmp = scope_insert(cur_scope, "read"); + tmp->func_info = malloc(sizeof(struct fi)); + + return IO; +} + "var" { debug_print(VAR, NULL); return VAR; diff --git a/pc.y b/pc.y index 7e4ca78..07f753f 100644 --- a/pc.y +++ b/pc.y @@ -26,6 +26,7 @@ extern scope *cur_scope; } %token PROG +%token IO %token VAR %token PROC FUNC %token BEG END @@ -94,7 +95,7 @@ extern scope *cur_scope; %% program - :PROG ID '(' id_list ')' ';' + :PROG ID '(' io_list ')' ';' var_declarations sub_prog_declarations compound_statement @@ -105,7 +106,6 @@ program print_tree($9); #endif free_tree($9); - free_tree($4); #ifdef DEBUG print_scope(cur_scope); #endif @@ -113,6 +113,11 @@ program } ; +io_list + :IO + |io_list ',' IO +; + id_list :ID { -- cgit v1.1