Skip to content

Commit

Permalink
fixed second test
Browse files Browse the repository at this point in the history
  • Loading branch information
mrshu committed Nov 18, 2013
1 parent 14099f0 commit 67aafc2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
11 changes: 10 additions & 1 deletion pynxc/first_pass.py
Expand Up @@ -67,7 +67,6 @@ def visitPass(self, node):
self.use_typedef = True

def visitBlock(self, block):
print "in block"
if self.debug:
print "myvisitBlock"
self.v(block)
Expand Down Expand Up @@ -254,6 +253,9 @@ def visitFunction(self, node):
self.variables = old_self_variables
self.scope.pop()

if 'main' in self.functions and self.main != []:
self.main_twice = True

# remove those variables that are global
remove_var = []
for var in self.functions[node.name].variables:
Expand Down Expand Up @@ -285,7 +287,14 @@ def visitWhile(self, node):
self.main_appended = False

def visitFor(self, node):
if self.debug:
print "visitFor"

if not self.main_appended and self.scope[-1] == 'module':

if self.debug:
print "appending to main", node

self.main.append(node)
self.main_appended = True

Expand Down
2 changes: 2 additions & 0 deletions pynxc/second_pass.py
Expand Up @@ -668,6 +668,8 @@ def flush_main(self):
self.write('task main()')
self.INDENT()

if self.debug:
print 'Flushing main:', self.fv.main
for node in self.fv.main:
self.v(node)
self.NEWLINE()
Expand Down
1 change: 0 additions & 1 deletion pynxc/tests/in/implicit_main2.py
@@ -1,6 +1,5 @@



for x in range(10):
NumOut(0, LCD_LINE1, x)

Expand Down
10 changes: 9 additions & 1 deletion pynxc/tests/out/implicit_main2.nxc
@@ -1,5 +1,13 @@
task main() {
void main_() {
TextOut(0, LCD_LINE1, "asd");
Wait(2000);

}
task main() {
for (x=0; x<10; x+=1) {
NumOut(0, LCD_LINE1, x);

}


}

0 comments on commit 67aafc2

Please sign in to comment.