changeset 397:5d03c10fe19d

Small changes
author Windel Bouwman
date Thu, 29 May 2014 10:47:28 +0200
parents fb3c1f029b30
children c0d9837acde8
files python/ppci/c3/lexer.py python/ppci/c3/parser.py python/ppci/ir2tree.py python/ppci/irmach.py test/testir.py
diffstat 5 files changed, 17 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/python/ppci/c3/lexer.py	Tue May 27 22:19:32 2014 +0200
+++ b/python/ppci/c3/lexer.py	Thu May 29 10:47:28 2014 +0200
@@ -19,17 +19,20 @@
     def __init__(self, diag):
         self.diag = diag
         tok_spec = [
-           ('REAL', r'\d+\.\d+', lambda typ, val: (typ, float(val))),
-           ('HEXNUMBER', r'0x[\da-fA-F]+', lambda typ, val: ('NUMBER', make_num(val))),
-           ('NUMBER', r'\d+', lambda typ, val: (typ, int(val))),
-           ('ID', r'[A-Za-z][A-Za-z\d_]*', self.handle_id),
-           ('NEWLINE', r'\n', lambda typ, val: self.newline()),
-           ('SKIP', r'[ \t]', None),
-           ('COMMENTS', r'//.*', None),
-           ('LONGCOMMENTBEGIN', r'\/\*', self.handle_comment_start),
-           ('LONGCOMMENTEND', r'\*\/', self.handle_comment_stop),
-           ('LEESTEKEN', r'==|->|<<|>>|!=|\+\+|[\.,=:;\-+*\[\]/\(\)]|>=|<=|<>|>|<|{|}|&|\^|\|', lambda typ, val: (val, val)),
-           ('STRING', r'".*?"', lambda typ, val: (typ, val[1:-1]))
+            ('REAL', r'\d+\.\d+', lambda typ, val: (typ, float(val))),
+            ('HEXNUMBER', r'0x[\da-fA-F]+',
+             lambda typ, val: ('NUMBER', make_num(val))),
+            ('NUMBER', r'\d+', lambda typ, val: (typ, int(val))),
+            ('ID', r'[A-Za-z][A-Za-z\d_]*', self.handle_id),
+            ('NEWLINE', r'\n', lambda typ, val: self.newline()),
+            ('SKIP', r'[ \t]', None),
+            ('COMMENTS', r'//.*', None),
+            ('LONGCOMMENTBEGIN', r'\/\*', self.handle_comment_start),
+            ('LONGCOMMENTEND', r'\*\/', self.handle_comment_stop),
+            ('LEESTEKEN',
+             r'==|->|<<|>>|!=|\+\+|[\.,=:;\-+*\[\]/\(\)]|>=|<=|<>|>|<|{|}|&|\^|\|',
+             lambda typ, val: (val, val)),
+            ('STRING', r'".*?"', lambda typ, val: (typ, val[1:-1]))
             ]
         super().__init__(tok_spec)
 
--- a/python/ppci/c3/parser.py	Tue May 27 22:19:32 2014 +0200
+++ b/python/ppci/c3/parser.py	Thu May 29 10:47:28 2014 +0200
@@ -469,4 +469,3 @@
         elif self.Peak == 'ID':
             return self.parseDesignator()
         self.Error('Expected NUM, ID or (expr), got {0}'.format(self.Peak))
-
--- a/python/ppci/ir2tree.py	Tue May 27 22:19:32 2014 +0200
+++ b/python/ppci/ir2tree.py	Thu May 29 10:47:28 2014 +0200
@@ -18,6 +18,7 @@
     names = {'+':'ADDI32', '-':'SUBI32', '|':'ORI32', '<<':'SHLI32',
         '*':'MULI32', '&':'ANDI32', '>>':'SHRI32'}
     op = names[e.operation]
+    assert e.ty == ir.i32
     return Tree(op, makeTree(e.a), makeTree(e.b))
 
 @register(ir.Temp)
--- a/python/ppci/irmach.py	Tue May 27 22:19:32 2014 +0200
+++ b/python/ppci/irmach.py	Thu May 29 10:47:28 2014 +0200
@@ -53,4 +53,3 @@
             x = '{}, def={}, use={}, other={}'
             x = x.format(cn, self.dst, self.src, self.others)
         return x
-
--- a/test/testir.py	Tue May 27 22:19:32 2014 +0200
+++ b/test/testir.py	Thu May 29 10:47:28 2014 +0200
@@ -70,8 +70,10 @@
         self.b.emit(ir.Jump(bb))
         self.b.setBlock(bb)
         v1 = ir.Const(5)
+        self.b.emit(v1)
         v2 = ir.Const(7)
         v3 = ir.Add(v1, v2, "add", ir.i32)
+        self.b.emit(v3)
         self.b.emit(ir.Jump(f.epiloog))
         self.cf.run(self.m)