This repository has been archived by the owner on Nov 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.fs
48 lines (42 loc) · 1.42 KB
/
main.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// possum v2.0.0
// copyright (c) 2011-2012 darkf
// licensed under the terms of the MIT license
// see LICENSE for details
module Main
open Possum
open Parser
open Types
let main =
let args = System.Environment.GetCommandLineArgs ()
if args.Length < 2 then
// REPL mode
initSym ()
let mutable cont = true
while cont do
try
printf ">> "
let input = System.Console.ReadLine ()
match input with
| ":q" | ":quit" | ":exit" -> cont <- false
| _ ->
let r = evalConsumable (Consumable (parseString input))
printfn "%s" (exprRepr r)
with
| BindingError (msg, _) -> printfn "BindingError: %s" msg
| SemanticError msg -> printfn "SemanticError: %s" msg
| ParseError msg -> printfn "ParseError: %s" msg
| e -> printfn "Unhandled exception: %s" e.Message
else
let tokens = parseFile args.[1] //"defun f is end print \"hi\""
let tc = Consumable tokens
//printConsumable tc
initSym ()
let st = parseExprs tc
try
ignore (evalConsumable st)
with
| BindingError (msg, _) -> printfn "BindingError: %s" msg
| SemanticError msg -> printfn "SemanticError: %s" msg
| ParseError msg -> printfn "ParseError: %s" msg
| e -> printfn "Unhandled exception: %s" e.Message
ignore (System.Console.ReadKey ())