1

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?

1 Answers1

1

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.

Sebastian Zarnekow
  • 6,609
  • 20
  • 23