X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=spl.icl;h=80049330e52a8259bdf28f2864e94ace7d5438cf;hb=1233630930a7767b46ddc91b83c6463dce84dce0;hp=240de63540f0a0b9856babac414e58d8bf70bade;hpb=df7fbaaf21817473f51525a2c8f03b0a5a37b823;p=cc1516.git diff --git a/spl.icl b/spl.icl index 240de63..8004933 100644 --- a/spl.icl +++ b/spl.icl @@ -12,6 +12,7 @@ import Data.Maybe import Data.Func import System.CommandLine import GenPrint +import Data.Map from Text import class Text(concat,join), instance Text String import parse @@ -50,7 +51,8 @@ Start w <<< " --help Show this help\n" <<< " --version Show the version\n" <<< " --[no-]lex Lexer output(default: disabled)\n" - <<< " --[no-]parse Parser output(default: enabled)\n" + <<< " --[no-]parse Parser output(default: disabled)\n" + <<< " --[no-]sem Semantic analysis output(default: enabled)\n" = snd $ fclose stdin w # (contents, stdin, w) = readFileOrStdin stdin args.fp w = case contents of @@ -66,13 +68,17 @@ Start w # stdin = if (not args.parse) stdin ( stdin <<< "//PARSER\n" <<< toString parseOut <<< "//PARSER\n") = case sem parseOut of - (Left e) = snd $ fclose (stdin <<< "SEMERRORS: " <<< - join "\n" (map toString e)) w - (Right semOut) - # stdin = if (not args.sem) stdin ( - stdin <<< "//SEM\n" <<< toString semOut <<< "//SEM\n") - = snd $ fclose stdin w + (Left e) = snd $ fclose (stdin <<< join "\n" (map toString e)) w + (Right constraints) + # stdin = if (not args.sem) stdin (stdin + <<< "//SEM G\n" <<< printConstraints constraints <<< "//SEMA\n") + = snd $ fclose (stdin <<< "\n") w where + printConstraints :: Constraints -> String + printConstraints [] = "" + printConstraints [(t1, t2):ts] = concat [ + "(", toString t1, ",", toString t2, ")"] +++ printConstraints ts + printTokens :: [Token] -> String printTokens ts = concat $ flatten $ map pt ts where