Alvaro Bilbao
Alvaro Bilbao

Reputation: 23

xtext code generation, how to avoid the code generation of a line?

I'm using xtext to generate java code for a college assignment, my problem is that i need a counter while generating code so i'm doing this:

    «var i = 0»
        «fc.function.name» («FOR a: fc.arguments SEPARATOR ','»
                                «IF (a instanceof InputExpression || a instanceof OutputExpression) && symbolTable.get(fc.function.name).get(fc.function.parameters.get(i).name).equals("int")»
                                    parseInt(«generateExpression(a)»)
                                «ELSE»
                                    «generateExpression(a)»
                                «ENDIF»
                                «i=i+1»
                            «ENDFOR»)

but every time the line «i=i+1» is reached, it generates the value of i, how can i avoid the generation in code of this line?

Upvotes: 1

Views: 172

Answers (1)

Sebastian Zarnekow
Sebastian Zarnekow

Reputation: 6729

Please try «{i=i+1; null}». Null values will not be printed, but the value of an assignment is the assigned value itself. By using null explicitly, you could avoid that.

Upvotes: 1

Related Questions