├── .gitignore ├── LICENSE ├── README.md ├── easylang.gg ├── easylang.rlex ├── easylang_lex.py ├── easylang_parser.py └── run.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | 131 | .idea/ 132 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | The MIT License (MIT) 3 | Copyright (c) 2020 thautwarm 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 19 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE 21 | OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## easylang 2 | 3 | Running the code with no dependency but the Python standard library. 4 | 5 | See `run.py` for more details. 6 | 7 | 8 | ```python 9 | exp = parse(""" 10 | print(add(1, 2)) 11 | k = fun (x, y, z) => 12 | { 13 | if gt(x, y) 14 | then add(z, 1) 15 | else add(z, -1) 16 | } 17 | 18 | print(k(1, 2, 3)) 19 | print(k(2, 1, 3)) 20 | """, "") 21 | 22 | import operator 23 | ctx = {'add': operator.add, 'print': print, 'gt': operator.gt} 24 | exp(ctx) 25 | # 3 26 | # 2 27 | # 4 28 | ``` 29 | 30 | ## About the Parser 31 | 32 | If you want to modify the parser and generate it again: 33 | ``` 34 | fff --trace easylang.gg 35 | ``` 36 | 37 | You need [frontend-for-free](https://github.com/thautwarm/frontend-for-free/) installed. -------------------------------------------------------------------------------- /easylang.gg: -------------------------------------------------------------------------------- 1 | # if x then 2 | # x + 1 3 | # else 4 | # x + 2 5 | 6 | # object = ((string, value) map -> value) 7 | 8 | list[p] : p { [$1] } 9 | | list[p] p { $1.append($2); $1 } 10 | ; 11 | 12 | seplist[sep, p] : p { [$1] } 13 | | seplist[sep, p] sep p { $1.append($3); $1 } 14 | ; 15 | 16 | START : list[exp] { mkblock($2) }; 17 | 18 | args : '(' seplist[',', arg] ')' { $2 } 19 | | '(' ')' { [] } 20 | ; 21 | 22 | 23 | # top level expression 24 | exp : app 25 | | 'fun' args '=>' exp { mkfunc($2, $4) } 26 | | '=' exp { mkassign($1.value, $3) } 27 | | '{' list[exp] '}' { mkblock($2) } 28 | | 'if' exp 'then' exp 'else' exp { mkif($2, $4, $6) } 29 | | '{' '}' { const(None) } 30 | ; 31 | 32 | arg : { $1.value }; 33 | 34 | app : atomexpr { $1 } 35 | | app '(' seplist[',', exp] ')' { call($1, $3) } # f(a, b, c) 36 | | app '(' ')' { call($1, ()) } 37 | ; 38 | 39 | atomexpr : { const(int($1.value)) } 40 | | { const(float($1.value)) } 41 | | { const(unesc($1.value)) } 42 | | { lookup($1.value) } 43 | | '(' exp ')' { $2 } 44 | ; 45 | 46 | 47 | %%inline 48 | from json.decoder import py_scanstring 49 | 50 | def unesc(x, f=py_scanstring): 51 | """from the raw form of a double quoted string to a python string, 52 | e.g., 53 | unesc('"asd"') == "asd" 54 | """ 55 | return f(x, 1)[0] 56 | 57 | def call(f, args): 58 | def ap(st): 59 | f_val = f(st) 60 | arg_vals = [arg(st) for arg in args] 61 | return f_val(*arg_vals) 62 | return ap 63 | 64 | def mkfunc(params, body): 65 | def ap(st): 66 | def obj(*args): 67 | assert len(args) == len(params) 68 | st_ = st.copy() 69 | for arg, param in zip(args, params): 70 | st_[param] = arg 71 | return body(st_) 72 | return obj 73 | return ap 74 | 75 | def mkassign(n, exp): 76 | def ap(st): 77 | st[n] = exp(st) 78 | return ap 79 | 80 | def mkblock(xs): 81 | def ap(st): 82 | r = None 83 | for x in xs: 84 | r = x(st) 85 | return r 86 | return ap 87 | 88 | def const(x): 89 | return lambda st: x 90 | 91 | def lookup(n): 92 | # fun st -> Map.lookup n st 93 | return lambda st: st[n] 94 | 95 | def mkif(cond, arm1, arm2): 96 | def ap(st): 97 | return (arm1 if cond(st) else arm2)(st) 98 | return ap 99 | %% 100 | -------------------------------------------------------------------------------- /easylang.rlex: -------------------------------------------------------------------------------- 1 | space \s+ 2 | str "([^\\"]+|\\.)*?" 3 | float [-+]?[0-9]+\.\d+([eE][-+]?\d+)?|[-+]?[0-9]+[eE][-+]?\d+ 4 | int [-+]?[0-9]+ 5 | ident [^\(\)\{\}\,\"\s]+ 6 | %ignore space -------------------------------------------------------------------------------- /easylang_lex.py: -------------------------------------------------------------------------------- 1 | from warnings import warn 2 | 3 | class Token: 4 | offset: int 5 | lineno: int 6 | colno: int 7 | filename: str 8 | idint: int 9 | value: str 10 | __slots__ = ("offset", "lineno", "colno", "filename", "idint", "value") 11 | 12 | def __init__(self, offset, lineno, colno, filename, type, value): 13 | self.offset = offset 14 | self.lineno = lineno 15 | self.colno = colno 16 | self.filename = filename 17 | self.idint = type 18 | self.value = value 19 | 20 | def __eq__(self, other: "Token"): 21 | if not isinstance(other, Token): 22 | return False 23 | 24 | return ( 25 | self.offset == other.offset 26 | and self.filename == other.filename 27 | and self.idint == other.idint 28 | and self.value == other.value 29 | and self.colno == other.colno 30 | and self.lineno == other.lineno 31 | ) 32 | 33 | def __hash__(self): 34 | return ( 35 | (self.offset ^ self.lineno ^ self.colno + 2333 + self.idint) 36 | ^ hash(self.filename) 37 | ^ hash(self.value) 38 | ) 39 | 40 | def __repr__(self): 41 | return ( 42 | "Token(offset=%d, lineno=%d, colno=%d, filename=%s, type=%d, value=%s)" 43 | % ( 44 | self.offset, 45 | self.lineno, 46 | self.colno, 47 | self.filename, 48 | self.idint, 49 | repr(self.value), 50 | ) 51 | ) 52 | 53 | def lexer(filename, text: str, *, pos=0, use_bof=True, use_eof=True): 54 | text_length = len(text) 55 | colno = 0 56 | lineno = 0 57 | newline = "\n" 58 | match = REGEX_STR.match 59 | ignores = IGNORES 60 | unionall_info = UNIONALL_INFO 61 | _Token = Token 62 | tokens = [] 63 | append = tokens.append 64 | if use_bof: 65 | append(_Token(0, 0, 0, filename, BOF, "")) 66 | while True: 67 | if text_length <= pos: 68 | break 69 | 70 | res = match(text, pos) 71 | if not res: 72 | warn(f"No handler for character `{text[pos].__repr__()}`.") 73 | ch = text[pos] 74 | append(Token(pos, lineno, colno, filename, -1, ch)) 75 | if ch == "\n": 76 | lineno += 1 77 | colno = 0 78 | pos += 1 79 | continue 80 | pat = res.group() 81 | typeid, cast_map = unionall_info[res.lastindex] 82 | if typeid in ignores: 83 | n = len(pat) 84 | line_inc = pat.count(newline) 85 | if line_inc: 86 | latest_newline_idx = pat.rindex(newline) 87 | colno = n - latest_newline_idx 88 | lineno += line_inc 89 | else: 90 | colno += n 91 | pos += n 92 | continue 93 | 94 | if cast_map: 95 | typeid = cast_map.get(pat, typeid) 96 | 97 | append(_Token(pos, lineno, colno, filename, typeid, pat)) 98 | n = len(pat) 99 | line_inc = pat.count(newline) 100 | if line_inc: 101 | latest_newline_idx = pat.rindex(newline) 102 | colno = n - latest_newline_idx 103 | lineno += line_inc 104 | else: 105 | colno += n 106 | pos += n 107 | 108 | if use_eof: 109 | append(Token(pos, lineno, colno, filename, EOF, "")) 110 | return tokens 111 | 112 | def lexer_lazy_bytes(filename, text: bytes, *, pos=0, use_bof=True, use_eof=True): 113 | text_length = len(text) 114 | colno = 0 115 | lineno = 0 116 | match = REGEX_BYTES.match 117 | ignores = IGNORES 118 | unionall_info = UNIONALL_INFO_BYTES 119 | _Token = Token 120 | if use_bof: 121 | yield _Token(0, 0, 0, filename, BOF, b"") 122 | 123 | while True: 124 | if text_length <= pos: 125 | break 126 | 127 | res = match(text, pos) 128 | if not res: 129 | warn(f"No handler for character `{str(text[pos]).__repr__()}`.") 130 | ch = text[pos] 131 | yield _Token(pos, lineno, colno, filename, -1, ch) 132 | if ch == b'\n': 133 | lineno += 1 134 | colno = 0 135 | pos += 1 136 | continue 137 | pat = res.group() 138 | typeid, cast_map = unionall_info[res.lastindex] 139 | if typeid in ignores: 140 | n = len(pat) 141 | line_inc = pat.count(b'\n') 142 | if line_inc: 143 | latest_newline_idx = pat.rindex(b'\n') 144 | colno = n - latest_newline_idx 145 | lineno += line_inc 146 | else: 147 | colno += n 148 | pos += n 149 | continue 150 | 151 | if cast_map: 152 | typeid = cast_map.get(pat, typeid) 153 | 154 | yield _Token(pos, lineno, colno, filename, typeid, pat) 155 | n = len(pat) 156 | line_inc = pat.count(b'\n') 157 | if line_inc: 158 | latest_newline_idx = pat.rindex(b'\n') 159 | colno = n - latest_newline_idx 160 | lineno += line_inc 161 | else: 162 | colno += n 163 | pos += n 164 | 165 | if use_eof: 166 | yield _Token(pos, lineno, colno, filename, EOF, "") 167 | 168 | EOF = 1 169 | BOF = 0 170 | REGEX = '(\\s+)|("([^\\\\"]+|\\\\.)*?")|([-+]?[0-9]+\\.\\d+([eE][-+]?\\d+)?|[-+]?[0-9]+[eE][-+]?\\d+)|([-+]?[0-9]+)|([^\\(\\)\\{\\}\\,\\"\\s]+)|(\\})|(\\{)|(,)|(\\))|(\\()' 171 | REGEX_STR = __import__('re').compile(REGEX) 172 | REGEX_BYTES = __import__('re').compile(REGEX.encode()) 173 | IGNORES = (17,) 174 | UNIONALL_INFO = ((None, None), (17, None), (16, None), (None, None), (15, None), (None, None), (14, None), (7, {'=>': 6, 'else': 13, 'then': 12, 'fun': 5, '=': 8, 'if': 11}), (10, None), (9, None), (2, None), (4, None), (3, None)) 175 | UNIONALL_INFO_BYTES = ((None, None), (17, None), (16, None), (None, None), (15, None), (None, None), (14, None), (7, {b'=>': 6, b'else': 13, b'then': 12, b'fun': 5, b'=': 8, b'if': 11}), (10, None), (9, None), (2, None), (4, None), (3, None)) 176 | numbering = {'BOF': 0, 'EOF': 1, 'quote ,': 2, 'quote (': 3, 'quote )': 4, 'quote fun': 5, 'quote =>': 6, 'ident': 7, 'quote =': 8, 'quote {': 9, 'quote }': 10, 'quote if': 11, 'quote then': 12, 'quote else': 13, 'int': 14, 'float': 15, 'str': 16, 'space': 17} 177 | -------------------------------------------------------------------------------- /easylang_parser.py: -------------------------------------------------------------------------------- 1 | 2 | """ 3 | Copyright thautwarm (c) 2019 4 | 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above 14 | copyright notice, this list of conditions and the following 15 | disclaimer in the documentation and/or other materials provided 16 | with the distribution. 17 | 18 | * Neither the name of thautwarm nor the names of other 19 | contributors may be used to endorse or promote products derived 20 | from this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | """ 34 | 35 | from json.decoder import py_scanstring 36 | 37 | def unesc(x, f=py_scanstring): 38 | """from the raw form of a double quoted string to a python string, 39 | e.g., 40 | unesc('"asd"') == "asd" 41 | """ 42 | return f(x, 1)[0] 43 | 44 | def call(f, args): 45 | def ap(st): 46 | f_val = f(st) 47 | arg_vals = [arg(st) for arg in args] 48 | return f_val(*arg_vals) 49 | return ap 50 | 51 | def mkfunc(params, body): 52 | def ap(st): 53 | def exp(*args): 54 | assert len(args) == len(params) 55 | st_ = st.copy() 56 | for arg, param in zip(args, params): 57 | st_[param] = arg 58 | return body(st_) 59 | return exp 60 | return ap 61 | def mkassign(n, exp): 62 | def ap(st): 63 | st[n] = exp(st) 64 | return ap 65 | 66 | def mkblock(xs): 67 | def ap(st): 68 | r = None 69 | for x in xs: 70 | r = x(st) 71 | return r 72 | return ap 73 | 74 | def const(x): 75 | return lambda st: x 76 | 77 | def lookup(n): 78 | # fun st -> Map.lookup n st 79 | return lambda st: st[n] 80 | 81 | def mkif(cond, arm1, arm2): 82 | def ap(st): 83 | return (arm1 if cond(st) else arm2)(st) 84 | return ap 85 | from typing import Generic, TypeVar 86 | T = TypeVar('T') 87 | 88 | class Tokens: 89 | __slots__ = ['array', 'offset'] 90 | 91 | def __init__(self, array): 92 | self.array = array 93 | self.offset = 0 94 | 95 | class State: 96 | 97 | def __init__(self): 98 | pass 99 | 100 | class AST(Generic[T]): 101 | __slots__ = ['tag', 'contents'] 102 | 103 | def __init__(self, tag: str, contents: T): 104 | self.tag = tag 105 | self.contents = contents 106 | 107 | class Nil: 108 | nil = None 109 | __slots__ = [] 110 | 111 | def __init__(self): 112 | if Nil.nil is None: 113 | Nil.nil = self 114 | return 115 | raise ValueError('Nil cannot get instantiated twice.') 116 | 117 | def __len__(self): 118 | return 0 119 | 120 | def __getitem__(self, n): 121 | raise IndexError('Out of bounds') 122 | 123 | @property 124 | def head(self): 125 | raise IndexError('Out of bounds') 126 | 127 | @property 128 | def tail(self): 129 | raise IndexError('Out of bounds') 130 | 131 | def __repr__(self): 132 | return '[]' 133 | _nil = Nil() 134 | 135 | class Cons: 136 | __slots__ = ['head', 'tail'] 137 | 138 | def __init__(self, _head, _tail): 139 | self.head = _head 140 | self.tail = _tail 141 | 142 | def __len__(self): 143 | nil = _nil 144 | l = 0 145 | while self is not nil: 146 | l += 1 147 | self = self.tail 148 | return l 149 | 150 | def __iter__(self): 151 | nil = _nil 152 | while self is not nil: 153 | yield self.head 154 | self = self.tail 155 | 156 | def __getitem__(self, n): 157 | while n != 0: 158 | self = self.tail 159 | n -= 1 160 | return self.head 161 | 162 | def __repr__(self): 163 | return repr(list(self)) 164 | try: 165 | 166 | def mk_pretty(): 167 | from prettyprinter import register_pretty, pretty_call, pprint 168 | 169 | @register_pretty(Tokens) 170 | def pretty_tokens(value, ctx): 171 | return pretty_call(ctx, Tokens, offset=value.offset, array=value.array) 172 | 173 | @register_pretty(AST) 174 | def pretty_ast(value, ctx): 175 | return pretty_call(ctx, AST, tag=value.tag, contents=value.contents) 176 | mk_pretty() 177 | del mk_pretty 178 | except ImportError: 179 | pass 180 | del T, Generic, TypeVar 181 | builtin_cons = Cons 182 | builtin_nil = _nil 183 | builtin_mk_ast = AST 184 | 185 | def mk_parser(): 186 | pass 187 | 188 | def rbnf_named_lr_step_app(rbnf_tmp_0, builtin_state, builtin_tokens): 189 | try: 190 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 191 | if _rbnf_cur_token.idint is 3: 192 | builtin_tokens.offset += 1 193 | else: 194 | _rbnf_cur_token = None 195 | except IndexError: 196 | _rbnf_cur_token = None 197 | lcl_0 = _rbnf_cur_token 198 | rbnf_tmp_1 = lcl_0 199 | lcl_0 = rbnf_tmp_1 is None 200 | if lcl_0: 201 | lcl_1 = builtin_tokens.offset 202 | lcl_1 = (lcl_1, 'quote ( not match') 203 | lcl_1 = builtin_cons(lcl_1, builtin_nil) 204 | lcl_1 = (False, lcl_1) 205 | lcl_0 = lcl_1 206 | else: 207 | lcl_1 = builtin_tokens.offset 208 | rbnf_named__off_1 = lcl_1 209 | try: 210 | builtin_tokens.array[builtin_tokens.offset + 0] 211 | _rbnf_peek_tmp = True 212 | except IndexError: 213 | _rbnf_peek_tmp = False 214 | lcl_1 = _rbnf_peek_tmp 215 | if lcl_1: 216 | lcl_3 = builtin_tokens.array[builtin_tokens.offset + 0] 217 | lcl_3 = lcl_3.idint 218 | if lcl_3 == 16: 219 | lcl_4 = rbnf_named_parse_rbnfmacro_2(builtin_state, builtin_tokens) 220 | rbnf_named__check_2 = lcl_4 221 | lcl_4 = rbnf_named__check_2[0] 222 | lcl_4 = lcl_4 == False 223 | if lcl_4: 224 | lcl_4 = rbnf_named__check_2 225 | else: 226 | lcl_5 = rbnf_named__check_2[1] 227 | rbnf_tmp_2 = lcl_5 228 | try: 229 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 230 | if _rbnf_cur_token.idint is 4: 231 | builtin_tokens.offset += 1 232 | else: 233 | _rbnf_cur_token = None 234 | except IndexError: 235 | _rbnf_cur_token = None 236 | lcl_5 = _rbnf_cur_token 237 | rbnf_tmp_3 = lcl_5 238 | lcl_5 = rbnf_tmp_3 is None 239 | if lcl_5: 240 | lcl_6 = builtin_tokens.offset 241 | lcl_6 = (lcl_6, 'quote ) not match') 242 | lcl_6 = builtin_cons(lcl_6, builtin_nil) 243 | lcl_6 = (False, lcl_6) 244 | lcl_5 = lcl_6 245 | else: 246 | lcl_6 = call(rbnf_tmp_0, rbnf_tmp_2) 247 | rbnf_tmp_1_ = lcl_6 248 | lcl_6 = (True, rbnf_tmp_1_) 249 | lcl_5 = lcl_6 250 | lcl_4 = lcl_5 251 | lcl_2 = lcl_4 252 | elif lcl_3 == 9: 253 | lcl_4 = rbnf_named_parse_rbnfmacro_2(builtin_state, builtin_tokens) 254 | rbnf_named__check_2 = lcl_4 255 | lcl_4 = rbnf_named__check_2[0] 256 | lcl_4 = lcl_4 == False 257 | if lcl_4: 258 | lcl_4 = rbnf_named__check_2 259 | else: 260 | lcl_5 = rbnf_named__check_2[1] 261 | rbnf_tmp_2 = lcl_5 262 | try: 263 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 264 | if _rbnf_cur_token.idint is 4: 265 | builtin_tokens.offset += 1 266 | else: 267 | _rbnf_cur_token = None 268 | except IndexError: 269 | _rbnf_cur_token = None 270 | lcl_5 = _rbnf_cur_token 271 | rbnf_tmp_3 = lcl_5 272 | lcl_5 = rbnf_tmp_3 is None 273 | if lcl_5: 274 | lcl_6 = builtin_tokens.offset 275 | lcl_6 = (lcl_6, 'quote ) not match') 276 | lcl_6 = builtin_cons(lcl_6, builtin_nil) 277 | lcl_6 = (False, lcl_6) 278 | lcl_5 = lcl_6 279 | else: 280 | lcl_6 = call(rbnf_tmp_0, rbnf_tmp_2) 281 | rbnf_tmp_1_ = lcl_6 282 | lcl_6 = (True, rbnf_tmp_1_) 283 | lcl_5 = lcl_6 284 | lcl_4 = lcl_5 285 | lcl_2 = lcl_4 286 | elif lcl_3 == 11: 287 | lcl_4 = rbnf_named_parse_rbnfmacro_2(builtin_state, builtin_tokens) 288 | rbnf_named__check_2 = lcl_4 289 | lcl_4 = rbnf_named__check_2[0] 290 | lcl_4 = lcl_4 == False 291 | if lcl_4: 292 | lcl_4 = rbnf_named__check_2 293 | else: 294 | lcl_5 = rbnf_named__check_2[1] 295 | rbnf_tmp_2 = lcl_5 296 | try: 297 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 298 | if _rbnf_cur_token.idint is 4: 299 | builtin_tokens.offset += 1 300 | else: 301 | _rbnf_cur_token = None 302 | except IndexError: 303 | _rbnf_cur_token = None 304 | lcl_5 = _rbnf_cur_token 305 | rbnf_tmp_3 = lcl_5 306 | lcl_5 = rbnf_tmp_3 is None 307 | if lcl_5: 308 | lcl_6 = builtin_tokens.offset 309 | lcl_6 = (lcl_6, 'quote ) not match') 310 | lcl_6 = builtin_cons(lcl_6, builtin_nil) 311 | lcl_6 = (False, lcl_6) 312 | lcl_5 = lcl_6 313 | else: 314 | lcl_6 = call(rbnf_tmp_0, rbnf_tmp_2) 315 | rbnf_tmp_1_ = lcl_6 316 | lcl_6 = (True, rbnf_tmp_1_) 317 | lcl_5 = lcl_6 318 | lcl_4 = lcl_5 319 | lcl_2 = lcl_4 320 | elif lcl_3 == 5: 321 | lcl_4 = rbnf_named_parse_rbnfmacro_2(builtin_state, builtin_tokens) 322 | rbnf_named__check_2 = lcl_4 323 | lcl_4 = rbnf_named__check_2[0] 324 | lcl_4 = lcl_4 == False 325 | if lcl_4: 326 | lcl_4 = rbnf_named__check_2 327 | else: 328 | lcl_5 = rbnf_named__check_2[1] 329 | rbnf_tmp_2 = lcl_5 330 | try: 331 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 332 | if _rbnf_cur_token.idint is 4: 333 | builtin_tokens.offset += 1 334 | else: 335 | _rbnf_cur_token = None 336 | except IndexError: 337 | _rbnf_cur_token = None 338 | lcl_5 = _rbnf_cur_token 339 | rbnf_tmp_3 = lcl_5 340 | lcl_5 = rbnf_tmp_3 is None 341 | if lcl_5: 342 | lcl_6 = builtin_tokens.offset 343 | lcl_6 = (lcl_6, 'quote ) not match') 344 | lcl_6 = builtin_cons(lcl_6, builtin_nil) 345 | lcl_6 = (False, lcl_6) 346 | lcl_5 = lcl_6 347 | else: 348 | lcl_6 = call(rbnf_tmp_0, rbnf_tmp_2) 349 | rbnf_tmp_1_ = lcl_6 350 | lcl_6 = (True, rbnf_tmp_1_) 351 | lcl_5 = lcl_6 352 | lcl_4 = lcl_5 353 | lcl_2 = lcl_4 354 | elif lcl_3 == 4: 355 | _rbnf_old_offset = builtin_tokens.offset 356 | _rbnf_cur_token = builtin_tokens.array[_rbnf_old_offset] 357 | builtin_tokens.offset = _rbnf_old_offset + 1 358 | lcl_4 = _rbnf_cur_token 359 | rbnf_tmp_2 = lcl_4 360 | lcl_4 = () 361 | lcl_4 = call(rbnf_tmp_0, lcl_4) 362 | rbnf_tmp_1_ = lcl_4 363 | lcl_4 = (True, rbnf_tmp_1_) 364 | lcl_2 = lcl_4 365 | elif lcl_3 == 3: 366 | lcl_4 = rbnf_named_parse_rbnfmacro_2(builtin_state, builtin_tokens) 367 | rbnf_named__check_2 = lcl_4 368 | lcl_4 = rbnf_named__check_2[0] 369 | lcl_4 = lcl_4 == False 370 | if lcl_4: 371 | lcl_4 = rbnf_named__check_2 372 | else: 373 | lcl_5 = rbnf_named__check_2[1] 374 | rbnf_tmp_2 = lcl_5 375 | try: 376 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 377 | if _rbnf_cur_token.idint is 4: 378 | builtin_tokens.offset += 1 379 | else: 380 | _rbnf_cur_token = None 381 | except IndexError: 382 | _rbnf_cur_token = None 383 | lcl_5 = _rbnf_cur_token 384 | rbnf_tmp_3 = lcl_5 385 | lcl_5 = rbnf_tmp_3 is None 386 | if lcl_5: 387 | lcl_6 = builtin_tokens.offset 388 | lcl_6 = (lcl_6, 'quote ) not match') 389 | lcl_6 = builtin_cons(lcl_6, builtin_nil) 390 | lcl_6 = (False, lcl_6) 391 | lcl_5 = lcl_6 392 | else: 393 | lcl_6 = call(rbnf_tmp_0, rbnf_tmp_2) 394 | rbnf_tmp_1_ = lcl_6 395 | lcl_6 = (True, rbnf_tmp_1_) 396 | lcl_5 = lcl_6 397 | lcl_4 = lcl_5 398 | lcl_2 = lcl_4 399 | elif lcl_3 == 14: 400 | lcl_4 = rbnf_named_parse_rbnfmacro_2(builtin_state, builtin_tokens) 401 | rbnf_named__check_2 = lcl_4 402 | lcl_4 = rbnf_named__check_2[0] 403 | lcl_4 = lcl_4 == False 404 | if lcl_4: 405 | lcl_4 = rbnf_named__check_2 406 | else: 407 | lcl_5 = rbnf_named__check_2[1] 408 | rbnf_tmp_2 = lcl_5 409 | try: 410 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 411 | if _rbnf_cur_token.idint is 4: 412 | builtin_tokens.offset += 1 413 | else: 414 | _rbnf_cur_token = None 415 | except IndexError: 416 | _rbnf_cur_token = None 417 | lcl_5 = _rbnf_cur_token 418 | rbnf_tmp_3 = lcl_5 419 | lcl_5 = rbnf_tmp_3 is None 420 | if lcl_5: 421 | lcl_6 = builtin_tokens.offset 422 | lcl_6 = (lcl_6, 'quote ) not match') 423 | lcl_6 = builtin_cons(lcl_6, builtin_nil) 424 | lcl_6 = (False, lcl_6) 425 | lcl_5 = lcl_6 426 | else: 427 | lcl_6 = call(rbnf_tmp_0, rbnf_tmp_2) 428 | rbnf_tmp_1_ = lcl_6 429 | lcl_6 = (True, rbnf_tmp_1_) 430 | lcl_5 = lcl_6 431 | lcl_4 = lcl_5 432 | lcl_2 = lcl_4 433 | elif lcl_3 == 7: 434 | lcl_4 = rbnf_named_parse_rbnfmacro_2(builtin_state, builtin_tokens) 435 | rbnf_named__check_2 = lcl_4 436 | lcl_4 = rbnf_named__check_2[0] 437 | lcl_4 = lcl_4 == False 438 | if lcl_4: 439 | lcl_4 = rbnf_named__check_2 440 | else: 441 | lcl_5 = rbnf_named__check_2[1] 442 | rbnf_tmp_2 = lcl_5 443 | try: 444 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 445 | if _rbnf_cur_token.idint is 4: 446 | builtin_tokens.offset += 1 447 | else: 448 | _rbnf_cur_token = None 449 | except IndexError: 450 | _rbnf_cur_token = None 451 | lcl_5 = _rbnf_cur_token 452 | rbnf_tmp_3 = lcl_5 453 | lcl_5 = rbnf_tmp_3 is None 454 | if lcl_5: 455 | lcl_6 = builtin_tokens.offset 456 | lcl_6 = (lcl_6, 'quote ) not match') 457 | lcl_6 = builtin_cons(lcl_6, builtin_nil) 458 | lcl_6 = (False, lcl_6) 459 | lcl_5 = lcl_6 460 | else: 461 | lcl_6 = call(rbnf_tmp_0, rbnf_tmp_2) 462 | rbnf_tmp_1_ = lcl_6 463 | lcl_6 = (True, rbnf_tmp_1_) 464 | lcl_5 = lcl_6 465 | lcl_4 = lcl_5 466 | lcl_2 = lcl_4 467 | elif lcl_3 == 15: 468 | lcl_4 = rbnf_named_parse_rbnfmacro_2(builtin_state, builtin_tokens) 469 | rbnf_named__check_2 = lcl_4 470 | lcl_4 = rbnf_named__check_2[0] 471 | lcl_4 = lcl_4 == False 472 | if lcl_4: 473 | lcl_4 = rbnf_named__check_2 474 | else: 475 | lcl_5 = rbnf_named__check_2[1] 476 | rbnf_tmp_2 = lcl_5 477 | try: 478 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 479 | if _rbnf_cur_token.idint is 4: 480 | builtin_tokens.offset += 1 481 | else: 482 | _rbnf_cur_token = None 483 | except IndexError: 484 | _rbnf_cur_token = None 485 | lcl_5 = _rbnf_cur_token 486 | rbnf_tmp_3 = lcl_5 487 | lcl_5 = rbnf_tmp_3 is None 488 | if lcl_5: 489 | lcl_6 = builtin_tokens.offset 490 | lcl_6 = (lcl_6, 'quote ) not match') 491 | lcl_6 = builtin_cons(lcl_6, builtin_nil) 492 | lcl_6 = (False, lcl_6) 493 | lcl_5 = lcl_6 494 | else: 495 | lcl_6 = call(rbnf_tmp_0, rbnf_tmp_2) 496 | rbnf_tmp_1_ = lcl_6 497 | lcl_6 = (True, rbnf_tmp_1_) 498 | lcl_5 = lcl_6 499 | lcl_4 = lcl_5 500 | lcl_2 = lcl_4 501 | else: 502 | lcl_4 = (rbnf_named__off_1, 'app lookahead failed') 503 | lcl_4 = builtin_cons(lcl_4, builtin_nil) 504 | lcl_4 = (False, lcl_4) 505 | lcl_2 = lcl_4 506 | lcl_1 = lcl_2 507 | else: 508 | lcl_2 = (rbnf_named__off_1, 'app got EOF') 509 | lcl_2 = builtin_cons(lcl_2, builtin_nil) 510 | lcl_2 = (False, lcl_2) 511 | lcl_1 = lcl_2 512 | lcl_0 = lcl_1 513 | return lcl_0 514 | 515 | def rbnf_named_lr_loop_app(rbnf_tmp_0, builtin_state, builtin_tokens): 516 | rbnf_named_lr_app_reduce = rbnf_tmp_0 517 | lcl_0 = builtin_tokens.offset 518 | rbnf_named__off_0 = lcl_0 519 | lcl_0 = rbnf_named_lr_step_app(rbnf_named_lr_app_reduce, builtin_state, builtin_tokens) 520 | rbnf_named_lr_app_try = lcl_0 521 | lcl_0 = rbnf_named_lr_app_try[0] 522 | lcl_0 = lcl_0 is not False 523 | while lcl_0: 524 | lcl_1 = builtin_tokens.offset 525 | rbnf_named__off_0 = lcl_1 526 | lcl_1 = rbnf_named_lr_app_try[1] 527 | rbnf_named_lr_app_reduce = lcl_1 528 | lcl_1 = rbnf_named_lr_step_app(rbnf_named_lr_app_reduce, builtin_state, builtin_tokens) 529 | rbnf_named_lr_app_try = lcl_1 530 | lcl_1 = rbnf_named_lr_app_try[0] 531 | lcl_1 = lcl_1 is not False 532 | lcl_0 = lcl_1 533 | lcl_0 = builtin_tokens.offset 534 | lcl_0 = lcl_0 == rbnf_named__off_0 535 | if lcl_0: 536 | lcl_1 = (True, rbnf_named_lr_app_reduce) 537 | lcl_0 = lcl_1 538 | else: 539 | lcl_0 = rbnf_named_lr_app_try 540 | return lcl_0 541 | 542 | def rbnf_named_lr_step_rbnfmacro_0(rbnf_tmp_0, builtin_state, builtin_tokens): 543 | lcl_0 = rbnf_named_parse_exp(builtin_state, builtin_tokens) 544 | rbnf_named__check_1 = lcl_0 545 | lcl_0 = rbnf_named__check_1[0] 546 | lcl_0 = lcl_0 == False 547 | if lcl_0: 548 | lcl_0 = rbnf_named__check_1 549 | else: 550 | lcl_1 = rbnf_named__check_1[1] 551 | rbnf_tmp_1 = lcl_1 552 | lcl_1 = rbnf_tmp_0.append 553 | lcl_1 = lcl_1(rbnf_tmp_1) 554 | rbnf_tmp_1_ = rbnf_tmp_0 555 | lcl_2 = (True, rbnf_tmp_1_) 556 | lcl_0 = lcl_2 557 | return lcl_0 558 | 559 | def rbnf_named_lr_loop_rbnfmacro_0(rbnf_tmp_0, builtin_state, builtin_tokens): 560 | rbnf_named_lr_rbnfmacro_0_reduce = rbnf_tmp_0 561 | lcl_0 = builtin_tokens.offset 562 | rbnf_named__off_0 = lcl_0 563 | lcl_0 = rbnf_named_lr_step_rbnfmacro_0(rbnf_named_lr_rbnfmacro_0_reduce, builtin_state, builtin_tokens) 564 | rbnf_named_lr_rbnfmacro_0_try = lcl_0 565 | lcl_0 = rbnf_named_lr_rbnfmacro_0_try[0] 566 | lcl_0 = lcl_0 is not False 567 | while lcl_0: 568 | lcl_1 = builtin_tokens.offset 569 | rbnf_named__off_0 = lcl_1 570 | lcl_1 = rbnf_named_lr_rbnfmacro_0_try[1] 571 | rbnf_named_lr_rbnfmacro_0_reduce = lcl_1 572 | lcl_1 = rbnf_named_lr_step_rbnfmacro_0(rbnf_named_lr_rbnfmacro_0_reduce, builtin_state, builtin_tokens) 573 | rbnf_named_lr_rbnfmacro_0_try = lcl_1 574 | lcl_1 = rbnf_named_lr_rbnfmacro_0_try[0] 575 | lcl_1 = lcl_1 is not False 576 | lcl_0 = lcl_1 577 | lcl_0 = builtin_tokens.offset 578 | lcl_0 = lcl_0 == rbnf_named__off_0 579 | if lcl_0: 580 | lcl_1 = (True, rbnf_named_lr_rbnfmacro_0_reduce) 581 | lcl_0 = lcl_1 582 | else: 583 | lcl_0 = rbnf_named_lr_rbnfmacro_0_try 584 | return lcl_0 585 | 586 | def rbnf_named_lr_step_rbnfmacro_1(rbnf_tmp_0, builtin_state, builtin_tokens): 587 | try: 588 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 589 | if _rbnf_cur_token.idint is 2: 590 | builtin_tokens.offset += 1 591 | else: 592 | _rbnf_cur_token = None 593 | except IndexError: 594 | _rbnf_cur_token = None 595 | lcl_0 = _rbnf_cur_token 596 | rbnf_tmp_1 = lcl_0 597 | lcl_0 = rbnf_tmp_1 is None 598 | if lcl_0: 599 | lcl_1 = builtin_tokens.offset 600 | lcl_1 = (lcl_1, 'quote , not match') 601 | lcl_1 = builtin_cons(lcl_1, builtin_nil) 602 | lcl_1 = (False, lcl_1) 603 | lcl_0 = lcl_1 604 | else: 605 | lcl_1 = rbnf_named_parse_arg(builtin_state, builtin_tokens) 606 | rbnf_named__check_2 = lcl_1 607 | lcl_1 = rbnf_named__check_2[0] 608 | lcl_1 = lcl_1 == False 609 | if lcl_1: 610 | lcl_1 = rbnf_named__check_2 611 | else: 612 | lcl_2 = rbnf_named__check_2[1] 613 | rbnf_tmp_2 = lcl_2 614 | lcl_2 = rbnf_tmp_0.append 615 | lcl_2 = lcl_2(rbnf_tmp_2) 616 | rbnf_tmp_1_ = rbnf_tmp_0 617 | lcl_3 = (True, rbnf_tmp_1_) 618 | lcl_1 = lcl_3 619 | lcl_0 = lcl_1 620 | return lcl_0 621 | 622 | def rbnf_named_lr_loop_rbnfmacro_1(rbnf_tmp_0, builtin_state, builtin_tokens): 623 | rbnf_named_lr_rbnfmacro_1_reduce = rbnf_tmp_0 624 | lcl_0 = builtin_tokens.offset 625 | rbnf_named__off_0 = lcl_0 626 | lcl_0 = rbnf_named_lr_step_rbnfmacro_1(rbnf_named_lr_rbnfmacro_1_reduce, builtin_state, builtin_tokens) 627 | rbnf_named_lr_rbnfmacro_1_try = lcl_0 628 | lcl_0 = rbnf_named_lr_rbnfmacro_1_try[0] 629 | lcl_0 = lcl_0 is not False 630 | while lcl_0: 631 | lcl_1 = builtin_tokens.offset 632 | rbnf_named__off_0 = lcl_1 633 | lcl_1 = rbnf_named_lr_rbnfmacro_1_try[1] 634 | rbnf_named_lr_rbnfmacro_1_reduce = lcl_1 635 | lcl_1 = rbnf_named_lr_step_rbnfmacro_1(rbnf_named_lr_rbnfmacro_1_reduce, builtin_state, builtin_tokens) 636 | rbnf_named_lr_rbnfmacro_1_try = lcl_1 637 | lcl_1 = rbnf_named_lr_rbnfmacro_1_try[0] 638 | lcl_1 = lcl_1 is not False 639 | lcl_0 = lcl_1 640 | lcl_0 = builtin_tokens.offset 641 | lcl_0 = lcl_0 == rbnf_named__off_0 642 | if lcl_0: 643 | lcl_1 = (True, rbnf_named_lr_rbnfmacro_1_reduce) 644 | lcl_0 = lcl_1 645 | else: 646 | lcl_0 = rbnf_named_lr_rbnfmacro_1_try 647 | return lcl_0 648 | 649 | def rbnf_named_lr_step_rbnfmacro_2(rbnf_tmp_0, builtin_state, builtin_tokens): 650 | try: 651 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 652 | if _rbnf_cur_token.idint is 2: 653 | builtin_tokens.offset += 1 654 | else: 655 | _rbnf_cur_token = None 656 | except IndexError: 657 | _rbnf_cur_token = None 658 | lcl_0 = _rbnf_cur_token 659 | rbnf_tmp_1 = lcl_0 660 | lcl_0 = rbnf_tmp_1 is None 661 | if lcl_0: 662 | lcl_1 = builtin_tokens.offset 663 | lcl_1 = (lcl_1, 'quote , not match') 664 | lcl_1 = builtin_cons(lcl_1, builtin_nil) 665 | lcl_1 = (False, lcl_1) 666 | lcl_0 = lcl_1 667 | else: 668 | lcl_1 = rbnf_named_parse_exp(builtin_state, builtin_tokens) 669 | rbnf_named__check_2 = lcl_1 670 | lcl_1 = rbnf_named__check_2[0] 671 | lcl_1 = lcl_1 == False 672 | if lcl_1: 673 | lcl_1 = rbnf_named__check_2 674 | else: 675 | lcl_2 = rbnf_named__check_2[1] 676 | rbnf_tmp_2 = lcl_2 677 | lcl_2 = rbnf_tmp_0.append 678 | lcl_2 = lcl_2(rbnf_tmp_2) 679 | rbnf_tmp_1_ = rbnf_tmp_0 680 | lcl_3 = (True, rbnf_tmp_1_) 681 | lcl_1 = lcl_3 682 | lcl_0 = lcl_1 683 | return lcl_0 684 | 685 | def rbnf_named_lr_loop_rbnfmacro_2(rbnf_tmp_0, builtin_state, builtin_tokens): 686 | rbnf_named_lr_rbnfmacro_2_reduce = rbnf_tmp_0 687 | lcl_0 = builtin_tokens.offset 688 | rbnf_named__off_0 = lcl_0 689 | lcl_0 = rbnf_named_lr_step_rbnfmacro_2(rbnf_named_lr_rbnfmacro_2_reduce, builtin_state, builtin_tokens) 690 | rbnf_named_lr_rbnfmacro_2_try = lcl_0 691 | lcl_0 = rbnf_named_lr_rbnfmacro_2_try[0] 692 | lcl_0 = lcl_0 is not False 693 | while lcl_0: 694 | lcl_1 = builtin_tokens.offset 695 | rbnf_named__off_0 = lcl_1 696 | lcl_1 = rbnf_named_lr_rbnfmacro_2_try[1] 697 | rbnf_named_lr_rbnfmacro_2_reduce = lcl_1 698 | lcl_1 = rbnf_named_lr_step_rbnfmacro_2(rbnf_named_lr_rbnfmacro_2_reduce, builtin_state, builtin_tokens) 699 | rbnf_named_lr_rbnfmacro_2_try = lcl_1 700 | lcl_1 = rbnf_named_lr_rbnfmacro_2_try[0] 701 | lcl_1 = lcl_1 is not False 702 | lcl_0 = lcl_1 703 | lcl_0 = builtin_tokens.offset 704 | lcl_0 = lcl_0 == rbnf_named__off_0 705 | if lcl_0: 706 | lcl_1 = (True, rbnf_named_lr_rbnfmacro_2_reduce) 707 | lcl_0 = lcl_1 708 | else: 709 | lcl_0 = rbnf_named_lr_rbnfmacro_2_try 710 | return lcl_0 711 | 712 | def rbnf_named_parse_START(builtin_state, builtin_tokens): 713 | try: 714 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 715 | if _rbnf_cur_token.idint is 0: 716 | builtin_tokens.offset += 1 717 | else: 718 | _rbnf_cur_token = None 719 | except IndexError: 720 | _rbnf_cur_token = None 721 | lcl_0 = _rbnf_cur_token 722 | rbnf_tmp_0 = lcl_0 723 | lcl_0 = rbnf_tmp_0 is None 724 | if lcl_0: 725 | lcl_1 = builtin_tokens.offset 726 | lcl_1 = (lcl_1, 'BOF not match') 727 | lcl_1 = builtin_cons(lcl_1, builtin_nil) 728 | lcl_1 = (False, lcl_1) 729 | lcl_0 = lcl_1 730 | else: 731 | lcl_1 = rbnf_named_parse_rbnfmacro_0(builtin_state, builtin_tokens) 732 | rbnf_named__check_1 = lcl_1 733 | lcl_1 = rbnf_named__check_1[0] 734 | lcl_1 = lcl_1 == False 735 | if lcl_1: 736 | lcl_1 = rbnf_named__check_1 737 | else: 738 | lcl_2 = rbnf_named__check_1[1] 739 | rbnf_tmp_1 = lcl_2 740 | try: 741 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 742 | if _rbnf_cur_token.idint is 1: 743 | builtin_tokens.offset += 1 744 | else: 745 | _rbnf_cur_token = None 746 | except IndexError: 747 | _rbnf_cur_token = None 748 | lcl_2 = _rbnf_cur_token 749 | rbnf_tmp_2 = lcl_2 750 | lcl_2 = rbnf_tmp_2 is None 751 | if lcl_2: 752 | lcl_3 = builtin_tokens.offset 753 | lcl_3 = (lcl_3, 'EOF not match') 754 | lcl_3 = builtin_cons(lcl_3, builtin_nil) 755 | lcl_3 = (False, lcl_3) 756 | lcl_2 = lcl_3 757 | else: 758 | lcl_3 = mkblock(rbnf_tmp_1) 759 | rbnf_tmp_1_ = lcl_3 760 | lcl_3 = (True, rbnf_tmp_1_) 761 | lcl_2 = lcl_3 762 | lcl_1 = lcl_2 763 | lcl_0 = lcl_1 764 | return lcl_0 765 | 766 | def rbnf_named_parse_app(builtin_state, builtin_tokens): 767 | lcl_0 = rbnf_named_parse_atomexpr(builtin_state, builtin_tokens) 768 | rbnf_named__check_0 = lcl_0 769 | lcl_0 = rbnf_named__check_0[0] 770 | lcl_0 = lcl_0 == False 771 | if lcl_0: 772 | lcl_0 = rbnf_named__check_0 773 | else: 774 | lcl_1 = rbnf_named__check_0[1] 775 | rbnf_tmp_0 = lcl_1 776 | rbnf_tmp_1_ = rbnf_tmp_0 777 | lcl_1 = rbnf_named_lr_loop_app(rbnf_tmp_1_, builtin_state, builtin_tokens) 778 | lcl_0 = lcl_1 779 | return lcl_0 780 | 781 | def rbnf_named_parse_arg(builtin_state, builtin_tokens): 782 | try: 783 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 784 | if _rbnf_cur_token.idint is 7: 785 | builtin_tokens.offset += 1 786 | else: 787 | _rbnf_cur_token = None 788 | except IndexError: 789 | _rbnf_cur_token = None 790 | lcl_0 = _rbnf_cur_token 791 | rbnf_tmp_0 = lcl_0 792 | lcl_0 = rbnf_tmp_0 is None 793 | if lcl_0: 794 | lcl_1 = builtin_tokens.offset 795 | lcl_1 = (lcl_1, 'ident not match') 796 | lcl_1 = builtin_cons(lcl_1, builtin_nil) 797 | lcl_1 = (False, lcl_1) 798 | lcl_0 = lcl_1 799 | else: 800 | lcl_1 = rbnf_tmp_0.value 801 | rbnf_tmp_1_ = lcl_1 802 | lcl_1 = (True, rbnf_tmp_1_) 803 | lcl_0 = lcl_1 804 | return lcl_0 805 | 806 | def rbnf_named_parse_args(builtin_state, builtin_tokens): 807 | try: 808 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 809 | if _rbnf_cur_token.idint is 3: 810 | builtin_tokens.offset += 1 811 | else: 812 | _rbnf_cur_token = None 813 | except IndexError: 814 | _rbnf_cur_token = None 815 | lcl_0 = _rbnf_cur_token 816 | rbnf_tmp_0 = lcl_0 817 | lcl_0 = rbnf_tmp_0 is None 818 | if lcl_0: 819 | lcl_1 = builtin_tokens.offset 820 | lcl_1 = (lcl_1, 'quote ( not match') 821 | lcl_1 = builtin_cons(lcl_1, builtin_nil) 822 | lcl_1 = (False, lcl_1) 823 | lcl_0 = lcl_1 824 | else: 825 | lcl_1 = builtin_tokens.offset 826 | rbnf_named__off_1 = lcl_1 827 | try: 828 | builtin_tokens.array[builtin_tokens.offset + 0] 829 | _rbnf_peek_tmp = True 830 | except IndexError: 831 | _rbnf_peek_tmp = False 832 | lcl_1 = _rbnf_peek_tmp 833 | if lcl_1: 834 | lcl_3 = builtin_tokens.array[builtin_tokens.offset + 0] 835 | lcl_3 = lcl_3.idint 836 | if lcl_3 == 4: 837 | _rbnf_old_offset = builtin_tokens.offset 838 | _rbnf_cur_token = builtin_tokens.array[_rbnf_old_offset] 839 | builtin_tokens.offset = _rbnf_old_offset + 1 840 | lcl_4 = _rbnf_cur_token 841 | rbnf_tmp_1 = lcl_4 842 | lcl_4 = [] 843 | rbnf_tmp_1_ = lcl_4 844 | lcl_4 = (True, rbnf_tmp_1_) 845 | lcl_2 = lcl_4 846 | elif lcl_3 == 7: 847 | lcl_4 = rbnf_named_parse_rbnfmacro_1(builtin_state, builtin_tokens) 848 | rbnf_named__check_1 = lcl_4 849 | lcl_4 = rbnf_named__check_1[0] 850 | lcl_4 = lcl_4 == False 851 | if lcl_4: 852 | lcl_4 = rbnf_named__check_1 853 | else: 854 | lcl_5 = rbnf_named__check_1[1] 855 | rbnf_tmp_1 = lcl_5 856 | try: 857 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 858 | if _rbnf_cur_token.idint is 4: 859 | builtin_tokens.offset += 1 860 | else: 861 | _rbnf_cur_token = None 862 | except IndexError: 863 | _rbnf_cur_token = None 864 | lcl_5 = _rbnf_cur_token 865 | rbnf_tmp_2 = lcl_5 866 | lcl_5 = rbnf_tmp_2 is None 867 | if lcl_5: 868 | lcl_6 = builtin_tokens.offset 869 | lcl_6 = (lcl_6, 'quote ) not match') 870 | lcl_6 = builtin_cons(lcl_6, builtin_nil) 871 | lcl_6 = (False, lcl_6) 872 | lcl_5 = lcl_6 873 | else: 874 | rbnf_tmp_1_ = rbnf_tmp_1 875 | lcl_6 = (True, rbnf_tmp_1_) 876 | lcl_5 = lcl_6 877 | lcl_4 = lcl_5 878 | lcl_2 = lcl_4 879 | else: 880 | lcl_4 = (rbnf_named__off_1, 'args lookahead failed') 881 | lcl_4 = builtin_cons(lcl_4, builtin_nil) 882 | lcl_4 = (False, lcl_4) 883 | lcl_2 = lcl_4 884 | lcl_1 = lcl_2 885 | else: 886 | lcl_2 = (rbnf_named__off_1, 'args got EOF') 887 | lcl_2 = builtin_cons(lcl_2, builtin_nil) 888 | lcl_2 = (False, lcl_2) 889 | lcl_1 = lcl_2 890 | lcl_0 = lcl_1 891 | return lcl_0 892 | 893 | def rbnf_named_parse_atomexpr(builtin_state, builtin_tokens): 894 | lcl_0 = builtin_tokens.offset 895 | rbnf_named__off_0 = lcl_0 896 | try: 897 | builtin_tokens.array[builtin_tokens.offset + 0] 898 | _rbnf_peek_tmp = True 899 | except IndexError: 900 | _rbnf_peek_tmp = False 901 | lcl_0 = _rbnf_peek_tmp 902 | if lcl_0: 903 | lcl_2 = builtin_tokens.array[builtin_tokens.offset + 0] 904 | lcl_2 = lcl_2.idint 905 | if lcl_2 == 16: 906 | _rbnf_old_offset = builtin_tokens.offset 907 | _rbnf_cur_token = builtin_tokens.array[_rbnf_old_offset] 908 | builtin_tokens.offset = _rbnf_old_offset + 1 909 | lcl_3 = _rbnf_cur_token 910 | rbnf_tmp_0 = lcl_3 911 | lcl_3 = rbnf_tmp_0.value 912 | lcl_3 = unesc(lcl_3) 913 | lcl_3 = const(lcl_3) 914 | rbnf_tmp_1_ = lcl_3 915 | lcl_3 = (True, rbnf_tmp_1_) 916 | lcl_1 = lcl_3 917 | elif lcl_2 == 3: 918 | _rbnf_old_offset = builtin_tokens.offset 919 | _rbnf_cur_token = builtin_tokens.array[_rbnf_old_offset] 920 | builtin_tokens.offset = _rbnf_old_offset + 1 921 | lcl_3 = _rbnf_cur_token 922 | rbnf_tmp_0 = lcl_3 923 | lcl_3 = rbnf_named_parse_exp(builtin_state, builtin_tokens) 924 | rbnf_named__check_1 = lcl_3 925 | lcl_3 = rbnf_named__check_1[0] 926 | lcl_3 = lcl_3 == False 927 | if lcl_3: 928 | lcl_3 = rbnf_named__check_1 929 | else: 930 | lcl_4 = rbnf_named__check_1[1] 931 | rbnf_tmp_1 = lcl_4 932 | try: 933 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 934 | if _rbnf_cur_token.idint is 4: 935 | builtin_tokens.offset += 1 936 | else: 937 | _rbnf_cur_token = None 938 | except IndexError: 939 | _rbnf_cur_token = None 940 | lcl_4 = _rbnf_cur_token 941 | rbnf_tmp_2 = lcl_4 942 | lcl_4 = rbnf_tmp_2 is None 943 | if lcl_4: 944 | lcl_5 = builtin_tokens.offset 945 | lcl_5 = (lcl_5, 'quote ) not match') 946 | lcl_5 = builtin_cons(lcl_5, builtin_nil) 947 | lcl_5 = (False, lcl_5) 948 | lcl_4 = lcl_5 949 | else: 950 | rbnf_tmp_1_ = rbnf_tmp_1 951 | lcl_5 = (True, rbnf_tmp_1_) 952 | lcl_4 = lcl_5 953 | lcl_3 = lcl_4 954 | lcl_1 = lcl_3 955 | elif lcl_2 == 14: 956 | _rbnf_old_offset = builtin_tokens.offset 957 | _rbnf_cur_token = builtin_tokens.array[_rbnf_old_offset] 958 | builtin_tokens.offset = _rbnf_old_offset + 1 959 | lcl_3 = _rbnf_cur_token 960 | rbnf_tmp_0 = lcl_3 961 | lcl_3 = rbnf_tmp_0.value 962 | lcl_3 = int(lcl_3) 963 | lcl_3 = const(lcl_3) 964 | rbnf_tmp_1_ = lcl_3 965 | lcl_3 = (True, rbnf_tmp_1_) 966 | lcl_1 = lcl_3 967 | elif lcl_2 == 7: 968 | _rbnf_old_offset = builtin_tokens.offset 969 | _rbnf_cur_token = builtin_tokens.array[_rbnf_old_offset] 970 | builtin_tokens.offset = _rbnf_old_offset + 1 971 | lcl_3 = _rbnf_cur_token 972 | rbnf_tmp_0 = lcl_3 973 | lcl_3 = rbnf_tmp_0.value 974 | lcl_3 = lookup(lcl_3) 975 | rbnf_tmp_1_ = lcl_3 976 | lcl_3 = (True, rbnf_tmp_1_) 977 | lcl_1 = lcl_3 978 | elif lcl_2 == 15: 979 | _rbnf_old_offset = builtin_tokens.offset 980 | _rbnf_cur_token = builtin_tokens.array[_rbnf_old_offset] 981 | builtin_tokens.offset = _rbnf_old_offset + 1 982 | lcl_3 = _rbnf_cur_token 983 | rbnf_tmp_0 = lcl_3 984 | lcl_3 = rbnf_tmp_0.value 985 | lcl_3 = float(lcl_3) 986 | lcl_3 = const(lcl_3) 987 | rbnf_tmp_1_ = lcl_3 988 | lcl_3 = (True, rbnf_tmp_1_) 989 | lcl_1 = lcl_3 990 | else: 991 | lcl_3 = (rbnf_named__off_0, 'atomexpr lookahead failed') 992 | lcl_3 = builtin_cons(lcl_3, builtin_nil) 993 | lcl_3 = (False, lcl_3) 994 | lcl_1 = lcl_3 995 | lcl_0 = lcl_1 996 | else: 997 | lcl_1 = (rbnf_named__off_0, 'atomexpr got EOF') 998 | lcl_1 = builtin_cons(lcl_1, builtin_nil) 999 | lcl_1 = (False, lcl_1) 1000 | lcl_0 = lcl_1 1001 | return lcl_0 1002 | 1003 | def rbnf_named_parse_exp(builtin_state, builtin_tokens): 1004 | lcl_0 = builtin_tokens.offset 1005 | rbnf_named__off_0 = lcl_0 1006 | try: 1007 | builtin_tokens.array[builtin_tokens.offset + 0] 1008 | _rbnf_peek_tmp = True 1009 | except IndexError: 1010 | _rbnf_peek_tmp = False 1011 | lcl_0 = _rbnf_peek_tmp 1012 | if lcl_0: 1013 | lcl_2 = builtin_tokens.array[builtin_tokens.offset + 0] 1014 | lcl_2 = lcl_2.idint 1015 | if lcl_2 == 16: 1016 | lcl_3 = rbnf_named_parse_app(builtin_state, builtin_tokens) 1017 | rbnf_named__check_0 = lcl_3 1018 | lcl_3 = rbnf_named__check_0[0] 1019 | lcl_3 = lcl_3 == False 1020 | if lcl_3: 1021 | lcl_3 = rbnf_named__check_0 1022 | else: 1023 | lcl_4 = rbnf_named__check_0[1] 1024 | rbnf_tmp_0 = lcl_4 1025 | rbnf_tmp_1_ = rbnf_tmp_0 1026 | lcl_4 = (True, rbnf_tmp_1_) 1027 | lcl_3 = lcl_4 1028 | lcl_1 = lcl_3 1029 | elif lcl_2 == 9: 1030 | _rbnf_old_offset = builtin_tokens.offset 1031 | _rbnf_cur_token = builtin_tokens.array[_rbnf_old_offset] 1032 | builtin_tokens.offset = _rbnf_old_offset + 1 1033 | lcl_3 = _rbnf_cur_token 1034 | rbnf_tmp_0 = lcl_3 1035 | lcl_3 = builtin_tokens.offset 1036 | rbnf_named__off_1 = lcl_3 1037 | try: 1038 | builtin_tokens.array[builtin_tokens.offset + 0] 1039 | _rbnf_peek_tmp = True 1040 | except IndexError: 1041 | _rbnf_peek_tmp = False 1042 | lcl_3 = _rbnf_peek_tmp 1043 | if lcl_3: 1044 | lcl_5 = builtin_tokens.array[builtin_tokens.offset + 0] 1045 | lcl_5 = lcl_5.idint 1046 | if lcl_5 == 16: 1047 | lcl_6 = rbnf_named_parse_rbnfmacro_0(builtin_state, builtin_tokens) 1048 | rbnf_named__check_1 = lcl_6 1049 | lcl_6 = rbnf_named__check_1[0] 1050 | lcl_6 = lcl_6 == False 1051 | if lcl_6: 1052 | lcl_6 = rbnf_named__check_1 1053 | else: 1054 | lcl_7 = rbnf_named__check_1[1] 1055 | rbnf_tmp_1 = lcl_7 1056 | try: 1057 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 1058 | if _rbnf_cur_token.idint is 10: 1059 | builtin_tokens.offset += 1 1060 | else: 1061 | _rbnf_cur_token = None 1062 | except IndexError: 1063 | _rbnf_cur_token = None 1064 | lcl_7 = _rbnf_cur_token 1065 | rbnf_tmp_2 = lcl_7 1066 | lcl_7 = rbnf_tmp_2 is None 1067 | if lcl_7: 1068 | lcl_8 = builtin_tokens.offset 1069 | lcl_8 = (lcl_8, 'quote } not match') 1070 | lcl_8 = builtin_cons(lcl_8, builtin_nil) 1071 | lcl_8 = (False, lcl_8) 1072 | lcl_7 = lcl_8 1073 | else: 1074 | lcl_8 = mkblock(rbnf_tmp_1) 1075 | rbnf_tmp_1_ = lcl_8 1076 | lcl_8 = (True, rbnf_tmp_1_) 1077 | lcl_7 = lcl_8 1078 | lcl_6 = lcl_7 1079 | lcl_4 = lcl_6 1080 | elif lcl_5 == 10: 1081 | _rbnf_old_offset = builtin_tokens.offset 1082 | _rbnf_cur_token = builtin_tokens.array[_rbnf_old_offset] 1083 | builtin_tokens.offset = _rbnf_old_offset + 1 1084 | lcl_6 = _rbnf_cur_token 1085 | rbnf_tmp_1 = lcl_6 1086 | lcl_6 = const(None) 1087 | rbnf_tmp_1_ = lcl_6 1088 | lcl_6 = (True, rbnf_tmp_1_) 1089 | lcl_4 = lcl_6 1090 | elif lcl_5 == 9: 1091 | lcl_6 = rbnf_named_parse_rbnfmacro_0(builtin_state, builtin_tokens) 1092 | rbnf_named__check_1 = lcl_6 1093 | lcl_6 = rbnf_named__check_1[0] 1094 | lcl_6 = lcl_6 == False 1095 | if lcl_6: 1096 | lcl_6 = rbnf_named__check_1 1097 | else: 1098 | lcl_7 = rbnf_named__check_1[1] 1099 | rbnf_tmp_1 = lcl_7 1100 | try: 1101 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 1102 | if _rbnf_cur_token.idint is 10: 1103 | builtin_tokens.offset += 1 1104 | else: 1105 | _rbnf_cur_token = None 1106 | except IndexError: 1107 | _rbnf_cur_token = None 1108 | lcl_7 = _rbnf_cur_token 1109 | rbnf_tmp_2 = lcl_7 1110 | lcl_7 = rbnf_tmp_2 is None 1111 | if lcl_7: 1112 | lcl_8 = builtin_tokens.offset 1113 | lcl_8 = (lcl_8, 'quote } not match') 1114 | lcl_8 = builtin_cons(lcl_8, builtin_nil) 1115 | lcl_8 = (False, lcl_8) 1116 | lcl_7 = lcl_8 1117 | else: 1118 | lcl_8 = mkblock(rbnf_tmp_1) 1119 | rbnf_tmp_1_ = lcl_8 1120 | lcl_8 = (True, rbnf_tmp_1_) 1121 | lcl_7 = lcl_8 1122 | lcl_6 = lcl_7 1123 | lcl_4 = lcl_6 1124 | elif lcl_5 == 11: 1125 | lcl_6 = rbnf_named_parse_rbnfmacro_0(builtin_state, builtin_tokens) 1126 | rbnf_named__check_1 = lcl_6 1127 | lcl_6 = rbnf_named__check_1[0] 1128 | lcl_6 = lcl_6 == False 1129 | if lcl_6: 1130 | lcl_6 = rbnf_named__check_1 1131 | else: 1132 | lcl_7 = rbnf_named__check_1[1] 1133 | rbnf_tmp_1 = lcl_7 1134 | try: 1135 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 1136 | if _rbnf_cur_token.idint is 10: 1137 | builtin_tokens.offset += 1 1138 | else: 1139 | _rbnf_cur_token = None 1140 | except IndexError: 1141 | _rbnf_cur_token = None 1142 | lcl_7 = _rbnf_cur_token 1143 | rbnf_tmp_2 = lcl_7 1144 | lcl_7 = rbnf_tmp_2 is None 1145 | if lcl_7: 1146 | lcl_8 = builtin_tokens.offset 1147 | lcl_8 = (lcl_8, 'quote } not match') 1148 | lcl_8 = builtin_cons(lcl_8, builtin_nil) 1149 | lcl_8 = (False, lcl_8) 1150 | lcl_7 = lcl_8 1151 | else: 1152 | lcl_8 = mkblock(rbnf_tmp_1) 1153 | rbnf_tmp_1_ = lcl_8 1154 | lcl_8 = (True, rbnf_tmp_1_) 1155 | lcl_7 = lcl_8 1156 | lcl_6 = lcl_7 1157 | lcl_4 = lcl_6 1158 | elif lcl_5 == 5: 1159 | lcl_6 = rbnf_named_parse_rbnfmacro_0(builtin_state, builtin_tokens) 1160 | rbnf_named__check_1 = lcl_6 1161 | lcl_6 = rbnf_named__check_1[0] 1162 | lcl_6 = lcl_6 == False 1163 | if lcl_6: 1164 | lcl_6 = rbnf_named__check_1 1165 | else: 1166 | lcl_7 = rbnf_named__check_1[1] 1167 | rbnf_tmp_1 = lcl_7 1168 | try: 1169 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 1170 | if _rbnf_cur_token.idint is 10: 1171 | builtin_tokens.offset += 1 1172 | else: 1173 | _rbnf_cur_token = None 1174 | except IndexError: 1175 | _rbnf_cur_token = None 1176 | lcl_7 = _rbnf_cur_token 1177 | rbnf_tmp_2 = lcl_7 1178 | lcl_7 = rbnf_tmp_2 is None 1179 | if lcl_7: 1180 | lcl_8 = builtin_tokens.offset 1181 | lcl_8 = (lcl_8, 'quote } not match') 1182 | lcl_8 = builtin_cons(lcl_8, builtin_nil) 1183 | lcl_8 = (False, lcl_8) 1184 | lcl_7 = lcl_8 1185 | else: 1186 | lcl_8 = mkblock(rbnf_tmp_1) 1187 | rbnf_tmp_1_ = lcl_8 1188 | lcl_8 = (True, rbnf_tmp_1_) 1189 | lcl_7 = lcl_8 1190 | lcl_6 = lcl_7 1191 | lcl_4 = lcl_6 1192 | elif lcl_5 == 3: 1193 | lcl_6 = rbnf_named_parse_rbnfmacro_0(builtin_state, builtin_tokens) 1194 | rbnf_named__check_1 = lcl_6 1195 | lcl_6 = rbnf_named__check_1[0] 1196 | lcl_6 = lcl_6 == False 1197 | if lcl_6: 1198 | lcl_6 = rbnf_named__check_1 1199 | else: 1200 | lcl_7 = rbnf_named__check_1[1] 1201 | rbnf_tmp_1 = lcl_7 1202 | try: 1203 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 1204 | if _rbnf_cur_token.idint is 10: 1205 | builtin_tokens.offset += 1 1206 | else: 1207 | _rbnf_cur_token = None 1208 | except IndexError: 1209 | _rbnf_cur_token = None 1210 | lcl_7 = _rbnf_cur_token 1211 | rbnf_tmp_2 = lcl_7 1212 | lcl_7 = rbnf_tmp_2 is None 1213 | if lcl_7: 1214 | lcl_8 = builtin_tokens.offset 1215 | lcl_8 = (lcl_8, 'quote } not match') 1216 | lcl_8 = builtin_cons(lcl_8, builtin_nil) 1217 | lcl_8 = (False, lcl_8) 1218 | lcl_7 = lcl_8 1219 | else: 1220 | lcl_8 = mkblock(rbnf_tmp_1) 1221 | rbnf_tmp_1_ = lcl_8 1222 | lcl_8 = (True, rbnf_tmp_1_) 1223 | lcl_7 = lcl_8 1224 | lcl_6 = lcl_7 1225 | lcl_4 = lcl_6 1226 | elif lcl_5 == 14: 1227 | lcl_6 = rbnf_named_parse_rbnfmacro_0(builtin_state, builtin_tokens) 1228 | rbnf_named__check_1 = lcl_6 1229 | lcl_6 = rbnf_named__check_1[0] 1230 | lcl_6 = lcl_6 == False 1231 | if lcl_6: 1232 | lcl_6 = rbnf_named__check_1 1233 | else: 1234 | lcl_7 = rbnf_named__check_1[1] 1235 | rbnf_tmp_1 = lcl_7 1236 | try: 1237 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 1238 | if _rbnf_cur_token.idint is 10: 1239 | builtin_tokens.offset += 1 1240 | else: 1241 | _rbnf_cur_token = None 1242 | except IndexError: 1243 | _rbnf_cur_token = None 1244 | lcl_7 = _rbnf_cur_token 1245 | rbnf_tmp_2 = lcl_7 1246 | lcl_7 = rbnf_tmp_2 is None 1247 | if lcl_7: 1248 | lcl_8 = builtin_tokens.offset 1249 | lcl_8 = (lcl_8, 'quote } not match') 1250 | lcl_8 = builtin_cons(lcl_8, builtin_nil) 1251 | lcl_8 = (False, lcl_8) 1252 | lcl_7 = lcl_8 1253 | else: 1254 | lcl_8 = mkblock(rbnf_tmp_1) 1255 | rbnf_tmp_1_ = lcl_8 1256 | lcl_8 = (True, rbnf_tmp_1_) 1257 | lcl_7 = lcl_8 1258 | lcl_6 = lcl_7 1259 | lcl_4 = lcl_6 1260 | elif lcl_5 == 7: 1261 | lcl_6 = rbnf_named_parse_rbnfmacro_0(builtin_state, builtin_tokens) 1262 | rbnf_named__check_1 = lcl_6 1263 | lcl_6 = rbnf_named__check_1[0] 1264 | lcl_6 = lcl_6 == False 1265 | if lcl_6: 1266 | lcl_6 = rbnf_named__check_1 1267 | else: 1268 | lcl_7 = rbnf_named__check_1[1] 1269 | rbnf_tmp_1 = lcl_7 1270 | try: 1271 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 1272 | if _rbnf_cur_token.idint is 10: 1273 | builtin_tokens.offset += 1 1274 | else: 1275 | _rbnf_cur_token = None 1276 | except IndexError: 1277 | _rbnf_cur_token = None 1278 | lcl_7 = _rbnf_cur_token 1279 | rbnf_tmp_2 = lcl_7 1280 | lcl_7 = rbnf_tmp_2 is None 1281 | if lcl_7: 1282 | lcl_8 = builtin_tokens.offset 1283 | lcl_8 = (lcl_8, 'quote } not match') 1284 | lcl_8 = builtin_cons(lcl_8, builtin_nil) 1285 | lcl_8 = (False, lcl_8) 1286 | lcl_7 = lcl_8 1287 | else: 1288 | lcl_8 = mkblock(rbnf_tmp_1) 1289 | rbnf_tmp_1_ = lcl_8 1290 | lcl_8 = (True, rbnf_tmp_1_) 1291 | lcl_7 = lcl_8 1292 | lcl_6 = lcl_7 1293 | lcl_4 = lcl_6 1294 | elif lcl_5 == 15: 1295 | lcl_6 = rbnf_named_parse_rbnfmacro_0(builtin_state, builtin_tokens) 1296 | rbnf_named__check_1 = lcl_6 1297 | lcl_6 = rbnf_named__check_1[0] 1298 | lcl_6 = lcl_6 == False 1299 | if lcl_6: 1300 | lcl_6 = rbnf_named__check_1 1301 | else: 1302 | lcl_7 = rbnf_named__check_1[1] 1303 | rbnf_tmp_1 = lcl_7 1304 | try: 1305 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 1306 | if _rbnf_cur_token.idint is 10: 1307 | builtin_tokens.offset += 1 1308 | else: 1309 | _rbnf_cur_token = None 1310 | except IndexError: 1311 | _rbnf_cur_token = None 1312 | lcl_7 = _rbnf_cur_token 1313 | rbnf_tmp_2 = lcl_7 1314 | lcl_7 = rbnf_tmp_2 is None 1315 | if lcl_7: 1316 | lcl_8 = builtin_tokens.offset 1317 | lcl_8 = (lcl_8, 'quote } not match') 1318 | lcl_8 = builtin_cons(lcl_8, builtin_nil) 1319 | lcl_8 = (False, lcl_8) 1320 | lcl_7 = lcl_8 1321 | else: 1322 | lcl_8 = mkblock(rbnf_tmp_1) 1323 | rbnf_tmp_1_ = lcl_8 1324 | lcl_8 = (True, rbnf_tmp_1_) 1325 | lcl_7 = lcl_8 1326 | lcl_6 = lcl_7 1327 | lcl_4 = lcl_6 1328 | else: 1329 | lcl_6 = (rbnf_named__off_1, 'exp lookahead failed') 1330 | lcl_6 = builtin_cons(lcl_6, builtin_nil) 1331 | lcl_6 = (False, lcl_6) 1332 | lcl_4 = lcl_6 1333 | lcl_3 = lcl_4 1334 | else: 1335 | lcl_4 = (rbnf_named__off_1, 'exp got EOF') 1336 | lcl_4 = builtin_cons(lcl_4, builtin_nil) 1337 | lcl_4 = (False, lcl_4) 1338 | lcl_3 = lcl_4 1339 | lcl_1 = lcl_3 1340 | elif lcl_2 == 11: 1341 | _rbnf_old_offset = builtin_tokens.offset 1342 | _rbnf_cur_token = builtin_tokens.array[_rbnf_old_offset] 1343 | builtin_tokens.offset = _rbnf_old_offset + 1 1344 | lcl_3 = _rbnf_cur_token 1345 | rbnf_tmp_0 = lcl_3 1346 | lcl_3 = rbnf_named_parse_exp(builtin_state, builtin_tokens) 1347 | rbnf_named__check_1 = lcl_3 1348 | lcl_3 = rbnf_named__check_1[0] 1349 | lcl_3 = lcl_3 == False 1350 | if lcl_3: 1351 | lcl_3 = rbnf_named__check_1 1352 | else: 1353 | lcl_4 = rbnf_named__check_1[1] 1354 | rbnf_tmp_1 = lcl_4 1355 | try: 1356 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 1357 | if _rbnf_cur_token.idint is 12: 1358 | builtin_tokens.offset += 1 1359 | else: 1360 | _rbnf_cur_token = None 1361 | except IndexError: 1362 | _rbnf_cur_token = None 1363 | lcl_4 = _rbnf_cur_token 1364 | rbnf_tmp_2 = lcl_4 1365 | lcl_4 = rbnf_tmp_2 is None 1366 | if lcl_4: 1367 | lcl_5 = builtin_tokens.offset 1368 | lcl_5 = (lcl_5, 'quote then not match') 1369 | lcl_5 = builtin_cons(lcl_5, builtin_nil) 1370 | lcl_5 = (False, lcl_5) 1371 | lcl_4 = lcl_5 1372 | else: 1373 | lcl_5 = rbnf_named_parse_exp(builtin_state, builtin_tokens) 1374 | rbnf_named__check_3 = lcl_5 1375 | lcl_5 = rbnf_named__check_3[0] 1376 | lcl_5 = lcl_5 == False 1377 | if lcl_5: 1378 | lcl_5 = rbnf_named__check_3 1379 | else: 1380 | lcl_6 = rbnf_named__check_3[1] 1381 | rbnf_tmp_3 = lcl_6 1382 | try: 1383 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 1384 | if _rbnf_cur_token.idint is 13: 1385 | builtin_tokens.offset += 1 1386 | else: 1387 | _rbnf_cur_token = None 1388 | except IndexError: 1389 | _rbnf_cur_token = None 1390 | lcl_6 = _rbnf_cur_token 1391 | rbnf_tmp_4 = lcl_6 1392 | lcl_6 = rbnf_tmp_4 is None 1393 | if lcl_6: 1394 | lcl_7 = builtin_tokens.offset 1395 | lcl_7 = (lcl_7, 'quote else not match') 1396 | lcl_7 = builtin_cons(lcl_7, builtin_nil) 1397 | lcl_7 = (False, lcl_7) 1398 | lcl_6 = lcl_7 1399 | else: 1400 | lcl_7 = rbnf_named_parse_exp(builtin_state, builtin_tokens) 1401 | rbnf_named__check_5 = lcl_7 1402 | lcl_7 = rbnf_named__check_5[0] 1403 | lcl_7 = lcl_7 == False 1404 | if lcl_7: 1405 | lcl_7 = rbnf_named__check_5 1406 | else: 1407 | lcl_8 = rbnf_named__check_5[1] 1408 | rbnf_tmp_5 = lcl_8 1409 | lcl_8 = mkif(rbnf_tmp_1, rbnf_tmp_3, rbnf_tmp_5) 1410 | rbnf_tmp_1_ = lcl_8 1411 | lcl_8 = (True, rbnf_tmp_1_) 1412 | lcl_7 = lcl_8 1413 | lcl_6 = lcl_7 1414 | lcl_5 = lcl_6 1415 | lcl_4 = lcl_5 1416 | lcl_3 = lcl_4 1417 | lcl_1 = lcl_3 1418 | elif lcl_2 == 5: 1419 | _rbnf_old_offset = builtin_tokens.offset 1420 | _rbnf_cur_token = builtin_tokens.array[_rbnf_old_offset] 1421 | builtin_tokens.offset = _rbnf_old_offset + 1 1422 | lcl_3 = _rbnf_cur_token 1423 | rbnf_tmp_0 = lcl_3 1424 | lcl_3 = rbnf_named_parse_args(builtin_state, builtin_tokens) 1425 | rbnf_named__check_1 = lcl_3 1426 | lcl_3 = rbnf_named__check_1[0] 1427 | lcl_3 = lcl_3 == False 1428 | if lcl_3: 1429 | lcl_3 = rbnf_named__check_1 1430 | else: 1431 | lcl_4 = rbnf_named__check_1[1] 1432 | rbnf_tmp_1 = lcl_4 1433 | try: 1434 | _rbnf_cur_token = builtin_tokens.array[builtin_tokens.offset] 1435 | if _rbnf_cur_token.idint is 6: 1436 | builtin_tokens.offset += 1 1437 | else: 1438 | _rbnf_cur_token = None 1439 | except IndexError: 1440 | _rbnf_cur_token = None 1441 | lcl_4 = _rbnf_cur_token 1442 | rbnf_tmp_2 = lcl_4 1443 | lcl_4 = rbnf_tmp_2 is None 1444 | if lcl_4: 1445 | lcl_5 = builtin_tokens.offset 1446 | lcl_5 = (lcl_5, 'quote => not match') 1447 | lcl_5 = builtin_cons(lcl_5, builtin_nil) 1448 | lcl_5 = (False, lcl_5) 1449 | lcl_4 = lcl_5 1450 | else: 1451 | lcl_5 = rbnf_named_parse_exp(builtin_state, builtin_tokens) 1452 | rbnf_named__check_3 = lcl_5 1453 | lcl_5 = rbnf_named__check_3[0] 1454 | lcl_5 = lcl_5 == False 1455 | if lcl_5: 1456 | lcl_5 = rbnf_named__check_3 1457 | else: 1458 | lcl_6 = rbnf_named__check_3[1] 1459 | rbnf_tmp_3 = lcl_6 1460 | lcl_6 = mkfunc(rbnf_tmp_1, rbnf_tmp_3) 1461 | rbnf_tmp_1_ = lcl_6 1462 | lcl_6 = (True, rbnf_tmp_1_) 1463 | lcl_5 = lcl_6 1464 | lcl_4 = lcl_5 1465 | lcl_3 = lcl_4 1466 | lcl_1 = lcl_3 1467 | elif lcl_2 == 3: 1468 | lcl_3 = rbnf_named_parse_app(builtin_state, builtin_tokens) 1469 | rbnf_named__check_0 = lcl_3 1470 | lcl_3 = rbnf_named__check_0[0] 1471 | lcl_3 = lcl_3 == False 1472 | if lcl_3: 1473 | lcl_3 = rbnf_named__check_0 1474 | else: 1475 | lcl_4 = rbnf_named__check_0[1] 1476 | rbnf_tmp_0 = lcl_4 1477 | rbnf_tmp_1_ = rbnf_tmp_0 1478 | lcl_4 = (True, rbnf_tmp_1_) 1479 | lcl_3 = lcl_4 1480 | lcl_1 = lcl_3 1481 | elif lcl_2 == 14: 1482 | lcl_3 = rbnf_named_parse_app(builtin_state, builtin_tokens) 1483 | rbnf_named__check_0 = lcl_3 1484 | lcl_3 = rbnf_named__check_0[0] 1485 | lcl_3 = lcl_3 == False 1486 | if lcl_3: 1487 | lcl_3 = rbnf_named__check_0 1488 | else: 1489 | lcl_4 = rbnf_named__check_0[1] 1490 | rbnf_tmp_0 = lcl_4 1491 | rbnf_tmp_1_ = rbnf_tmp_0 1492 | lcl_4 = (True, rbnf_tmp_1_) 1493 | lcl_3 = lcl_4 1494 | lcl_1 = lcl_3 1495 | elif lcl_2 == 7: 1496 | lcl_3 = builtin_tokens.offset 1497 | rbnf_named__off_1 = lcl_3 1498 | try: 1499 | builtin_tokens.array[builtin_tokens.offset + 1] 1500 | _rbnf_peek_tmp = True 1501 | except IndexError: 1502 | _rbnf_peek_tmp = False 1503 | lcl_3 = _rbnf_peek_tmp 1504 | if lcl_3: 1505 | lcl_5 = builtin_tokens.array[builtin_tokens.offset + 1] 1506 | lcl_5 = lcl_5.idint 1507 | if lcl_5 == 8: 1508 | _rbnf_old_offset = builtin_tokens.offset 1509 | _rbnf_cur_token = builtin_tokens.array[_rbnf_old_offset] 1510 | builtin_tokens.offset = _rbnf_old_offset + 1 1511 | lcl_6 = _rbnf_cur_token 1512 | rbnf_tmp_0 = lcl_6 1513 | _rbnf_old_offset = builtin_tokens.offset 1514 | _rbnf_cur_token = builtin_tokens.array[_rbnf_old_offset] 1515 | builtin_tokens.offset = _rbnf_old_offset + 1 1516 | lcl_6 = _rbnf_cur_token 1517 | rbnf_tmp_1 = lcl_6 1518 | lcl_6 = rbnf_named_parse_exp(builtin_state, builtin_tokens) 1519 | rbnf_named__check_2 = lcl_6 1520 | lcl_6 = rbnf_named__check_2[0] 1521 | lcl_6 = lcl_6 == False 1522 | if lcl_6: 1523 | lcl_6 = rbnf_named__check_2 1524 | else: 1525 | lcl_7 = rbnf_named__check_2[1] 1526 | rbnf_tmp_2 = lcl_7 1527 | lcl_7 = rbnf_tmp_0.value 1528 | lcl_7 = mkassign(lcl_7, rbnf_tmp_2) 1529 | rbnf_tmp_1_ = lcl_7 1530 | lcl_7 = (True, rbnf_tmp_1_) 1531 | lcl_6 = lcl_7 1532 | lcl_4 = lcl_6 1533 | elif lcl_5 == 3: 1534 | lcl_6 = rbnf_named_parse_app(builtin_state, builtin_tokens) 1535 | rbnf_named__check_0 = lcl_6 1536 | lcl_6 = rbnf_named__check_0[0] 1537 | lcl_6 = lcl_6 == False 1538 | if lcl_6: 1539 | lcl_6 = rbnf_named__check_0 1540 | else: 1541 | lcl_7 = rbnf_named__check_0[1] 1542 | rbnf_tmp_0 = lcl_7 1543 | rbnf_tmp_1_ = rbnf_tmp_0 1544 | lcl_7 = (True, rbnf_tmp_1_) 1545 | lcl_6 = lcl_7 1546 | lcl_4 = lcl_6 1547 | else: 1548 | lcl_6 = rbnf_named_parse_app(builtin_state, builtin_tokens) 1549 | rbnf_named__check_0 = lcl_6 1550 | lcl_6 = rbnf_named__check_0[0] 1551 | lcl_6 = lcl_6 == False 1552 | if lcl_6: 1553 | lcl_6 = rbnf_named__check_0 1554 | else: 1555 | lcl_7 = rbnf_named__check_0[1] 1556 | rbnf_tmp_0 = lcl_7 1557 | rbnf_tmp_1_ = rbnf_tmp_0 1558 | lcl_7 = (True, rbnf_tmp_1_) 1559 | lcl_6 = lcl_7 1560 | lcl_4 = lcl_6 1561 | lcl_3 = lcl_4 1562 | else: 1563 | lcl_4 = (rbnf_named__off_1, 'exp got EOF') 1564 | lcl_4 = builtin_cons(lcl_4, builtin_nil) 1565 | lcl_4 = (False, lcl_4) 1566 | lcl_3 = lcl_4 1567 | lcl_1 = lcl_3 1568 | elif lcl_2 == 15: 1569 | lcl_3 = rbnf_named_parse_app(builtin_state, builtin_tokens) 1570 | rbnf_named__check_0 = lcl_3 1571 | lcl_3 = rbnf_named__check_0[0] 1572 | lcl_3 = lcl_3 == False 1573 | if lcl_3: 1574 | lcl_3 = rbnf_named__check_0 1575 | else: 1576 | lcl_4 = rbnf_named__check_0[1] 1577 | rbnf_tmp_0 = lcl_4 1578 | rbnf_tmp_1_ = rbnf_tmp_0 1579 | lcl_4 = (True, rbnf_tmp_1_) 1580 | lcl_3 = lcl_4 1581 | lcl_1 = lcl_3 1582 | else: 1583 | lcl_3 = (rbnf_named__off_0, 'exp lookahead failed') 1584 | lcl_3 = builtin_cons(lcl_3, builtin_nil) 1585 | lcl_3 = (False, lcl_3) 1586 | lcl_1 = lcl_3 1587 | lcl_0 = lcl_1 1588 | else: 1589 | lcl_1 = (rbnf_named__off_0, 'exp got EOF') 1590 | lcl_1 = builtin_cons(lcl_1, builtin_nil) 1591 | lcl_1 = (False, lcl_1) 1592 | lcl_0 = lcl_1 1593 | return lcl_0 1594 | 1595 | def rbnf_named_parse_rbnfmacro_0(builtin_state, builtin_tokens): 1596 | lcl_0 = rbnf_named_parse_exp(builtin_state, builtin_tokens) 1597 | rbnf_named__check_0 = lcl_0 1598 | lcl_0 = rbnf_named__check_0[0] 1599 | lcl_0 = lcl_0 == False 1600 | if lcl_0: 1601 | lcl_0 = rbnf_named__check_0 1602 | else: 1603 | lcl_1 = rbnf_named__check_0[1] 1604 | rbnf_tmp_0 = lcl_1 1605 | lcl_1 = [] 1606 | _rbnf_immediate_lst = lcl_1 1607 | _rbnf_immediate_lst.append(rbnf_tmp_0) 1608 | lcl_1 = _rbnf_immediate_lst 1609 | rbnf_tmp_1_ = lcl_1 1610 | lcl_1 = rbnf_named_lr_loop_rbnfmacro_0(rbnf_tmp_1_, builtin_state, builtin_tokens) 1611 | lcl_0 = lcl_1 1612 | return lcl_0 1613 | 1614 | def rbnf_named_parse_rbnfmacro_1(builtin_state, builtin_tokens): 1615 | lcl_0 = rbnf_named_parse_arg(builtin_state, builtin_tokens) 1616 | rbnf_named__check_0 = lcl_0 1617 | lcl_0 = rbnf_named__check_0[0] 1618 | lcl_0 = lcl_0 == False 1619 | if lcl_0: 1620 | lcl_0 = rbnf_named__check_0 1621 | else: 1622 | lcl_1 = rbnf_named__check_0[1] 1623 | rbnf_tmp_0 = lcl_1 1624 | lcl_1 = [] 1625 | _rbnf_immediate_lst = lcl_1 1626 | _rbnf_immediate_lst.append(rbnf_tmp_0) 1627 | lcl_1 = _rbnf_immediate_lst 1628 | rbnf_tmp_1_ = lcl_1 1629 | lcl_1 = rbnf_named_lr_loop_rbnfmacro_1(rbnf_tmp_1_, builtin_state, builtin_tokens) 1630 | lcl_0 = lcl_1 1631 | return lcl_0 1632 | 1633 | def rbnf_named_parse_rbnfmacro_2(builtin_state, builtin_tokens): 1634 | lcl_0 = rbnf_named_parse_exp(builtin_state, builtin_tokens) 1635 | rbnf_named__check_0 = lcl_0 1636 | lcl_0 = rbnf_named__check_0[0] 1637 | lcl_0 = lcl_0 == False 1638 | if lcl_0: 1639 | lcl_0 = rbnf_named__check_0 1640 | else: 1641 | lcl_1 = rbnf_named__check_0[1] 1642 | rbnf_tmp_0 = lcl_1 1643 | lcl_1 = [] 1644 | _rbnf_immediate_lst = lcl_1 1645 | _rbnf_immediate_lst.append(rbnf_tmp_0) 1646 | lcl_1 = _rbnf_immediate_lst 1647 | rbnf_tmp_1_ = lcl_1 1648 | lcl_1 = rbnf_named_lr_loop_rbnfmacro_2(rbnf_tmp_1_, builtin_state, builtin_tokens) 1649 | lcl_0 = lcl_1 1650 | return lcl_0 1651 | return rbnf_named_parse_START -------------------------------------------------------------------------------- /run.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | warnings.filterwarnings('ignore', category=SyntaxWarning, message='"is" with a literal') 3 | 4 | from easylang_lex import lexer 5 | from easylang_parser import * 6 | 7 | __all__ = ["parse"] 8 | _parse = mk_parser() 9 | 10 | 11 | def parse(text: str, filename: str = "unknown"): 12 | tokens = lexer(filename, text) 13 | status, res_or_err = _parse(None, Tokens(tokens)) 14 | if status: 15 | return res_or_err 16 | 17 | msgs = [] 18 | lineno = None 19 | colno = None 20 | filename = None 21 | offset = 0 22 | msg = "" 23 | for each in res_or_err: 24 | i, msg = each 25 | token = tokens[i] 26 | lineno = token.lineno + 1 27 | colno = token.colno 28 | offset = token.offset 29 | filename = token.filename 30 | break 31 | e = SyntaxError(msg) 32 | e.lineno = lineno 33 | e.colno = colno 34 | e.filename = filename 35 | e.text = text[offset - colno : text.find("\n", offset)] 36 | e.offset = colno 37 | raise e 38 | 39 | 40 | # exp = parse( 41 | # """ 42 | # print(add(1, 2)) 43 | # k = fun (x, y, z) => 44 | # { 45 | # if gt(x, y) 46 | # then add(z, 1) 47 | # else add(z, -1) 48 | # } 49 | # 50 | # print(k(1, 2, 3)) 51 | # print(k(2, 1, 3)) 52 | # """, 53 | # "", 54 | # ) 55 | 56 | import operator 57 | 58 | ctx = {"+": operator.add, "print": print, ">": operator.gt} 59 | 60 | while True: 61 | try: 62 | source_code = input("simple> ") 63 | filename = "" 64 | obj = parse(source_code, filename) 65 | print(obj(ctx)) 66 | except Exception as e: 67 | print(type(e), e) 68 | --------------------------------------------------------------------------------