Mercurial > lcfOS
diff python/ppci/layout.py @ 386:2a970e7270e2
Added repeat assembler macro
author | Windel Bouwman |
---|---|
date | Thu, 01 May 2014 17:40:59 +0200 |
parents | d056b552d3f4 |
children |
line wrap: on
line diff
--- a/python/ppci/layout.py Thu May 01 14:03:12 2014 +0200 +++ b/python/ppci/layout.py Thu May 01 17:40:59 2014 +0200 @@ -56,6 +56,14 @@ return 'Align({})'.format(self.alignment) +class SymbolDefinition(Input): + def __init__(self, symbol_name): + self.symbol_name = symbol_name + + def __repr__(self): + return 'Symbol define: {}'.format(self.symbol_name) + + class LayoutLexer(BaseLexer): def __init__(self): tok_spec = [ @@ -67,7 +75,7 @@ ('STRING', r"'.*?'", lambda typ, val: (typ, val[1:-1])), ] super().__init__(tok_spec) - self.kws = ['MEMORY', 'ALIGN', 'LOCATION','SECTION','SIZE'] + self.kws = ['MEMORY', 'ALIGN', 'LOCATION','SECTION','SIZE', 'DEFINESYMBOL'] def handle_id(self, typ, val): if val in self.kws: @@ -90,6 +98,7 @@ g.add_one_or_more('input', 'input_list') g.add_production('input', ['ALIGN', '(', 'NUMBER', ')'], self.handle_align) g.add_production('input', ['SECTION', '(', 'ID', ')'], self.handle_section) + g.add_production('input', ['DEFINESYMBOL', '(', 'ID', ')'], self.handle_defsym) g.start_symbol = 'layout' self.p = g.generate_parser() @@ -112,6 +121,9 @@ def handle_section(self, section_tag, lbrace, section_name, rbrace): return Section(section_name.val) + def handle_defsym(self, section_tag, lbrace, name, rbrace): + return SymbolDefinition(name.val) + class LayoutLoader: def __init__(self):