-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
1 changed file
with
17 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |