Compare commits

..

No commits in common. "2eaa763a2cd6f88a582f7c654ec3416bfc3646fc" and "a08084230e9a7a3141e8532ae504221240d70e35" have entirely different histories.

25 changed files with 142 additions and 575 deletions

View File

@ -3,7 +3,6 @@ import sys
def emit(string):
sys.stdout.write(string)
sys.stdout.flush()
def trace(header, value):
if os.environ.get('TRACE'):
@ -39,6 +38,11 @@ def skip():
PEEK = None
def skipchar(char):
global LINE
assert char == peek(), (LINE, char, peek())
skip()
def emitln(data):
emit(data)
emit(eol)
@ -56,11 +60,6 @@ def lexident():
return word
def skipchar(char):
global LINE
assert char == peek(), (LINE, char, peek())
skip()
def parseconststring():
skipchar(quote)
emit(quote)
@ -162,60 +161,10 @@ def parsestatreturn(indent):
emit('return ')
if ' ' == peek():
skip()
if quote == peek():
parseconststring()
else:
parseexprvarref()
emit(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):
skipchar(' ')
emit(' ' * indent)
@ -261,10 +210,6 @@ def parsestat(indent):
parsestatreturn(indent)
return
if call == "check":
parsestatcheck(indent)
return
if call == "trace":
parsestattrace(indent)
return
@ -355,7 +300,6 @@ def emitheader():
emitln("")
emitln("def emit(string):")
emitln(" sys.stdout.write(string)")
emitln(" sys.stdout.flush()")
emitln("")
emitln("def trace(header, value):")
emitln(" if os.environ.get('TRACE'):")
@ -364,39 +308,32 @@ def emitheader():
emitln("eof = chr(0)")
emitln("eol = chr(10)")
emitln("quote = chr(34)")
emitln("PEEK = None")
emitln("LINE = 1")
emitln("")
emitln("STDINCOLNO = 0")
emitln("STDINLINENO = 1")
emitln("STDINPEEK = None")
emitln("")
emitln("def _readchar():")
emitln("def peek():")
emitln(" global PEEK")
emitln(" if PEEK is None:")
emitln(" char = sys.stdin.read(1)")
emitln(" trace('char', char)")
emitln(" if not char:")
emitln(" return eof")
emitln(" return char")
emitln(" PEEK = eof")
emitln(" else:")
emitln(" PEEK = char")
emitln(" return PEEK")
emitln("")
emitln("def peek():")
emitln(" return STDINPEEK")
emitln("peek()")
emitln("")
emitln("def skip():")
emitln(" global STDINCOLNO")
emitln(" global STDINLINENO")
emitln(" global STDINPEEK")
emitln(" if eol == STDINPEEK:")
emitln(" STDINLINENO += 1")
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(" global LINE")
emitln(" global PEEK")
emitln(" if eol == PEEK:")
emitln(" LINE += 1")
emitln(" PEEK = None")
emitln("")
emitln("def skipchar(char):")
emitln(" global LINE")
emitln(" assert char == peek(), (LINE, char, peek())")
emitln(" skip()")
emitln("")

View File

@ -2,4 +2,3 @@
/lang0py*.exe
/lang0py*.o
/lang0py*.py
/lang0py*.py.tmp

View File

@ -18,22 +18,18 @@ all: lang0py.exe
$(CYTHON) -3 --embed $<
lang0py0.py: lang0py.lang0 $(LANG0PY)
cat $< | $(LANG0PY) > $@.tmp
mv $@.tmp $@
cat $< | $(LANG0PY) > $@
lang0py1.py: lang0py.lang0 lang0py0.exe
cat $< | ./lang0py0.exe > $@.tmp
mv $@.tmp $@
cat $< | ./lang0py0.exe > $@
# Cannot diff on the first iteration - platform change
lang0py2.py: lang0py.lang0 lang0py1.exe
cat $< | ./lang0py1.exe > $@.tmp
mv $@.tmp $@
cat $< | ./lang0py1.exe > $@
-diff lang0py1.py lang0py2.py
lang0py.py: lang0py.lang0 lang0py2.exe
cat $< | ./lang0py2.exe > $@.tmp
mv $@.tmp $@
cat $< | ./lang0py2.exe > $@
-diff lang0py2.py lang0py.py
clean:

