aurel
Full Member
Posts: 234
|
Post by aurel on Feb 19, 2024 14:09:58 GMT -5
in my case Oxygen Basic but is very BASIC-ish so could be translated to other dialects too. so far :
'min.py in oxygen $filename "minpy.exe" include "rtl32.inc" #lookahead
'global vars... int pc : string variable[] 'program counteridentifier -> (type, value) lookup table 'get program string source[] , fname fname = "test.txt" source = GetFile fname print source
'... sub Look() as string ' returns the current character while skipping over comments 'global pc ' comments are entered by # and exited by \n or \0 if source[pc] = "#" while source[pc] <> chr(10) and source[pc] <> chr(0): pc = pc + 1 : wend ' scan over comments here end if return source[pc] end sub '... sub Take() as string string c ' takes away and returns the current character c = Look() : pc = pc + 1 : return c end sub '... sub TakeString(string _word) as int ' returns whether a certain string could be taken starting at pc int n : string c int copypc = pc for n = 1 to LEN(_word) c = mid(_word,n,1) if Take() <> c : pc = copypc : return False : end if return True next n end sub
'.... sub NextC() as string ' returns the next non-whitespace character while Look() = " " or Look() = chr(9) or Look() = chr(10) or Look() = chr(13) : Take() return Look() wend end sub '... sub Program() int act = True 'while NextC() <> chr(0) : Block(act) : wend end sub
'def Error(text):
'start program... Program()
|
|