From eb303641d96742d5403580ca7a66755986d5e7c5 Mon Sep 17 00:00:00 2001 From: Paul Mathieu Date: Sat, 20 Mar 2021 21:25:01 -0700 Subject: [PATCH] cc: fix typo --- tools/cc.ebnf | 6 +++--- tools/cc.py | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/cc.ebnf b/tools/cc.ebnf index b3ae672..ce235e3 100644 --- a/tools/cc.ebnf +++ b/tools/cc.ebnf @@ -10,7 +10,7 @@ fun_decl: fun_prot ";" fun_prot: type symbol "(" [fun_param ("," fun_param)*] ")" fun_param: type [symbol] -global_var: type symbol sized_array* empty_array? [ "=" litteral ] ";" +global_var: type symbol sized_array* empty_array? [ "=" literal ] ";" fun_def: fun_prot body @@ -109,7 +109,7 @@ initializer_list: "{" [init_list_field ("," init_list_field)* ","? ] "}" | "&" prec2_expr -> address_of | "sizeof" prec2_expr -> sizeof -?prec1_expr: litteral +?prec1_expr: literal | identifier | "(" expression ")" | prec1_expr "++" -> post_increment @@ -123,7 +123,7 @@ initializer_list: "{" [init_list_field ("," init_list_field)* ","? ] "}" label: IDENTIFIER -litteral: SIGNED_NUMBER | ESCAPED_STRING | HEX_LITTERAL | CHARACTER +literal: SIGNED_NUMBER | ESCAPED_STRING | HEX_LITTERAL | CHARACTER field: IDENTIFIER identifier: IDENTIFIER ?symbol: IDENTIFIER diff --git a/tools/cc.py b/tools/cc.py index df5ca23..1d2b4c3 100644 --- a/tools/cc.py +++ b/tools/cc.py @@ -313,8 +313,8 @@ class CcTransform(lark.visitors.Transformer): @lark.v_args(tree=True) def _f(self, tree): left, right = tree.children - if left.data == 'litteral' and right.data == 'litteral': - tree.data = 'litteral' + if left.data == 'literal' and right.data == 'literal': + tree.data = 'literal' tree.children = [litt(left.children[0], right.children[0])] return tree return _f @@ -360,7 +360,7 @@ class CcTransform(lark.visitors.Transformer): addop = lark.Tree('add', children) return lark.Tree('dereference', [addop]) - # operations on litterals can be done by the compiler + # operations on literals can be done by the compiler add = _binary_op(lambda a, b: a+b) sub = _binary_op(lambda a, b: a-b) mul = _binary_op(lambda a, b: a*b) @@ -862,7 +862,7 @@ class CcInterp(lark.visitors.Interpreter): self.global_scope.symbols[token] = Variable(litt_type(s), token) return token - def litteral(self, tree): + def literal(self, tree): imm = tree.children[0] if isinstance(imm, str): tok = self._make_string(imm) @@ -1064,7 +1064,7 @@ class CcInterp(lark.visitors.Interpreter): strct = self.global_scope.structs[type.struct] offs = strct.offset(ch_field) if offs > 0: - load_offs = lark.Tree('litteral', [offs]) + load_offs = lark.Tree('literal', [offs]) addop = lark.Tree('add', [tree.children[0], load_offs]) self.visit(addop) addop.type = PointerType(pointed=strct.field_type(ch_field))