View File

@ -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:
emit data
emit eol
@ -162,96 +151,12 @@ parsestatreturn indent:
calc isspace eq char " "
if isspace
skip
calc char peek
calc isquote eq char quote
calc isnotquote not isquote
if isquote
parseconststring
/
if isnotquote
parseexprvarref
/
/
emit 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:
emit indent
emit "trace("
@ -309,11 +214,6 @@ parsestat indent:
parsestattrace indent
return
/
calc ischeck eq call "check"
if ischeck
parsestatcheck indent
return
/
emit indent
emit call
emit "("
@ -380,11 +280,16 @@ parseblock indent:
parsefunc:
calc funcname lexident
calc char peek
calc iseoblock eq char "/"
if iseoblock
return
/
trace funcname
emit "def "
emit funcname
emit "("
set isnotfirst ""
set first "1"
forever
calc char peek
calc isspace eq char " "
@ -394,11 +299,13 @@ parsefunc:
/
skip
calc var lexident
calc isfirst eq first "1"
calc isnotfirst not isfirst
if isnotfirst
emit ", "
/
emit var
set isnotfirst "1"
set first "0"
/
calc char peek
calc iseoblock eq char "/"
@ -432,48 +339,40 @@ emitheader:
emitln ""
emitln "def emit(string):"
emitln " sys.stdout.write(string)"
emitln " sys.stdout.flush()"
emitln ""
emitln "def trace(header, value):"
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 "eof = chr(0)"
emitln "eol = chr(10)"
emitln "quote = chr(34)"
emitln "PEEK = None"
emitln "LINE = 1"
emitln ""
emitln "STDINCOLNO = 0"
emitln "STDINLINENO = 1"
emitln "STDINPEEK = None"
emitln ""
emitln "def _readchar():"
emitln "def peek():"
emitln " global PEEK"
emitln " if PEEK is None:"
emitln " char = sys.stdin.read(1)"
emitln " trace('char', char)"
emitln " if not char:"
emitln " return eof"
emitln " return char"
emitln " PEEK = eof"
emitln " else:"
emitln " PEEK = char"
emitln " return PEEK"
emitln ""
emitln "def peek():"
emitln " return STDINPEEK"
emitln "peek()"
emitln ""
emitln "def skip():"
emitln " global STDINCOLNO"
emitln " global STDINLINENO"
emitln " global STDINPEEK"
emitln " if eol == STDINPEEK:"
emitln " STDINLINENO += 1"
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 " global LINE"
emitln " global PEEK"
emitln " if eol == PEEK:"
emitln " LINE += 1"
emitln " PEEK = None"
emitln ""
emitln "def skipchar(char):"
emitln " global LINE"
emitln " assert char == peek(), (LINE, char, peek())"
emitln " skip()"
emitln ""
/

1
2-lang0c/.gitignore vendored
View File

@ -1,5 +1,4 @@
/lang0c*.c
/lang0c*.c.tmp
/lang0c*.exe
/lang0c*.o
/lang0c*.py

View File

@ -15,8 +15,7 @@ all: lang0c.exe
gcc -c $<
lang0c0.py: lang0c.lang0 $(LANG0PY)
cat $< | $(LANG0PY) > $@.tmp
mv $@.tmp $@
cat $< | $(LANG0PY) > $@
lang0c0.c: lang0c0.py
$(CYTHON) -3 --embed $<
@ -28,18 +27,15 @@ lang0c0.exe: lang0c0.o
gcc -o $@ $< -lpython$(PYVERSION)
lang0c1.c: lang0c.lang0 lang0c0.exe
cat $< | ./lang0c0.exe > $@.tmp
mv $@.tmp $@
cat $< | ./lang0c0.exe > $@
# Cannot diff on the first iteration - platform change
lang0c2.c: lang0c.lang0 lang0c1.exe
cat $< | ./lang0c1.exe > $@.tmp
mv $@.tmp $@
cat $< | ./lang0c1.exe > $@
-diff lang0c1.c lang0c2.c
lang0c.c: lang0c.lang0 lang0c2.exe
cat $< | ./lang0c2.exe > $@.tmp
mv $@.tmp $@
cat $< | ./lang0c2.exe > $@
-diff lang0c2.c lang0c.c
clean:

View File

