Skip to content

Commit

Permalink
Update lm.py
Browse files Browse the repository at this point in the history
Improved "lm.py" parser so that lispmark can be processed from the command line

 eg "./lm.py file.lm" outputs "file.html"
  • Loading branch information
153 authored Sep 1, 2018
1 parent eafb4ba commit 7ddb59c
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions lm.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
#!/usr/bin/env python3
# simple parse tool to generate .html from .lm file

import sys
import parse

def main():
fn = input("file: ")
if len(sys.argv) == 1:
fn = input("file: ")
else:
fn = sys.argv[1]
with open(fn + ".lm", "r") as f:
f = f.read()
f = f.read()
f = "".join(["(html", f, ")"])
lm = parse.eval_input(f)
print(lm)
wri = input("Write file?")
if wri not in ["0", "n"]:
with open(fn + ".html", "w") as nf:
nf.write(lm)
if len(sys.argv) == 1:
print(lm)
wri = input("Write file?")
if wri not in ["0", "n"]:
with open(fn + ".html", "w") as nf:
nf.write(lm)
else:
with open(fn + ".html", "w") as nf:
nf.write(lm)

main()

0 comments on commit 7ddb59c

Please sign in to comment.