From 5f905865bed2080c49b29dd48decdd24c4702cc9 Mon Sep 17 00:00:00 2001 From: Vincent Burns Date: Mon, 13 Jan 2014 01:51:36 -0500 Subject: Fix for some comments during if statements added test files --- compiler/c2nim/cparse.nim | 2 +- compiler/c2nim/tests/vincent.c | 21 +++++++++++++++++++++ compiler/c2nim/tests/vincent.h | 3 +++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 compiler/c2nim/tests/vincent.c create mode 100644 compiler/c2nim/tests/vincent.h (limited to 'compiler') diff --git a/compiler/c2nim/cparse.nim b/compiler/c2nim/cparse.nim index aa2dfa3e1..30cee180a 100644 --- a/compiler/c2nim/cparse.nim +++ b/compiler/c2nim/cparse.nim @@ -1473,12 +1473,12 @@ proc parseIf(p: var TParser): PNode = while true: getTok(p) # skip ``if`` var branch = newNodeP(nkElifBranch, p) - skipCom(p, branch) eat(p, pxParLe, branch) addSon(branch, expression(p)) eat(p, pxParRi, branch) addSon(branch, nestedStatement(p)) addSon(result, branch) + skipCom(p, branch) if p.tok.s == "else": getTok(p, result) if p.tok.s != "if": diff --git a/compiler/c2nim/tests/vincent.c b/compiler/c2nim/tests/vincent.c new file mode 100644 index 000000000..b9436c39b --- /dev/null +++ b/compiler/c2nim/tests/vincent.c @@ -0,0 +1,21 @@ +#include +#include + +int rand(void); + +int main() { + float f = .2, + g = 2., + h = 1.0+rand(), + i = 1.0e+3; + int j, a; + for(j = 0, a = 10; j < 0; j++, a++) ; + do { + printf("howdy"); + } while(--i, 0); + if(1) + printf("1"); // error from this comment + else + printf("2"); + return '\x00'; +} diff --git a/compiler/c2nim/tests/vincent.h b/compiler/c2nim/tests/vincent.h new file mode 100644 index 000000000..b4e761ee1 --- /dev/null +++ b/compiler/c2nim/tests/vincent.h @@ -0,0 +1,3 @@ +struct foo { + int x,y,z; +}; -- cgit 1.4.1-2-gfad0