@ -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:
emit data
emit eol
@ -206,8 +195,6 @@ parsestatbreak indent:
parsestatreturn indent:
declare char
declare isspace
declare isnotquote
declare isquote
declare isnotspace
emit indent
emit "return "
@ -216,16 +203,8 @@ parsestatreturn indent:
calc isnotspace not isspace
if isspace
skip
calc char peek
calc isquote eq char quote
calc isnotquote not isquote
if isquote
parseconststring
/
if isnotquote
parseexprvarref
/
/
if isnotspace
emit "0"
/
@ -235,98 +214,6 @@ parsestatreturn indent:
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:
declare varname
emit indent
@ -391,11 +278,6 @@ parsestat indent:
parsestatreturn indent
return
/
calc iscall eq call "check"
if iscall
parsestatcheck indent
return
/
calc iscall eq call "trace"
if iscall
parsestattrace indent
@ -589,55 +471,35 @@ emitheader:
emitln " return 0;"
emitln "}"
emitln ""
emitln "int STDINCOLNO = 1;"
emitln "int STDINLINENO = 1;"
emitln "char * STDINPEEK = 0;"
emitln "int LINE = 1;"
emitln ""
emitln "char * _readchar()"
emitln "char * peek()"
emitln "{"
emitln " char * res = malloc(2*sizeof(char));"
emitln " res[0] = getc(stdin);"
emitln " res[1] = 0;"
emitln " ungetc(res[0], stdin);"
emitln " return res;"
emitln "}"
emitln ""
emitln "char * peek()"
emitln "{"
emitln " if( !STDINPEEK ) STDINPEEK = _readchar(); // First byte read"
emitln " return STDINPEEK;"
emitln "}"
emitln ""
emitln "void skip()"
emitln "{"
emitln " if( !STDINPEEK ) STDINPEEK = _readchar(); // First byte read, not even peek()'d"
emitln " if( STDINPEEK[0] == 10 ) {"
emitln " STDINLINENO += 1;"
emitln " STDINCOLNO = 0;"
emitln " }"
emitln " STDINCOLNO += 1;"
emitln " STDINPEEK = _readchar();"
emitln " char c = getc(stdin);"
emitln " if( c == 10 ) LINE += 1;"
emitln "}"
emitln ""
emitln "char * stdinlineno()"
emitln "void skipchar(char * chr)"
emitln "{"
emitln " char * res = malloc(8*sizeof(char));"
emit " sprintf(res, "
emitln " assert(strlen(chr) == 1);"
emitln " char * act = peek();"
emitln " assert(strlen(act) == 1);"
emitln " if( chr[0] == act[0] ) {skip(); return;};"
emit " fprintf(stderr, "
emit quote
emit "%d"
emit "Expected '%c' on line %d but saw '%c' instead%c"
emit quote
emitln ", STDINLINENO);"
emitln " return res;"
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 ", chr[0], LINE, act[0], 10);"
emitln " exit(1);"
emitln "}"
emitln ""
return

View File

@ -113,10 +113,6 @@ Returns the given value. You can not give an argument if your function is never
### 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
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.
#### stdincolno
#### skipchar a
Returns the column number for stdin (starting at 1)
#### stdinlineno
Returns the line number for stdin (starting at 1)
Advances stdin a single character, if it matches the first character of `a`. Otherwise, exits the program.
### Typing

View File

