Compare commits
No commits in common. "2eaa763a2cd6f88a582f7c654ec3416bfc3646fc" and "a08084230e9a7a3141e8532ae504221240d70e35" have entirely different histories.
2eaa763a2c
...
a08084230e
@ -3,7 +3,6 @@ import sys
|
|||||||
|
|
||||||
def emit(string):
|
def emit(string):
|
||||||
sys.stdout.write(string)
|
sys.stdout.write(string)
|
||||||
sys.stdout.flush()
|
|
||||||
|
|
||||||
def trace(header, value):
|
def trace(header, value):
|
||||||
if os.environ.get('TRACE'):
|
if os.environ.get('TRACE'):
|
||||||
@ -39,6 +38,11 @@ def skip():
|
|||||||
|
|
||||||
PEEK = None
|
PEEK = None
|
||||||
|
|
||||||
|
def skipchar(char):
|
||||||
|
global LINE
|
||||||
|
assert char == peek(), (LINE, char, peek())
|
||||||
|
skip()
|
||||||
|
|
||||||
def emitln(data):
|
def emitln(data):
|
||||||
emit(data)
|
emit(data)
|
||||||
emit(eol)
|
emit(eol)
|
||||||
@ -56,11 +60,6 @@ def lexident():
|
|||||||
|
|
||||||
return word
|
return word
|
||||||
|
|
||||||
def skipchar(char):
|
|
||||||
global LINE
|
|
||||||
assert char == peek(), (LINE, char, peek())
|
|
||||||
skip()
|
|
||||||
|
|
||||||
def parseconststring():
|
def parseconststring():
|
||||||
skipchar(quote)
|
skipchar(quote)
|
||||||
emit(quote)
|
emit(quote)
|
||||||
@ -162,60 +161,10 @@ def parsestatreturn(indent):
|
|||||||
emit('return ')
|
emit('return ')
|
||||||
if ' ' == peek():
|
if ' ' == peek():
|
||||||
skip()
|
skip()
|
||||||
if quote == peek():
|
|
||||||
parseconststring()
|
|
||||||
else:
|
|
||||||
parseexprvarref()
|
parseexprvarref()
|
||||||
emit(eol)
|
emit(eol)
|
||||||
skipchar(eol)
|
skipchar(eol)
|
||||||
|
|
||||||
def parsestatcheck(indent):
|
|
||||||
skipchar(' ')
|
|
||||||
emit(' ' * indent)
|
|
||||||
emit('assert ')
|
|
||||||
|
|
||||||
func_name = lexident()
|
|
||||||
emit(func_name)
|
|
||||||
emit('(')
|
|
||||||
notfirst = False
|
|
||||||
|
|
||||||
while True:
|
|
||||||
skipchar(' ')
|
|
||||||
|
|
||||||
if ':' == peek():
|
|
||||||
break
|
|
||||||
|
|
||||||
if notfirst:
|
|
||||||
emit(', ')
|
|
||||||
|
|
||||||
if quote == peek():
|
|
||||||
parseconststring()
|
|
||||||
else:
|
|
||||||
parseexprvarref()
|
|
||||||
|
|
||||||
notfirst = True
|
|
||||||
|
|
||||||
skipchar(':')
|
|
||||||
|
|
||||||
emit('), (')
|
|
||||||
notfirst = False
|
|
||||||
|
|
||||||
while True:
|
|
||||||
skipchar(' ')
|
|
||||||
|
|
||||||
if notfirst:
|
|
||||||
emit(', ')
|
|
||||||
|
|
||||||
if quote == peek():
|
|
||||||
parseconststring()
|
|
||||||
else:
|
|
||||||
parseexprvarref()
|
|
||||||
|
|
||||||
if eol == peek():
|
|
||||||
break
|
|
||||||
notfirst = True
|
|
||||||
emitln(')')
|
|
||||||
|
|
||||||
def parsestattrace(indent):
|
def parsestattrace(indent):
|
||||||
skipchar(' ')
|
skipchar(' ')
|
||||||
emit(' ' * indent)
|
emit(' ' * indent)
|
||||||
@ -261,10 +210,6 @@ def parsestat(indent):
|
|||||||
parsestatreturn(indent)
|
parsestatreturn(indent)
|
||||||
return
|
return
|
||||||
|
|
||||||
if call == "check":
|
|
||||||
parsestatcheck(indent)
|
|
||||||
return
|
|
||||||
|
|
||||||
if call == "trace":
|
if call == "trace":
|
||||||
parsestattrace(indent)
|
parsestattrace(indent)
|
||||||
return
|
return
|
||||||
@ -355,7 +300,6 @@ def emitheader():
|
|||||||
emitln("")
|
emitln("")
|
||||||
emitln("def emit(string):")
|
emitln("def emit(string):")
|
||||||
emitln(" sys.stdout.write(string)")
|
emitln(" sys.stdout.write(string)")
|
||||||
emitln(" sys.stdout.flush()")
|
|
||||||
emitln("")
|
emitln("")
|
||||||
emitln("def trace(header, value):")
|
emitln("def trace(header, value):")
|
||||||
emitln(" if os.environ.get('TRACE'):")
|
emitln(" if os.environ.get('TRACE'):")
|
||||||
@ -364,39 +308,32 @@ def emitheader():
|
|||||||
emitln("eof = chr(0)")
|
emitln("eof = chr(0)")
|
||||||
emitln("eol = chr(10)")
|
emitln("eol = chr(10)")
|
||||||
emitln("quote = chr(34)")
|
emitln("quote = chr(34)")
|
||||||
|
emitln("PEEK = None")
|
||||||
|
emitln("LINE = 1")
|
||||||
emitln("")
|
emitln("")
|
||||||
emitln("STDINCOLNO = 0")
|
emitln("def peek():")
|
||||||
emitln("STDINLINENO = 1")
|
emitln(" global PEEK")
|
||||||
emitln("STDINPEEK = None")
|
emitln(" if PEEK is None:")
|
||||||
emitln("")
|
|
||||||
emitln("def _readchar():")
|
|
||||||
emitln(" char = sys.stdin.read(1)")
|
emitln(" char = sys.stdin.read(1)")
|
||||||
emitln(" trace('char', char)")
|
emitln(" trace('char', char)")
|
||||||
emitln(" if not char:")
|
emitln(" if not char:")
|
||||||
emitln(" return eof")
|
emitln(" PEEK = eof")
|
||||||
emitln(" return char")
|
emitln(" else:")
|
||||||
|
emitln(" PEEK = char")
|
||||||
|
emitln(" return PEEK")
|
||||||
emitln("")
|
emitln("")
|
||||||
emitln("def peek():")
|
emitln("peek()")
|
||||||
emitln(" return STDINPEEK")
|
|
||||||
emitln("")
|
emitln("")
|
||||||
emitln("def skip():")
|
emitln("def skip():")
|
||||||
emitln(" global STDINCOLNO")
|
emitln(" global LINE")
|
||||||
emitln(" global STDINLINENO")
|
emitln(" global PEEK")
|
||||||
emitln(" global STDINPEEK")
|
emitln(" if eol == PEEK:")
|
||||||
emitln(" if eol == STDINPEEK:")
|
emitln(" LINE += 1")
|
||||||
emitln(" STDINLINENO += 1")
|
emitln(" PEEK = None")
|
||||||
emitln(" STDINCOLNO = 0")
|
|
||||||
emitln(" STDINCOLNO += 1")
|
|
||||||
emitln(" STDINPEEK = _readchar()")
|
|
||||||
emitln("")
|
|
||||||
emitln("def stdinlineno():")
|
|
||||||
emitln(" global STDINLINENO")
|
|
||||||
emitln(" return str(STDINLINENO)")
|
|
||||||
emitln("")
|
|
||||||
emitln("def stdincolno():")
|
|
||||||
emitln(" global STDINCOLNO")
|
|
||||||
emitln(" return str(STDINCOLNO)")
|
|
||||||
emitln("")
|
emitln("")
|
||||||
|
emitln("def skipchar(char):")
|
||||||
|
emitln(" global LINE")
|
||||||
|
emitln(" assert char == peek(), (LINE, char, peek())")
|
||||||
emitln(" skip()")
|
emitln(" skip()")
|
||||||
emitln("")
|
emitln("")
|
||||||
|
|
||||||
|
|||||||
1
1-lang0py/.gitignore
vendored
1
1-lang0py/.gitignore
vendored
@ -2,4 +2,3 @@
|
|||||||
/lang0py*.exe
|
/lang0py*.exe
|
||||||
/lang0py*.o
|
/lang0py*.o
|
||||||
/lang0py*.py
|
/lang0py*.py
|
||||||
/lang0py*.py.tmp
|
|
||||||
|
|||||||
@ -18,22 +18,18 @@ all: lang0py.exe
|
|||||||
$(CYTHON) -3 --embed $<
|
$(CYTHON) -3 --embed $<
|
||||||
|
|
||||||
lang0py0.py: lang0py.lang0 $(LANG0PY)
|
lang0py0.py: lang0py.lang0 $(LANG0PY)
|
||||||
cat $< | $(LANG0PY) > $@.tmp
|
cat $< | $(LANG0PY) > $@
|
||||||
mv $@.tmp $@
|
|
||||||
|
|
||||||
lang0py1.py: lang0py.lang0 lang0py0.exe
|
lang0py1.py: lang0py.lang0 lang0py0.exe
|
||||||
cat $< | ./lang0py0.exe > $@.tmp
|
cat $< | ./lang0py0.exe > $@
|
||||||
mv $@.tmp $@
|
|
||||||
# Cannot diff on the first iteration - platform change
|
# Cannot diff on the first iteration - platform change
|
||||||
|
|
||||||
lang0py2.py: lang0py.lang0 lang0py1.exe
|
lang0py2.py: lang0py.lang0 lang0py1.exe
|
||||||
cat $< | ./lang0py1.exe > $@.tmp
|
cat $< | ./lang0py1.exe > $@
|
||||||
mv $@.tmp $@
|
|
||||||
-diff lang0py1.py lang0py2.py
|
-diff lang0py1.py lang0py2.py
|
||||||
|
|
||||||
lang0py.py: lang0py.lang0 lang0py2.exe
|
lang0py.py: lang0py.lang0 lang0py2.exe
|
||||||
cat $< | ./lang0py2.exe > $@.tmp
|
cat $< | ./lang0py2.exe > $@
|
||||||
mv $@.tmp $@
|
|
||||||
-diff lang0py2.py lang0py.py
|
-diff lang0py2.py lang0py.py
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@ -1,14 +1,3 @@
|
|||||||
skipchar exp:
|
|
||||||
declare act
|
|
||||||
declare lineno
|
|
||||||
declare colno
|
|
||||||
calc act peek
|
|
||||||
calc lineno stdinlineno
|
|
||||||
calc colno stdincolno
|
|
||||||
check eq exp act : "Unexpected character" act "expected" exp "at" lineno colno
|
|
||||||
skip
|
|
||||||
/
|
|
||||||
|
|
||||||
emitln data:
|
emitln data:
|
||||||
emit data
|
emit data
|
||||||
emit eol
|
emit eol
|
||||||
@ -162,96 +151,12 @@ parsestatreturn indent:
|
|||||||
calc isspace eq char " "
|
calc isspace eq char " "
|
||||||
if isspace
|
if isspace
|
||||||
skip
|
skip
|
||||||
calc char peek
|
|
||||||
calc isquote eq char quote
|
|
||||||
calc isnotquote not isquote
|
|
||||||
if isquote
|
|
||||||
parseconststring
|
|
||||||
/
|
|
||||||
if isnotquote
|
|
||||||
parseexprvarref
|
parseexprvarref
|
||||||
/
|
/
|
||||||
/
|
|
||||||
emit eol
|
emit eol
|
||||||
skipchar eol
|
skipchar eol
|
||||||
/
|
/
|
||||||
|
|
||||||
parsestatcheck indent:
|
|
||||||
declare char
|
|
||||||
declare funcname
|
|
||||||
declare iscolon
|
|
||||||
declare isnotquote
|
|
||||||
declare isquote
|
|
||||||
declare notfirst
|
|
||||||
|
|
||||||
skipchar " "
|
|
||||||
emit indent
|
|
||||||
emit "assert "
|
|
||||||
|
|
||||||
calc funcname lexident
|
|
||||||
emit funcname
|
|
||||||
emit "("
|
|
||||||
|
|
||||||
set notfirst ""
|
|
||||||
forever
|
|
||||||
skipchar " "
|
|
||||||
calc char peek
|
|
||||||
calc iscolon eq char ":"
|
|
||||||
if iscolon
|
|
||||||
break
|
|
||||||
/
|
|
||||||
|
|
||||||
if notfirst
|
|
||||||
emit ", "
|
|
||||||
/
|
|
||||||
|
|
||||||
calc char peek
|
|
||||||
calc isquote eq char quote
|
|
||||||
calc isnotquote not isquote
|
|
||||||
if isquote
|
|
||||||
parseconststring
|
|
||||||
/
|
|
||||||
if isnotquote
|
|
||||||
parseexprvarref
|
|
||||||
/
|
|
||||||
|
|
||||||
set notfirst "1"
|
|
||||||
/
|
|
||||||
|
|
||||||
skipchar ":"
|
|
||||||
|
|
||||||
emit "), ("
|
|
||||||
set notfirst ""
|
|
||||||
|
|
||||||
forever
|
|
||||||
skipchar " "
|
|
||||||
|
|
||||||
if notfirst
|
|
||||||
emit ", "
|
|
||||||
/
|
|
||||||
|
|
||||||
calc char peek
|
|
||||||
calc isquote eq char quote
|
|
||||||
calc isnotquote not isquote
|
|
||||||
if isquote
|
|
||||||
parseconststring
|
|
||||||
/
|
|
||||||
if isnotquote
|
|
||||||
parseexprvarref
|
|
||||||
/
|
|
||||||
|
|
||||||
calc char peek
|
|
||||||
calc iseol eq char eol
|
|
||||||
if iseol
|
|
||||||
break
|
|
||||||
/
|
|
||||||
|
|
||||||
set notfirst "1"
|
|
||||||
/
|
|
||||||
|
|
||||||
emitln ")"
|
|
||||||
/
|
|
||||||
|
|
||||||
parsestattrace indent:
|
parsestattrace indent:
|
||||||
emit indent
|
emit indent
|
||||||
emit "trace("
|
emit "trace("
|
||||||
@ -309,11 +214,6 @@ parsestat indent:
|
|||||||
parsestattrace indent
|
parsestattrace indent
|
||||||
return
|
return
|
||||||
/
|
/
|
||||||
calc ischeck eq call "check"
|
|
||||||
if ischeck
|
|
||||||
parsestatcheck indent
|
|
||||||
return
|
|
||||||
/
|
|
||||||
emit indent
|
emit indent
|
||||||
emit call
|
emit call
|
||||||
emit "("
|
emit "("
|
||||||
@ -380,11 +280,16 @@ parseblock indent:
|
|||||||
|
|
||||||
parsefunc:
|
parsefunc:
|
||||||
calc funcname lexident
|
calc funcname lexident
|
||||||
|
calc char peek
|
||||||
|
calc iseoblock eq char "/"
|
||||||
|
if iseoblock
|
||||||
|
return
|
||||||
|
/
|
||||||
trace funcname
|
trace funcname
|
||||||
emit "def "
|
emit "def "
|
||||||
emit funcname
|
emit funcname
|
||||||
emit "("
|
emit "("
|
||||||
set isnotfirst ""
|
set first "1"
|
||||||
forever
|
forever
|
||||||
calc char peek
|
calc char peek
|
||||||
calc isspace eq char " "
|
calc isspace eq char " "
|
||||||
@ -394,11 +299,13 @@ parsefunc:
|
|||||||
/
|
/
|
||||||
skip
|
skip
|
||||||
calc var lexident
|
calc var lexident
|
||||||
|
calc isfirst eq first "1"
|
||||||
|
calc isnotfirst not isfirst
|
||||||
if isnotfirst
|
if isnotfirst
|
||||||
emit ", "
|
emit ", "
|
||||||
/
|
/
|
||||||
emit var
|
emit var
|
||||||
set isnotfirst "1"
|
set first "0"
|
||||||
/
|
/
|
||||||
calc char peek
|
calc char peek
|
||||||
calc iseoblock eq char "/"
|
calc iseoblock eq char "/"
|
||||||
@ -432,48 +339,40 @@ emitheader:
|
|||||||
emitln ""
|
emitln ""
|
||||||
emitln "def emit(string):"
|
emitln "def emit(string):"
|
||||||
emitln " sys.stdout.write(string)"
|
emitln " sys.stdout.write(string)"
|
||||||
emitln " sys.stdout.flush()"
|
|
||||||
emitln ""
|
emitln ""
|
||||||
emitln "def trace(header, value):"
|
emitln "def trace(header, value):"
|
||||||
emitln " if os.environ.get('TRACE'):"
|
emitln " if os.environ.get('TRACE'):"
|
||||||
emitln " sys.stderr.write(f'{header}={value!r}\\n')"
|
emitln " sys.stderr.write(f'{header}={value!r}\')"
|
||||||
emitln ""
|
emitln ""
|
||||||
emitln "eof = chr(0)"
|
emitln "eof = chr(0)"
|
||||||
emitln "eol = chr(10)"
|
emitln "eol = chr(10)"
|
||||||
emitln "quote = chr(34)"
|
emitln "quote = chr(34)"
|
||||||
|
emitln "PEEK = None"
|
||||||
|
emitln "LINE = 1"
|
||||||
emitln ""
|
emitln ""
|
||||||
emitln "STDINCOLNO = 0"
|
emitln "def peek():"
|
||||||
emitln "STDINLINENO = 1"
|
emitln " global PEEK"
|
||||||
emitln "STDINPEEK = None"
|
emitln " if PEEK is None:"
|
||||||
emitln ""
|
|
||||||
emitln "def _readchar():"
|
|
||||||
emitln " char = sys.stdin.read(1)"
|
emitln " char = sys.stdin.read(1)"
|
||||||
emitln " trace('char', char)"
|
emitln " trace('char', char)"
|
||||||
emitln " if not char:"
|
emitln " if not char:"
|
||||||
emitln " return eof"
|
emitln " PEEK = eof"
|
||||||
emitln " return char"
|
emitln " else:"
|
||||||
|
emitln " PEEK = char"
|
||||||
|
emitln " return PEEK"
|
||||||
emitln ""
|
emitln ""
|
||||||
emitln "def peek():"
|
emitln "peek()"
|
||||||
emitln " return STDINPEEK"
|
|
||||||
emitln ""
|
emitln ""
|
||||||
emitln "def skip():"
|
emitln "def skip():"
|
||||||
emitln " global STDINCOLNO"
|
emitln " global LINE"
|
||||||
emitln " global STDINLINENO"
|
emitln " global PEEK"
|
||||||
emitln " global STDINPEEK"
|
emitln " if eol == PEEK:"
|
||||||
emitln " if eol == STDINPEEK:"
|
emitln " LINE += 1"
|
||||||
emitln " STDINLINENO += 1"
|
emitln " PEEK = None"
|
||||||
emitln " STDINCOLNO = 0"
|
|
||||||
emitln " STDINCOLNO += 1"
|
|
||||||
emitln " STDINPEEK = _readchar()"
|
|
||||||
emitln ""
|
|
||||||
emitln "def stdinlineno():"
|
|
||||||
emitln " global STDINLINENO"
|
|
||||||
emitln " return str(STDINLINENO)"
|
|
||||||
emitln ""
|
|
||||||
emitln "def stdincolno():"
|
|
||||||
emitln " global STDINCOLNO"
|
|
||||||
emitln " return str(STDINCOLNO)"
|
|
||||||
emitln ""
|
emitln ""
|
||||||
|
emitln "def skipchar(char):"
|
||||||
|
emitln " global LINE"
|
||||||
|
emitln " assert char == peek(), (LINE, char, peek())"
|
||||||
emitln " skip()"
|
emitln " skip()"
|
||||||
emitln ""
|
emitln ""
|
||||||
/
|
/
|
||||||
|
|||||||
1
2-lang0c/.gitignore
vendored
1
2-lang0c/.gitignore
vendored
@ -1,5 +1,4 @@
|
|||||||
/lang0c*.c
|
/lang0c*.c
|
||||||
/lang0c*.c.tmp
|
|
||||||
/lang0c*.exe
|
/lang0c*.exe
|
||||||
/lang0c*.o
|
/lang0c*.o
|
||||||
/lang0c*.py
|
/lang0c*.py
|
||||||
|
|||||||
@ -15,8 +15,7 @@ all: lang0c.exe
|
|||||||
gcc -c $<
|
gcc -c $<
|
||||||
|
|
||||||
lang0c0.py: lang0c.lang0 $(LANG0PY)
|
lang0c0.py: lang0c.lang0 $(LANG0PY)
|
||||||
cat $< | $(LANG0PY) > $@.tmp
|
cat $< | $(LANG0PY) > $@
|
||||||
mv $@.tmp $@
|
|
||||||
|
|
||||||
lang0c0.c: lang0c0.py
|
lang0c0.c: lang0c0.py
|
||||||
$(CYTHON) -3 --embed $<
|
$(CYTHON) -3 --embed $<
|
||||||
@ -28,18 +27,15 @@ lang0c0.exe: lang0c0.o
|
|||||||
gcc -o $@ $< -lpython$(PYVERSION)
|
gcc -o $@ $< -lpython$(PYVERSION)
|
||||||
|
|
||||||
lang0c1.c: lang0c.lang0 lang0c0.exe
|
lang0c1.c: lang0c.lang0 lang0c0.exe
|
||||||
cat $< | ./lang0c0.exe > $@.tmp
|
cat $< | ./lang0c0.exe > $@
|
||||||
mv $@.tmp $@
|
|
||||||
# Cannot diff on the first iteration - platform change
|
# Cannot diff on the first iteration - platform change
|
||||||
|
|
||||||
lang0c2.c: lang0c.lang0 lang0c1.exe
|
lang0c2.c: lang0c.lang0 lang0c1.exe
|
||||||
cat $< | ./lang0c1.exe > $@.tmp
|
cat $< | ./lang0c1.exe > $@
|
||||||
mv $@.tmp $@
|
|
||||||
-diff lang0c1.c lang0c2.c
|
-diff lang0c1.c lang0c2.c
|
||||||
|
|
||||||
lang0c.c: lang0c.lang0 lang0c2.exe
|
lang0c.c: lang0c.lang0 lang0c2.exe
|
||||||
cat $< | ./lang0c2.exe > $@.tmp
|
cat $< | ./lang0c2.exe > $@
|
||||||
mv $@.tmp $@
|
|
||||||
-diff lang0c2.c lang0c.c
|
-diff lang0c2.c lang0c.c
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|||||||
@ -1,14 +1,3 @@
|
|||||||
skipchar exp:
|
|
||||||
declare act
|
|
||||||
declare lineno
|
|
||||||
declare colno
|
|
||||||
calc act peek
|
|
||||||
calc lineno stdinlineno
|
|
||||||
calc colno stdincolno
|
|
||||||
check eq exp act : "Unexpected character" act "expected" exp "at" lineno colno
|
|
||||||
skip
|
|
||||||
/
|
|
||||||
|
|
||||||
emitln data:
|
emitln data:
|
||||||
emit data
|
emit data
|
||||||
emit eol
|
emit eol
|
||||||
@ -206,8 +195,6 @@ parsestatbreak indent:
|
|||||||
parsestatreturn indent:
|
parsestatreturn indent:
|
||||||
declare char
|
declare char
|
||||||
declare isspace
|
declare isspace
|
||||||
declare isnotquote
|
|
||||||
declare isquote
|
|
||||||
declare isnotspace
|
declare isnotspace
|
||||||
emit indent
|
emit indent
|
||||||
emit "return "
|
emit "return "
|
||||||
@ -216,16 +203,8 @@ parsestatreturn indent:
|
|||||||
calc isnotspace not isspace
|
calc isnotspace not isspace
|
||||||
if isspace
|
if isspace
|
||||||
skip
|
skip
|
||||||
calc char peek
|
|
||||||
calc isquote eq char quote
|
|
||||||
calc isnotquote not isquote
|
|
||||||
if isquote
|
|
||||||
parseconststring
|
|
||||||
/
|
|
||||||
if isnotquote
|
|
||||||
parseexprvarref
|
parseexprvarref
|
||||||
/
|
/
|
||||||
/
|
|
||||||
if isnotspace
|
if isnotspace
|
||||||
emit "0"
|
emit "0"
|
||||||
/
|
/
|
||||||
@ -235,98 +214,6 @@ parsestatreturn indent:
|
|||||||
return
|
return
|
||||||
/
|
/
|
||||||
|
|
||||||
parsestatcheck indent:
|
|
||||||
declare char
|
|
||||||
declare funcname
|
|
||||||
declare iscolon
|
|
||||||
declare iseol
|
|
||||||
declare isnotquote
|
|
||||||
declare isquote
|
|
||||||
declare notfirst
|
|
||||||
|
|
||||||
skipchar " "
|
|
||||||
emit indent
|
|
||||||
emit "if( 0 == strlen("
|
|
||||||
|
|
||||||
calc funcname lexident
|
|
||||||
emit funcname
|
|
||||||
emit "("
|
|
||||||
|
|
||||||
set notfirst ""
|
|
||||||
forever
|
|
||||||
skipchar " "
|
|
||||||
calc char peek
|
|
||||||
calc iscolon eq char ":"
|
|
||||||
if iscolon
|
|
||||||
break
|
|
||||||
/
|
|
||||||
|
|
||||||
if notfirst
|
|
||||||
emit ", "
|
|
||||||
/
|
|
||||||
|
|
||||||
calc char peek
|
|
||||||
calc isquote eq char quote
|
|
||||||
calc isnotquote not isquote
|
|
||||||
if isquote
|
|
||||||
parseconststring
|
|
||||||
/
|
|
||||||
if isnotquote
|
|
||||||
parseexprvarref
|
|
||||||
/
|
|
||||||
|
|
||||||
set notfirst "1"
|
|
||||||
/
|
|
||||||
|
|
||||||
skipchar ":"
|
|
||||||
|
|
||||||
emitln ")) )"
|
|
||||||
emit indent
|
|
||||||
emitln "{"
|
|
||||||
|
|
||||||
emit " fprintf(stderr, "
|
|
||||||
emit quote
|
|
||||||
emit "%s"
|
|
||||||
emit quote
|
|
||||||
emit ", "
|
|
||||||
emit quote
|
|
||||||
emit "ERROR:"
|
|
||||||
emit quote
|
|
||||||
emitln ");"
|
|
||||||
|
|
||||||
forever
|
|
||||||
skipchar " "
|
|
||||||
|
|
||||||
emit indent
|
|
||||||
emit " fprintf(stderr, "
|
|
||||||
emit quote
|
|
||||||
emit " %s"
|
|
||||||
emit quote
|
|
||||||
emit ", "
|
|
||||||
calc char peek
|
|
||||||
calc isquote eq char quote
|
|
||||||
calc isnotquote not isquote
|
|
||||||
if isquote
|
|
||||||
parseconststring
|
|
||||||
/
|
|
||||||
if isnotquote
|
|
||||||
parseexprvarref
|
|
||||||
/
|
|
||||||
emitln ");"
|
|
||||||
|
|
||||||
calc char peek
|
|
||||||
calc iseol eq char eol
|
|
||||||
if iseol
|
|
||||||
break
|
|
||||||
/
|
|
||||||
/
|
|
||||||
|
|
||||||
emit indent
|
|
||||||
emitln " exit(1);"
|
|
||||||
emit indent
|
|
||||||
emitln "}"
|
|
||||||
/
|
|
||||||
|
|
||||||
parsestattrace indent:
|
parsestattrace indent:
|
||||||
declare varname
|
declare varname
|
||||||
emit indent
|
emit indent
|
||||||
@ -391,11 +278,6 @@ parsestat indent:
|
|||||||
parsestatreturn indent
|
parsestatreturn indent
|
||||||
return
|
return
|
||||||
/
|
/
|
||||||
calc iscall eq call "check"
|
|
||||||
if iscall
|
|
||||||
parsestatcheck indent
|
|
||||||
return
|
|
||||||
/
|
|
||||||
calc iscall eq call "trace"
|
calc iscall eq call "trace"
|
||||||
if iscall
|
if iscall
|
||||||
parsestattrace indent
|
parsestattrace indent
|
||||||
@ -589,55 +471,35 @@ emitheader:
|
|||||||
emitln " return 0;"
|
emitln " return 0;"
|
||||||
emitln "}"
|
emitln "}"
|
||||||
emitln ""
|
emitln ""
|
||||||
emitln "int STDINCOLNO = 1;"
|
emitln "int LINE = 1;"
|
||||||
emitln "int STDINLINENO = 1;"
|
|
||||||
emitln "char * STDINPEEK = 0;"
|
|
||||||
emitln ""
|
emitln ""
|
||||||
emitln "char * _readchar()"
|
emitln "char * peek()"
|
||||||
emitln "{"
|
emitln "{"
|
||||||
emitln " char * res = malloc(2*sizeof(char));"
|
emitln " char * res = malloc(2*sizeof(char));"
|
||||||
emitln " res[0] = getc(stdin);"
|
emitln " res[0] = getc(stdin);"
|
||||||
emitln " res[1] = 0;"
|
emitln " res[1] = 0;"
|
||||||
|
emitln " ungetc(res[0], stdin);"
|
||||||
emitln " return res;"
|
emitln " return res;"
|
||||||
emitln "}"
|
emitln "}"
|
||||||
emitln ""
|
emitln ""
|
||||||
emitln "char * peek()"
|
|
||||||
emitln "{"
|
|
||||||
emitln " if( !STDINPEEK ) STDINPEEK = _readchar(); // First byte read"
|
|
||||||
emitln " return STDINPEEK;"
|
|
||||||
emitln "}"
|
|
||||||
emitln ""
|
|
||||||
emitln "void skip()"
|
emitln "void skip()"
|
||||||
emitln "{"
|
emitln "{"
|
||||||
emitln " if( !STDINPEEK ) STDINPEEK = _readchar(); // First byte read, not even peek()'d"
|
emitln " char c = getc(stdin);"
|
||||||
emitln " if( STDINPEEK[0] == 10 ) {"
|
emitln " if( c == 10 ) LINE += 1;"
|
||||||
emitln " STDINLINENO += 1;"
|
|
||||||
emitln " STDINCOLNO = 0;"
|
|
||||||
emitln " }"
|
|
||||||
emitln " STDINCOLNO += 1;"
|
|
||||||
emitln " STDINPEEK = _readchar();"
|
|
||||||
emitln "}"
|
emitln "}"
|
||||||
emitln ""
|
emitln ""
|
||||||
emitln "char * stdinlineno()"
|
emitln "void skipchar(char * chr)"
|
||||||
emitln "{"
|
emitln "{"
|
||||||
emitln " char * res = malloc(8*sizeof(char));"
|
emitln " assert(strlen(chr) == 1);"
|
||||||
emit " sprintf(res, "
|
emitln " char * act = peek();"
|
||||||
|
emitln " assert(strlen(act) == 1);"
|
||||||
|
emitln " if( chr[0] == act[0] ) {skip(); return;};"
|
||||||
|
emit " fprintf(stderr, "
|
||||||
emit quote
|
emit quote
|
||||||
emit "%d"
|
emit "Expected '%c' on line %d but saw '%c' instead%c"
|
||||||
emit quote
|
emit quote
|
||||||
emitln ", STDINLINENO);"
|
emitln ", chr[0], LINE, act[0], 10);"
|
||||||
emitln " return res;"
|
emitln " exit(1);"
|
||||||
emitln "}"
|
|
||||||
emitln ""
|
|
||||||
emitln "char * stdincolno()"
|
|
||||||
emitln "{"
|
|
||||||
emitln " char * res = malloc(8*sizeof(char));"
|
|
||||||
emit " sprintf(res, "
|
|
||||||
emit quote
|
|
||||||
emit "%d"
|
|
||||||
emit quote
|
|
||||||
emitln ", STDINCOLNO);"
|
|
||||||
emitln " return res;"
|
|
||||||
emitln "}"
|
emitln "}"
|
||||||
emitln ""
|
emitln ""
|
||||||
return
|
return
|
||||||
|
|||||||
12
README.md
12
README.md
@ -113,10 +113,6 @@ Returns the given value. You can not give an argument if your function is never
|
|||||||
|
|
||||||
### Builtins
|
### Builtins
|
||||||
|
|
||||||
#### check func [arg0..] : msg [arg0..]
|
|
||||||
|
|
||||||
Calls the given function with the given arguments. If the function's return value is not found to be true, outputs the given `msg` and halts the program.
|
|
||||||
|
|
||||||
#### trace
|
#### trace
|
||||||
|
|
||||||
Writes the name and value of the variable passed to stderr if the TRACE environment variable is set.
|
Writes the name and value of the variable passed to stderr if the TRACE environment variable is set.
|
||||||
@ -151,13 +147,9 @@ Checks stdin for the next character and returns it.
|
|||||||
|
|
||||||
Advances stdin a single character.
|
Advances stdin a single character.
|
||||||
|
|
||||||
#### stdincolno
|
#### skipchar a
|
||||||
|
|
||||||
Returns the column number for stdin (starting at 1)
|
Advances stdin a single character, if it matches the first character of `a`. Otherwise, exits the program.
|
||||||
|
|
||||||
#### stdinlineno
|
|
||||||
|
|
||||||
Returns the line number for stdin (starting at 1)
|
|
||||||
|
|
||||||
### Typing
|
### Typing
|
||||||
|
|
||||||
|
|||||||
@ -1,35 +1,29 @@
|
|||||||
.SUFFIXES:
|
.SUFFIXES:
|
||||||
.PHONY: all clean
|
.PHONY: all clean
|
||||||
.PRECIOUS: build/%.it0.py build/%.it0.c
|
|
||||||
.DELETE_ON_ERROR:
|
|
||||||
|
|
||||||
PYVERSION=3.10
|
PYVERSION=3.10
|
||||||
PYPREFIX=/usr
|
PYPREFIX=/usr
|
||||||
CYTHON=cython3
|
CYTHON=cython3
|
||||||
CC=gcc
|
CC=gcc
|
||||||
|
|
||||||
# builtincheckfalse is separate since it's supposed to crash. It's a test for the test 'framework', if you will.
|
TESTLIST=$(shell ls *.lang0 | sed 's/.lang0//')
|
||||||
TESTLIST=$(shell ls *.lang0 | grep -v 'builtincheckfalse' | sed 's/.lang0//')
|
|
||||||
|
|
||||||
all: check
|
all: check
|
||||||
|
|
||||||
check: all-it0.results all-it1.results all-it2.results
|
check: all-it0.results all-it1.results all-it2.results
|
||||||
! grep -v 'Success' $^
|
! grep -v 'Success' $^
|
||||||
|
|
||||||
all-it0.results: $(addprefix build/,$(addsuffix .it0, $(TESTLIST))) build/builtincheckfalse.it0
|
all-it0.results: $(addprefix build/,$(addsuffix .it0, $(TESTLIST)))
|
||||||
-rm -f $@
|
-rm -f $@
|
||||||
cat test-input.txt | build/builtincheckfalse.it0 2> /dev/null 2>&1 | grep 'Success'
|
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; echo "Hello" | ./build/$(test).it0 >> $@ ; echo "" >> $@ ;)
|
||||||
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; cat test-input.txt | ./build/$(test).it0 >> $@ ; echo "" >> $@ ;)
|
|
||||||
|
|
||||||
all-it1.results: $(addprefix build/,$(addsuffix .it1, $(TESTLIST))) build/builtincheckfalse.it1
|
all-it1.results: $(addprefix build/,$(addsuffix .it1, $(TESTLIST)))
|
||||||
-rm -f $@
|
-rm -f $@
|
||||||
cat test-input.txt | build/builtincheckfalse.it1 2> /dev/null 2>&1 | grep 'Success'
|
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; echo "Hello" | ./build/$(test).it1 >> $@ ; echo "" >> $@ ;)
|
||||||
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; cat test-input.txt | ./build/$(test).it1 >> $@ ; echo "" >> $@ ;)
|
|
||||||
|
|
||||||
all-it2.results: $(addprefix build/,$(addsuffix .it2, $(TESTLIST))) build/builtincheckfalse.it2
|
all-it2.results: $(addprefix build/,$(addsuffix .it2, $(TESTLIST)))
|
||||||
-rm -f $@
|
-rm -f $@
|
||||||
cat test-input.txt | build/builtincheckfalse.it2 2> /dev/null 2>&1 | grep 'Success'
|
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; echo "Hello" | ./build/$(test).it2 >> $@ ; echo "" >> $@ ;)
|
||||||
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; cat test-input.txt | ./build/$(test).it2 >> $@ ; echo "" >> $@ ;)
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -f *.results build/*.it0* build/*.it1* build/*.it2*
|
-rm -f *.results build/*.it0* build/*.it1* build/*.it2*
|
||||||
@ -37,12 +31,8 @@ clean:
|
|||||||
###
|
###
|
||||||
# it0
|
# it0
|
||||||
|
|
||||||
../0-lang0py/lang0py.exe: ../0-lang0py/lang0py.py
|
|
||||||
$(MAKE) -C ../0-lang0py
|
|
||||||
|
|
||||||
build/%.it0.py: %.lang0 ../0-lang0py/lang0py.exe
|
build/%.it0.py: %.lang0 ../0-lang0py/lang0py.exe
|
||||||
cat $< | ../0-lang0py/lang0py.exe > $@.tmp
|
cat $< | ../0-lang0py/lang0py.exe > $@
|
||||||
mv $@.tmp $@
|
|
||||||
|
|
||||||
build/%.it0.c: build/%.it0.py
|
build/%.it0.c: build/%.it0.py
|
||||||
$(CYTHON) -3 --embed -o $@ $^
|
$(CYTHON) -3 --embed -o $@ $^
|
||||||
@ -56,12 +46,8 @@ build/%.it0: build/%.it0.o
|
|||||||
###
|
###
|
||||||
# it1
|
# it1
|
||||||
|
|
||||||
../1-lang0py/lang0py.exe: ../0-lang0py/lang0py.exe ../1-lang0py/lang0py.lang0
|
|
||||||
$(MAKE) -C ../1-lang0py
|
|
||||||
|
|
||||||
build/%.it1.py: %.lang0 ../1-lang0py/lang0py.exe
|
build/%.it1.py: %.lang0 ../1-lang0py/lang0py.exe
|
||||||
cat $< | ../1-lang0py/lang0py.exe > $@.tmp
|
cat $< | ../1-lang0py/lang0py.exe > $@
|
||||||
mv $@.tmp $@
|
|
||||||
|
|
||||||
build/%.it1.c: build/%.it1.py
|
build/%.it1.c: build/%.it1.py
|
||||||
$(CYTHON) -3 --embed -o $@ $^
|
$(CYTHON) -3 --embed -o $@ $^
|
||||||
@ -75,12 +61,8 @@ build/%.it1: build/%.it1.o
|
|||||||
###
|
###
|
||||||
# it2
|
# it2
|
||||||
|
|
||||||
../2-lang0c/lang0c.exe: ../0-lang0py/lang0py.exe ../1-lang0py/lang0py.exe ../2-lang0c/lang0c.lang0
|
|
||||||
$(MAKE) -C ../2-lang0c
|
|
||||||
|
|
||||||
build/%.it2.c: %.lang0 ../2-lang0c/lang0c.exe
|
build/%.it2.c: %.lang0 ../2-lang0c/lang0c.exe
|
||||||
cat $< | ../2-lang0c/lang0c.exe > $@.tmp
|
cat $< | ../2-lang0c/lang0c.exe > $@
|
||||||
mv $@.tmp $@
|
|
||||||
|
|
||||||
build/%.it2.o: build/%.it2.c
|
build/%.it2.o: build/%.it2.c
|
||||||
$(CC) -o $@ -c $^ -I$(PYPREFIX)/include/python$(PYVERSION)
|
$(CC) -o $@ -c $^ -I$(PYPREFIX)/include/python$(PYVERSION)
|
||||||
|
|||||||
3
tests/build/.gitignore
vendored
3
tests/build/.gitignore
vendored
@ -2,13 +2,10 @@
|
|||||||
/*.it0.c
|
/*.it0.c
|
||||||
/*.it0.o
|
/*.it0.o
|
||||||
/*.it0.py
|
/*.it0.py
|
||||||
/*.it0.py.tmp
|
|
||||||
/*.it1
|
/*.it1
|
||||||
/*.it1.c
|
/*.it1.c
|
||||||
/*.it1.o
|
/*.it1.o
|
||||||
/*.it1.py
|
/*.it1.py
|
||||||
/*.it1.py.tmp
|
|
||||||
/*.it2
|
/*.it2
|
||||||
/*.it2.c
|
/*.it2.c
|
||||||
/*.it2.c.tmp
|
|
||||||
/*.it2.o
|
/*.it2.o
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
main:
|
|
||||||
check not "1" : "Success"
|
|
||||||
/
|
|
||||||
@ -1,4 +0,0 @@
|
|||||||
main:
|
|
||||||
check not "" : "Failure"
|
|
||||||
emit "Success"
|
|
||||||
/
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
func:
|
|
||||||
return "Success"
|
|
||||||
/
|
|
||||||
|
|
||||||
main:
|
|
||||||
declare result
|
|
||||||
calc result func
|
|
||||||
emit result
|
|
||||||
/
|
|
||||||
11
tests/parsingpredeclaredfunction.lang0
Normal file
11
tests/parsingpredeclaredfunction.lang0
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
func result/
|
||||||
|
|
||||||
|
main:
|
||||||
|
declare result
|
||||||
|
calc result func "Success"
|
||||||
|
emit result
|
||||||
|
/
|
||||||
|
|
||||||
|
func result:
|
||||||
|
return result
|
||||||
|
/
|
||||||
@ -1,10 +0,0 @@
|
|||||||
func/
|
|
||||||
|
|
||||||
main:
|
|
||||||
check func : "The function should return 1, even though it is not defined yet"
|
|
||||||
emit "Success"
|
|
||||||
/
|
|
||||||
|
|
||||||
func:
|
|
||||||
return "1"
|
|
||||||
/
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
func arg/
|
|
||||||
|
|
||||||
main:
|
|
||||||
check func "1" : "The function should return 1, even though it is not defined yet"
|
|
||||||
emit "Success"
|
|
||||||
/
|
|
||||||
|
|
||||||
func arg:
|
|
||||||
return arg
|
|
||||||
/
|
|
||||||
@ -1,86 +0,0 @@
|
|||||||
main:
|
|
||||||
declare char
|
|
||||||
declare colno
|
|
||||||
declare lineno
|
|
||||||
|
|
||||||
calc char peek
|
|
||||||
calc colno stdincolno
|
|
||||||
calc lineno stdinlineno
|
|
||||||
check eq char "H" : "Read: H" char
|
|
||||||
check eq colno "1" : "The column number should not have advanced yet" colno
|
|
||||||
check eq lineno "1" : "The line number should not have advanced yet" lineno
|
|
||||||
skip
|
|
||||||
|
|
||||||
calc char peek
|
|
||||||
calc colno stdincolno
|
|
||||||
calc lineno stdinlineno
|
|
||||||
check eq char "e" : "Read: e" char
|
|
||||||
check eq colno "2" : "The column number should have been advanced by 1" colno
|
|
||||||
check eq lineno "1" : "The line number should not have advanced yet" lineno
|
|
||||||
skip
|
|
||||||
|
|
||||||
calc char peek
|
|
||||||
calc colno stdincolno
|
|
||||||
calc lineno stdinlineno
|
|
||||||
check eq char "l" : "Read: l" char
|
|
||||||
check eq colno "3" : "The column number should have been advanced by 2" colno
|
|
||||||
check eq lineno "1" : "The line number should not have advanced yet" lineno
|
|
||||||
skip
|
|
||||||
|
|
||||||
calc char peek
|
|
||||||
calc colno stdincolno
|
|
||||||
calc lineno stdinlineno
|
|
||||||
check eq char "l" : "Read: l" char
|
|
||||||
check eq colno "4" : "The column number should have been advanced by 3" colno
|
|
||||||
check eq lineno "1" : "The line number should not have advanced yet" lineno
|
|
||||||
skip
|
|
||||||
|
|
||||||
calc char peek
|
|
||||||
calc colno stdincolno
|
|
||||||
calc lineno stdinlineno
|
|
||||||
check eq char "o" : "Read: o" char
|
|
||||||
check eq colno "5" : "The column number should have been advanced by 4" colno
|
|
||||||
check eq lineno "1" : "The line number should not have advanced yet" lineno
|
|
||||||
skip
|
|
||||||
|
|
||||||
calc char peek
|
|
||||||
calc colno stdincolno
|
|
||||||
calc lineno stdinlineno
|
|
||||||
check eq char "!" : "Read: !" char
|
|
||||||
check eq colno "6" : "The column number should have been advanced by 5" colno
|
|
||||||
check eq lineno "1" : "The line number should not have advanced yet" lineno
|
|
||||||
skip
|
|
||||||
|
|
||||||
calc char peek
|
|
||||||
calc colno stdincolno
|
|
||||||
calc lineno stdinlineno
|
|
||||||
check eq char eol : "Read: eol" char
|
|
||||||
check eq colno "7" : "The column number should have been advanced by 6" colno
|
|
||||||
check eq lineno "1" : "The line number should not have advanced yet" lineno
|
|
||||||
skip
|
|
||||||
|
|
||||||
calc char peek
|
|
||||||
calc colno stdincolno
|
|
||||||
calc lineno stdinlineno
|
|
||||||
check eq char eol : "Read: eol" char
|
|
||||||
check eq colno "1" : "The column number should have been reset" colno
|
|
||||||
check eq lineno "2" : "The line number should have advanced by 1" lineno
|
|
||||||
skip
|
|
||||||
|
|
||||||
calc char peek
|
|
||||||
calc colno stdincolno
|
|
||||||
calc lineno stdinlineno
|
|
||||||
check eq char "T" : "Read: T" char
|
|
||||||
check eq colno "1" : "The column number should have been reset again" colno
|
|
||||||
check eq lineno "3" : "The line number should have advanced by 2" lineno
|
|
||||||
skip
|
|
||||||
|
|
||||||
calc char peek
|
|
||||||
calc colno stdincolno
|
|
||||||
calc lineno stdinlineno
|
|
||||||
check eq char "h" : "Read: h" char
|
|
||||||
check eq colno "2" : "The line number should not have been advanced by 1" colno
|
|
||||||
check eq lineno "3" : "The line number should not have advanced further" lineno
|
|
||||||
|
|
||||||
emit "Success"
|
|
||||||
/
|
|
||||||
@ -1,6 +1,5 @@
|
|||||||
main:
|
main:
|
||||||
declare result
|
declare result
|
||||||
calc result addstringchar "abc" "d"
|
calc result addstringchar "Succes" "s"
|
||||||
check eq result "abcd" : "Adding abc and d should be abcd"
|
emit result
|
||||||
emit "Success"
|
|
||||||
/
|
/
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
main:
|
main:
|
||||||
declare bool
|
declare bool
|
||||||
calc bool eq "1" "2"
|
calc bool eq "1" "2"
|
||||||
check not bool : "1 should not equal 2"
|
if bool
|
||||||
|
return
|
||||||
|
/
|
||||||
emit "Success"
|
emit "Success"
|
||||||
/
|
/
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
main:
|
main:
|
||||||
declare bool
|
declare bool
|
||||||
check eq "1" "1" : "1 should equal 1"
|
calc bool eq "1" "1"
|
||||||
|
if bool
|
||||||
emit "Success"
|
emit "Success"
|
||||||
/
|
/
|
||||||
|
/
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
main:
|
main:
|
||||||
declare bool
|
declare bool
|
||||||
calc bool lt "b" "a"
|
calc bool lt "b" "a"
|
||||||
check not bool : "a should should sort before b"
|
if bool
|
||||||
|
return
|
||||||
|
/
|
||||||
emit "Success"
|
emit "Success"
|
||||||
/
|
/
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
main:
|
main:
|
||||||
declare bool
|
declare bool
|
||||||
check lt "a" "b" : "a should should sort before b"
|
calc bool lt "a" "b"
|
||||||
|
if bool
|
||||||
emit "Success"
|
emit "Success"
|
||||||
/
|
/
|
||||||
|
/
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
main:
|
main:
|
||||||
declare char
|
declare char
|
||||||
|
declare ish
|
||||||
calc char peek
|
calc char peek
|
||||||
check eq char "H" : "The first byte we're passed is expected to be an 'H'"
|
calc ish eq char "H"
|
||||||
|
if ish
|
||||||
emit "Success"
|
emit "Success"
|
||||||
/
|
/
|
||||||
|
/
|
||||||
|
|||||||
@ -1,12 +1,24 @@
|
|||||||
main:
|
main:
|
||||||
declare char
|
declare char
|
||||||
|
declare ish
|
||||||
|
declare iso
|
||||||
|
declare notish
|
||||||
|
declare notiso
|
||||||
skip
|
skip
|
||||||
calc char peek
|
calc char peek
|
||||||
check eq char "e" : "The second byte we're passed is expected to be an 'e'"
|
calc ish eq char "e"
|
||||||
|
calc notish not ish
|
||||||
|
if notish
|
||||||
|
return
|
||||||
|
/
|
||||||
skip
|
skip
|
||||||
skip
|
skip
|
||||||
skip
|
skip
|
||||||
calc char peek
|
calc char peek
|
||||||
check eq char "o" : "The fifth byte we're passed is expected to be an 'o'"
|
calc iso eq char "o"
|
||||||
|
calc notiso not iso
|
||||||
|
if notish
|
||||||
|
return
|
||||||
|
/
|
||||||
emit "Success"
|
emit "Success"
|
||||||
/
|
/
|
||||||
|
|||||||
@ -1,3 +0,0 @@
|
|||||||
Hello!
|
|
||||||
|
|
||||||
This is an example of standard input.
|
|
||||||
Loading…
x
Reference in New Issue
Block a user