+++ /dev/null
-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;
-}
from yard import :: Error, instance toString Error
:: Opts = {
+ version :: Bool,
program :: String,
lex :: Bool,
parse :: Bool,
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
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}