@ -1,35 +1,29 @@
.SUFFIXES:
.PHONY: all clean
.PRECIOUS: build/%.it0.py build/%.it0.c
.DELETE_ON_ERROR:
PYVERSION=3.10
PYPREFIX=/usr
CYTHON=cython3
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 | grep -v 'builtincheckfalse' | sed 's/.lang0//')
TESTLIST=$(shell ls *.lang0 | sed 's/.lang0//')
all: check
check: all-it0.results all-it1.results all-it2.results
! grep -v 'Success' $^
all-it0.results: $(addprefix build/,$(addsuffix .it0, $(TESTLIST))) build/builtincheckfalse.it0
all-it0.results: $(addprefix build/,$(addsuffix .it0, $(TESTLIST)))
-rm -f $@
cat test-input.txt | build/builtincheckfalse.it0 2> /dev/null 2>&1 | grep 'Success'
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; cat test-input.txt | ./build/$(test).it0 >> $@ ; echo "" >> $@ ;)
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; echo "Hello" | ./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 $@
cat test-input.txt | build/builtincheckfalse.it1 2> /dev/null 2>&1 | grep 'Success'
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; cat test-input.txt | ./build/$(test).it1 >> $@ ; echo "" >> $@ ;)
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; echo "Hello" | ./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 $@
cat test-input.txt | build/builtincheckfalse.it2 2> /dev/null 2>&1 | grep 'Success'
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; cat test-input.txt | ./build/$(test).it2 >> $@ ; echo "" >> $@ ;)
$(foreach test,$(TESTLIST), echo -n "$(test) " >> $@; echo "Hello" | ./build/$(test).it2 >> $@ ; echo "" >> $@ ;)
clean:
-rm -f *.results build/*.it0* build/*.it1* build/*.it2*
@ -37,12 +31,8 @@ clean:
###
# it0
../0-lang0py/lang0py.exe: ../0-lang0py/lang0py.py
$(MAKE) -C ../0-lang0py
build/%.it0.py: %.lang0 ../0-lang0py/lang0py.exe
cat $< | ../0-lang0py/lang0py.exe > $@.tmp
mv $@.tmp $@
cat $< | ../0-lang0py/lang0py.exe > $@
build/%.it0.c: build/%.it0.py
$(CYTHON) -3 --embed -o $@ $^
@ -56,12 +46,8 @@ build/%.it0: build/%.it0.o
###
# 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
cat $< | ../1-lang0py/lang0py.exe > $@.tmp
mv $@.tmp $@
cat $< | ../1-lang0py/lang0py.exe > $@
build/%.it1.c: build/%.it1.py
$(CYTHON) -3 --embed -o $@ $^
@ -75,12 +61,8 @@ build/%.it1: build/%.it1.o
###
# 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
cat $< | ../2-lang0c/lang0c.exe > $@.tmp
mv $@.tmp $@
cat $< | ../2-lang0c/lang0c.exe > $@
build/%.it2.o: build/%.it2.c
$(CC) -o $@ -c $^ -I$(PYPREFIX)/include/python$(PYVERSION)

View File

@ -2,13 +2,10 @@
/*.it0.c
/*.it0.o
/*.it0.py
/*.it0.py.tmp
/*.it1
/*.it1.c
/*.it1.o
/*.it1.py
/*.it1.py.tmp
/*.it2
/*.it2.c
/*.it2.c.tmp
/*.it2.o

View File

@ -1,3 +0,0 @@
main:
check not "1" : "Success"
/

View File

@ -1,4 +0,0 @@
main:
check not "" : "Failure"
emit "Success"
/

View File

@ -1,9 +0,0 @@
func:
return "Success"
/
main:
declare result
calc result func
emit result
/

View File

@ -0,0 +1,11 @@
func result/
main:
declare result
calc result func "Success"
emit result
/
func result:
return result
/

View File

@ -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"
/

View File

@ -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
/

View File

@ -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"
/

View File

@ -1,6 +1,5 @@
main:
declare result
calc result addstringchar "abc" "d"
check eq result "abcd" : "Adding abc and d should be abcd"
emit "Success"
calc result addstringchar "Succes" "s"
emit result
/

View File

@ -1,6 +1,8 @@
main:
declare bool
calc bool eq "1" "2"
check not bool : "1 should not equal 2"
if bool
return
/
emit "Success"
/

View File

@ -1,5 +1,7 @@
main:
declare bool
check eq "1" "1" : "1 should equal 1"
calc bool eq "1" "1"
if bool
emit "Success"
/
/

View File

@ -1,6 +1,8 @@
main:
declare bool
calc bool lt "b" "a"
check not bool : "a should should sort before b"
if bool
return
/
emit "Success"
/

View File

@ -1,5 +1,7 @@
main:
declare bool
check lt "a" "b" : "a should should sort before b"
calc bool lt "a" "b"
if bool
emit "Success"
/
/

View File

@ -1,6 +1,9 @@
main:
declare char
declare ish
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"
/
/

View File

@ -1,12 +1,24 @@
main:
declare char
declare ish
declare iso
declare notish
declare notiso
skip
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
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"
/

View File

@ -1,3 +0,0 @@
Hello!
This is an example of standard input.