Fix for some comments during if statements
added test files
This commit is contained in:
parent
58855c2fc7
commit
5f905865be
3 changed files with 25 additions and 1 deletions
|
|
@ -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":
|
||||
|
|
|
|||
21
compiler/c2nim/tests/vincent.c
Normal file
21
compiler/c2nim/tests/vincent.c
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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';
|
||||
}
|
||||
3
compiler/c2nim/tests/vincent.h
Normal file
3
compiler/c2nim/tests/vincent.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
struct foo {
|
||||
int x,y,z;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue