From: Mart Lubbers Date: Wed, 2 Mar 2016 14:31:04 +0000 (+0100) Subject: man toegevoegd, mapjes gemaakt, bijna klaar voor inleveren X-Git-Url: https://git.martlubbers.net/?a=commitdiff_plain;h=b3bedf1e825aaaee9134dddc6de82b373bf8b86b;p=cc1516.git man toegevoegd, mapjes gemaakt, bijna klaar voor inleveren --- diff --git a/src/.gitignore b/src/.gitignore index b1b84c1..aa2c2db 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -1,3 +1,4 @@ Clean System Files main sapl +main.1 diff --git a/src/Makefile b/src/Makefile index f0036fa..1749e2c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,7 +1,15 @@ CPM:=cpm +BIN:=main -all: +.PHONY: man main + +all: $(BIN) $(BIN).1 + +main: $(CPM) make +%.1: % + help2man ./$< > $@ + clean: - $(RM) -rv Clean\ System\ Files sapl main + $(RM) -rv Clean\ System\ Files sapl $(BIN) $(BIN).1 diff --git a/src/exVarDecl.spl b/src/exVarDecl.spl deleted file mode 100644 index 8873515..0000000 --- a/src/exVarDecl.spl +++ /dev/null @@ -1,67 +0,0 @@ -var v1ar1 = 1; -Int int1 = 1; -Bool bool1 = 1; -Char char1 = 1; -[Char] listchar1 = 1; -(Bool, Int) tupleboolint1 = 1; -var v1 = True; -var v2 = False; -var v3 = True && False; -var v4 = True || !False; -var v4 = 1 - 2 - 3 -- 4; -var v5 = 1 * 2 - 3 * 4; -var v6 = 1 * (2 - 3) * 4; -var v7 = 1 * 2 % 3 * 4; -var v8 = a * 4; -var v9 = a.tl.fst * 4; -var v9 = a.tl * 4; -var w0 = a.fst * 4; -var w1 = a.snd * 4; -var w2 = a.hd : anotherVariable; -var w3 = [] + 5; -var w4 = func(); -var w5 = func(1); -var w5 = func(1, [], 1+2); -a a = 4; -var w6 = ([] + 5, func(1)); -([a], [(b, (c, [[[(d, e)]]]))]) t = f(1+2-3*4%5/6+(6+(6+1)), g(h(a.fst), [])); -t() :: Void {} -t(a) :: Void {} -t(a, b, c) :: Void {} -t() :: Int { - var v1 = True; - ([a], [(b, (c, [[[(d, e)]]]))]) t = f(1+2-3*4%5/6+(6+(6+1)), g(h(a.fst), [])); - - if(True){ - } - if(True){ - abc(); - abc(1); - abc(1, 1, 1); - } else { - if((x*x)+(y+y)){ - } else { - abcd(); - } - } - - while(True){} - while(True){ - if(True){ - abc(); - abc(1); - abc(1, 1, 1); - } else { - if((x*x)+(y+y)){ - } else { - abcd(); - } - } - } - - abc(); - abc(1); - abc(1, 1, 1); - return (1, 2); - return; -} diff --git a/src/example.spl b/src/examples/example.spl similarity index 100% rename from src/example.spl rename to src/examples/example.spl diff --git a/src/grammar.txt b/src/grammar/grammar.txt similarity index 100% rename from src/grammar.txt rename to src/grammar/grammar.txt diff --git a/src/main.icl b/src/main.icl index ee1e0bd..31c98d7 100644 --- a/src/main.icl +++ b/src/main.icl @@ -19,6 +19,7 @@ import lex from yard import :: Error, instance toString Error :: Opts = { + version :: Bool, program :: String, lex :: Bool, parse :: Bool, @@ -30,15 +31,23 @@ derive gPrint TokenValue Start :: *World -> *World Start w # (args, w) = parseArgs w -| args.help - # (out, w) = stdio w - # out = out <<< "Usage: " <<< args.program <<< " [opts] [FILENAME]\n" - <<< "\t--help Show this help\n" - <<< "\t--[no-]lex Lexer output(default: disabled)\n" - <<< "\t--[no-]parse Parser output(default: enabled)\n\n" - <<< "\tFILENAME File to parse, when unspecified stdin is parsed\n" - = snd $ fclose out w # (stdin, w) = stdio w +| args.version + # stdin = stdin + <<< "main 0.1 (17 march 2016)\n" + <<< "Copyright Pim Jager and Mart Lubbers\n" + = snd $ fclose stdin w +| args.help + # stdin = stdin + <<< "Usage: " <<< args.program <<< " [OPTION] [FILE]\n" + <<< "Lex parse and either FILE or stdin\n" + <<< "\n" + <<< "Options:\n" + <<< " --help Show this help\n" + <<< " --version Show the version\n" + <<< " --[no-]lex Lexer output(default: disabled)\n" + <<< " --[no-]parse Parser output(default: enabled)\n" + = snd $ fclose stdin w # (contents, stdin, w) = readFileOrStdin stdin args.fp w = case contents of (Left cs) = snd $ fclose (stdin <<< cs) w @@ -64,11 +73,18 @@ Start w parseArgs :: *World -> (Opts, *World) parseArgs w # ([p:args], w) = getCommandLine w -= (pa args {program=p, lex=False, parse=True, fp=Nothing, help=False}, w) += (pa args { + program=p, + version=False, + lex=False, + parse=True, + fp=Nothing, + help=False}, w) where pa :: [String] Opts -> Opts pa [] o = o pa ["--help":r] o = pa r {o & help=True} + pa ["--version":r] o = pa r {o & version=True} pa ["--lex":r] o = pa r {o & lex=True} pa ["--no-lex":r] o = pa r {o & lex=False} pa ["--parse":r] o = pa r {o & parse=True}