Renamed project master
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 18 Dec 2018 21:19:04 +0000 (15:19 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Tue, 18 Dec 2018 21:19:04 +0000 (15:19 -0600)
christmas_proj [deleted file]
christmas_proj.nimble [deleted file]
light [new file with mode: 0755]
light.nimble [new file with mode: 0644]
src/christmas_proj.nim [deleted file]
src/light.nim [new file with mode: 0644]

diff --git a/christmas_proj b/christmas_proj
deleted file mode 100755 (executable)
index 1c1efbc..0000000
Binary files a/christmas_proj and /dev/null differ
diff --git a/christmas_proj.nimble b/christmas_proj.nimble
deleted file mode 100644 (file)
index c935d1f..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-# Package
-
-version       = "0.1.0"
-author        = "Brendan Hansen"
-description   = "A new awesome nimble package"
-license       = "MIT"
-srcDir        = "src"
-bin           = @["christmas_proj"]
-
-
-# Dependencies
-
-requires "nim >= 0.19.0"
-requires "docopt >= 0.6.8"
-requires "opengl >= 1.2.0"
-requires "nimrod-glfw"
-
-task run, "Run project":
-  exec("nimble build -d:release")
-  exec("./christmas_proj")
diff --git a/light b/light
new file mode 100755 (executable)
index 0000000..716f870
Binary files /dev/null and b/light differ
diff --git a/light.nimble b/light.nimble
new file mode 100644 (file)
index 0000000..263f569
--- /dev/null
@@ -0,0 +1,20 @@
+# Package
+
+version       = "0.1.0"
+author        = "Brendan Hansen"
+description   = "A new awesome nimble package"
+license       = "MIT"
+srcDir        = "src"
+bin           = @["light"]
+
+
+# Dependencies
+
+requires "nim >= 0.19.0"
+requires "docopt >= 0.6.8"
+requires "opengl >= 1.2.0"
+requires "nimrod-glfw"
+
+task run, "Run project":
+  exec("nimble build -d:release")
+  exec("./light")
diff --git a/src/christmas_proj.nim b/src/christmas_proj.nim
deleted file mode 100644 (file)
index 2217b11..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-import os
-import times
-import tables
-import random
-import parseutils
-
-import docopt
-import opengl
-import glfw3 as glfw
-import gfx/window as gfx_window
-import gfx/glutils as glutils
-
-import lang/types/types
-import lang/types/ast
-import lang/program
-import lang/executer
-
-import board/board
-
-proc key_down(window: glfw.Window, key, scancode, action, modifier: cint) {.cdecl.} =
-  if key == glfw.KEY_ESCAPE and action == glfw.PRESS:
-    glfw.SetWindowShouldClose(window, glfw.TRUE)
-
-proc CreateFuncs(window: gfx_window.Window, board: LightBoard): ExecFuncs =
-  newTable({
-    "say": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
-      echo $args
-    ),
-
-    "get_width": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
-      board.width.int32
-    ),
-
-    "get_height": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
-      board.height.int32
-    ),
-
-    "in_bounds": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
-      if args[0] < 0 or args[1] < 0 or args[0] >= board.width or args[1] >= board.height:
-        0
-      else:
-        1
-    ),
-
-    "set_col": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
-      board.SetCol(args[0].int, args[1].int, args[2].GLuint)
-    ),
-
-    "set_a": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
-      board.SetA(args[0].int, args[1].int, args[2].GLuint)
-    ),
-
-    "set_r": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
-      board.SetR(args[0].int, args[1].int, args[2].GLuint)
-    ),
-
-    "set_g": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
-      board.SetG(args[0].int, args[1].int, args[2].GLuint)
-    ),
-
-    "set_b": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
-      board.SetB(args[0].int, args[1].int, args[2].GLuint)
-    ),
-
-    "get_col": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
-      board.GetCol(args[0].int, args[1].int).int32
-    ),
-
-    "get_a": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
-      board.GetA(args[0].int, args[1].int).int32
-    ),
-
-    "get_r": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
-      board.GetR(args[0].int, args[1].int).int32
-    ),
-
-    "get_g": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
-      board.GetG(args[0].int, args[1].int).int32
-    ),
-
-    "get_b": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
-      board.GetB(args[0].int, args[1].int).int32
-    ),
-
-    "random": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
-      random.rand(args[0].int).int32
-    ),
-
-    "halt": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
-      ec.StopExecution()
-    ),
-
-    "render": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
-      glClearColor(0, 0, 0, 1)
-      glClear(GL_COLOR_BUFFER_BIT)
-      
-      board.RebufferColors()
-      board.Render()
-
-      os.sleep(1)
-      window.Refresh()
-      if window.ShouldClose():
-        ec.StopExecution()
-    )
-  })
-
-let docs = """
-Light Interpreter.
-
-Usage:
-  light run <file> [--width=<int>] [--height=<int>] [--win_width=<int>] [--win_height=<int>]
-  light ast <file>
-  light (-h | --help)
-  light --version
-  
-Options:
-  -h --help           Show this screen.
-  --width=<int>       Width of board [default: 64].
-  --height=<int>      Height of board [default: 64].
-  --win_width=<int>   Width of window [default: 1200].
-  --win_height=<int>  Height of window [default: 700].
-"""
-
-type
-  RunOptions = object
-    filename: string
-    board_width: int
-    board_height: int
-    window_width: int
-    window_height: int
-
-proc RunProgram(options: RunOptions) =
-  let window = gfx_window.NewWindow(options.window_width.cint, options.window_height.cint, "Light Visualizer")
-  window.SetKeyCallback(key_down)
-
-  var program = LoadProgram(options.filename)
-
-  let board = CreateBoard(options.board_width, options.board_height)
-  board.InitRendering()
-
-  let ec = MakeExecutionContext(CreateFuncs(window, board))
-  discard ExecuteProgram(ec, program)
-
-  while not window.ShouldClose():
-    glClearColor(0, 0, 0, 1)
-    glClear(GL_COLOR_BUFFER_BIT)
-    
-    board.Render()
-
-    os.sleep(1)
-    window.Refresh()
-
-  window.CloseWindow()
-
-proc PrintAst(filename: string) =
-  let program = LoadProgram(filename)
-
-  echo "\n" & filename & "'s Abstract Syntax Tree"
-  for line in program.code:
-    echo line
-  echo "\n"
-
-proc main() =
-  random.randomize(getTime().toUnix())
-  let args = docopt(docs, version = "Light programming language v0.1.0")
-
-  if args["run"]:
-    var
-      board_width: int
-      board_height: int
-      window_width: int
-      window_height: int
-    discard parseInt($args["--width"], board_width)
-    discard parseInt($args["--height"], board_height)
-    discard parseInt($args["--win_width"], window_width)
-    discard parseInt($args["--win_height"], window_height)
-    let options = RunOptions(
-        filename: $args["<file>"],
-        board_width: board_width,
-        board_height: board_height,
-        window_width: window_width,
-        window_height: window_height,
-    )
-    RunProgram(options)
-
-  if args["ast"]:
-    PrintAst($args["<file>"])
-
-when isMainModule:
-  main()
diff --git a/src/light.nim b/src/light.nim
new file mode 100644 (file)
index 0000000..2217b11
--- /dev/null
@@ -0,0 +1,190 @@
+import os
+import times
+import tables
+import random
+import parseutils
+
+import docopt
+import opengl
+import glfw3 as glfw
+import gfx/window as gfx_window
+import gfx/glutils as glutils
+
+import lang/types/types
+import lang/types/ast
+import lang/program
+import lang/executer
+
+import board/board
+
+proc key_down(window: glfw.Window, key, scancode, action, modifier: cint) {.cdecl.} =
+  if key == glfw.KEY_ESCAPE and action == glfw.PRESS:
+    glfw.SetWindowShouldClose(window, glfw.TRUE)
+
+proc CreateFuncs(window: gfx_window.Window, board: LightBoard): ExecFuncs =
+  newTable({
+    "say": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
+      echo $args
+    ),
+
+    "get_width": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
+      board.width.int32
+    ),
+
+    "get_height": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
+      board.height.int32
+    ),
+
+    "in_bounds": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
+      if args[0] < 0 or args[1] < 0 or args[0] >= board.width or args[1] >= board.height:
+        0
+      else:
+        1
+    ),
+
+    "set_col": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
+      board.SetCol(args[0].int, args[1].int, args[2].GLuint)
+    ),
+
+    "set_a": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
+      board.SetA(args[0].int, args[1].int, args[2].GLuint)
+    ),
+
+    "set_r": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
+      board.SetR(args[0].int, args[1].int, args[2].GLuint)
+    ),
+
+    "set_g": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
+      board.SetG(args[0].int, args[1].int, args[2].GLuint)
+    ),
+
+    "set_b": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
+      board.SetB(args[0].int, args[1].int, args[2].GLuint)
+    ),
+
+    "get_col": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
+      board.GetCol(args[0].int, args[1].int).int32
+    ),
+
+    "get_a": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
+      board.GetA(args[0].int, args[1].int).int32
+    ),
+
+    "get_r": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
+      board.GetR(args[0].int, args[1].int).int32
+    ),
+
+    "get_g": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
+      board.GetG(args[0].int, args[1].int).int32
+    ),
+
+    "get_b": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
+      board.GetB(args[0].int, args[1].int).int32
+    ),
+
+    "random": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
+      random.rand(args[0].int).int32
+    ),
+
+    "halt": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
+      ec.StopExecution()
+    ),
+
+    "render": (proc(ec: ExecutionContext, args: openarray[int32]): int32 {.closure.} =
+      glClearColor(0, 0, 0, 1)
+      glClear(GL_COLOR_BUFFER_BIT)
+      
+      board.RebufferColors()
+      board.Render()
+
+      os.sleep(1)
+      window.Refresh()
+      if window.ShouldClose():
+        ec.StopExecution()
+    )
+  })
+
+let docs = """
+Light Interpreter.
+
+Usage:
+  light run <file> [--width=<int>] [--height=<int>] [--win_width=<int>] [--win_height=<int>]
+  light ast <file>
+  light (-h | --help)
+  light --version
+  
+Options:
+  -h --help           Show this screen.
+  --width=<int>       Width of board [default: 64].
+  --height=<int>      Height of board [default: 64].
+  --win_width=<int>   Width of window [default: 1200].
+  --win_height=<int>  Height of window [default: 700].
+"""
+
+type
+  RunOptions = object
+    filename: string
+    board_width: int
+    board_height: int
+    window_width: int
+    window_height: int
+
+proc RunProgram(options: RunOptions) =
+  let window = gfx_window.NewWindow(options.window_width.cint, options.window_height.cint, "Light Visualizer")
+  window.SetKeyCallback(key_down)
+
+  var program = LoadProgram(options.filename)
+
+  let board = CreateBoard(options.board_width, options.board_height)
+  board.InitRendering()
+
+  let ec = MakeExecutionContext(CreateFuncs(window, board))
+  discard ExecuteProgram(ec, program)
+
+  while not window.ShouldClose():
+    glClearColor(0, 0, 0, 1)
+    glClear(GL_COLOR_BUFFER_BIT)
+    
+    board.Render()
+
+    os.sleep(1)
+    window.Refresh()
+
+  window.CloseWindow()
+
+proc PrintAst(filename: string) =
+  let program = LoadProgram(filename)
+
+  echo "\n" & filename & "'s Abstract Syntax Tree"
+  for line in program.code:
+    echo line
+  echo "\n"
+
+proc main() =
+  random.randomize(getTime().toUnix())
+  let args = docopt(docs, version = "Light programming language v0.1.0")
+
+  if args["run"]:
+    var
+      board_width: int
+      board_height: int
+      window_width: int
+      window_height: int
+    discard parseInt($args["--width"], board_width)
+    discard parseInt($args["--height"], board_height)
+    discard parseInt($args["--win_width"], window_width)
+    discard parseInt($args["--win_height"], window_height)
+    let options = RunOptions(
+        filename: $args["<file>"],
+        board_width: board_width,
+        board_height: board_height,
+        window_width: window_width,
+        window_height: window_height,
+    )
+    RunProgram(options)
+
+  if args["ast"]:
+    PrintAst($args["<file>"])
+
+when isMainModule:
+  main()