Skip to content

Commit

Permalink
add runtime with input and output functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Ramsauer committed Apr 11, 2018
1 parent 08a0fce commit 7370ca0
Show file tree
Hide file tree
Showing 8 changed files with 701 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
*.d
*.o
lexmain
lexmain.exe
out.txt
parsemain
runtime
*.exe
*.out
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/runtime",
"args": [ "-t", "trace.out", "-s", "sym.out", "pla_korrekt.tst", "output.out"],
"args": [ "pla_korrekt.tst", "87", "111", "114", "108", "100" ],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
Expand Down
11 changes: 10 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@
"__nullptr": "cpp",
"new": "cpp",
"stdexcept": "cpp",
"sstream": "cpp"
"sstream": "cpp",
"vector": "cpp",
"__bit_reference": "cpp",
"atomic": "cpp",
"bitset": "cpp",
"system_error": "cpp",
"__hash_table": "cpp",
"__split_buffer": "cpp",
"hash_map": "cpp",
"unordered_map": "cpp"
}
}
8 changes: 8 additions & 0 deletions global.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@

using namespace std;

const string ASCII_OUT = "ascii";
const string INT_OUT = "cint";
const string REAL_OUT = "creal";
const string ARG_COUNT = "argCount";
const string ARG_IDX = "argIdx";
const string ARG_OUT = "argOut";
const string ARG_PROC = "arg";

#define TRUE 1
#define FALSE 0
#define BSIZE 512 /* Puffergrösse */
Expand Down
12 changes: 12 additions & 0 deletions parser.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,18 @@ void parser_t::program() {
// globale Symboltabelle anlegen (firstsym
firstsym = create_newsym();

actsym = firstsym;

insert( this, INTIDENT, ASCII_OUT, 0 );
insert( this, INTIDENT, INT_OUT, 0 );
insert( this, REALIDENT, REAL_OUT, 0 );
insert( this, KONST, ARG_COUNT, 0 );
insert( this, INTIDENT, ARG_IDX, 0 );
insert( this, PROC, ARG_PROC, 0 );
insert( this, INTIDENT, ARG_OUT, 0 );

actsym = nullptr;

// Block muss folgen
block( firstsym );

Expand Down
37 changes: 27 additions & 10 deletions pla_korrekt.tst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const c = 6, d = 7;
const c = 6, d = 7, H = 72, E = 69, L = 76, O = 79, NL = 10;
var n: int , f: real, e:real;
procedure test;
var i : int, k:real;
Expand All @@ -8,17 +8,34 @@
f := k+f;
i := 2;
while i <=n do
begin
f := f + k * 1.0;
f := 1.0;
if i = 0
then i := 1 fi;
i := i+1
end
begin
f := f + k * 1.0;
f := 1.0;
if i = 0
then i := 1 fi;
i := i+1
end
end;

begin
if n = 0 then n := n + 1 else n := 0 fi;
n := c;
call test
call test;

cint := n;
ascii := NL;

ascii := H;
ascii := E;
ascii := L;
ascii := L;
ascii := O;
ascii := NL;

argIdx := 0;
while argIdx < argCount do
begin
call arg;
ascii := argOut;
argIdx := argIdx + 1
end
end$
Loading

0 comments on commit 7370ca0

Please sign in to comment.