Skip to content

Commit

Permalink
Lox: expect filename as arg and execute the source at the given location
Browse files Browse the repository at this point in the history
  • Loading branch information
ccntrq committed Jan 6, 2018
1 parent 7702f6d commit c64c00b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Lox.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,13 @@ module Lox where

import Scanner

import System.Environment

main :: IO ()
main = print $ runScanner (initState "()") scanTokens
main = getArgs >>= \args -> execFile $ head args

execFile :: String -> IO ()
execFile path = readFile path >>= \src -> runSource src

runSource :: String -> IO ()
runSource src = print $ runScanner (initState src) scanTokens

0 comments on commit c64c00b

Please sign in to comment.