From 483bcde4dbb75d1901cffad6cc2c45307b7e90a2 Mon Sep 17 00:00:00 2001 From: pimjager Date: Fri, 6 May 2016 16:33:17 +0200 Subject: [PATCH] start of code generation --- gen.dcl | 5 +++++ gen.icl | 7 +++++++ spl.icl | 13 ++++++++++--- 3 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 gen.dcl create mode 100644 gen.icl diff --git a/gen.dcl b/gen.dcl new file mode 100644 index 0000000..0ed553c --- /dev/null +++ b/gen.dcl @@ -0,0 +1,5 @@ +definition module gen + +import AST + +gen :: AST -> String \ No newline at end of file diff --git a/gen.icl b/gen.icl new file mode 100644 index 0000000..0d5eb12 --- /dev/null +++ b/gen.icl @@ -0,0 +1,7 @@ +implementation module gen + +import AST +import StdMisc + +gen :: AST -> String +gen _ = "dummy" \ No newline at end of file diff --git a/spl.icl b/spl.icl index cf3d5f3..e88e943 100644 --- a/spl.icl +++ b/spl.icl @@ -19,6 +19,7 @@ import parse import lex import sem import AST +import gen from yard import :: Error, instance toString Error :: Opts = { @@ -27,6 +28,7 @@ from yard import :: Error, instance toString Error lex :: Bool, parse :: Bool, sem :: Bool, + gen :: Bool, fp :: Maybe String, help :: Bool} @@ -58,20 +60,22 @@ Start w = case contents of (Left cs) = snd $ fclose (stdin <<< cs) w (Right cs) = case lexer cs of - (Left e) = snd $ fclose (stdin <<< toString e) w + (Left e) = snd $ fclose (stdin <<< toString e <<< "\n") w (Right lexOut) # stdin = if (not args.lex) stdin ( stdin <<< "//LEXER\n" <<< printTokens lexOut <<< "//LEXER\n") = case parser lexOut of - (Left e) = snd $ fclose (stdin <<< toString e) w + (Left e) = snd $ fclose (stdin <<< toString e <<< "\n") w (Right parseOut) # stdin = if (not args.parse) stdin ( stdin <<< "//PARSER\n" <<< toString parseOut <<< "//PARSER\n") = case sem parseOut of - (Left e) = snd $ fclose (stdin <<< join "\n" (map toString e)) w + (Left e) = snd $ fclose (stdin <<< join "\n" (map toString e) <<< "\n") w (Right ast) # stdin = if (not args.sem) stdin (stdin <<< "//SEM G\n" <<< toString ast <<< "//SEMA\n") + # stdin = if (not args.gen) stdin (stdin + <<< "//CODE GEN\n" <<< gen ast <<< "\n//CODE GEN\n") = snd $ fclose (stdin <<< "\n") w where printConstraints :: Constraints -> String @@ -94,6 +98,7 @@ parseArgs w lex=False, parse=False, sem=True, + gen=True, fp=Nothing, help=False}, w) where @@ -107,6 +112,8 @@ where pa ["--no-parse":r] o = pa r {o & parse=False} pa ["--sem":r] o = pa r {o & sem=True} pa ["--no-sem":r] o = pa r {o & sem=False} + pa ["--gen":r] o = pa r {o & gen=True} + pa ["--no-gen":r] o = pa r {o & gen=False} pa [x:r] o = pa r {o & fp=Just x} readFileOrStdin :: *File (Maybe String) *World -> *(Either String [Char], *File, *World) -- 2.20.1