Validating x,y coordinates [message #1787047] |
Thu, 17 May 2018 13:48  |
Eclipse User |
|
|
|
Hello, I am working on an assignment and have a slight issue understanding something about validation and the grammar.
Currently this is my grammar (only showing relevant parts, ... is omitted code):
Game:
'Game' name=ID grid=GridSize ...
;
GridSize:
'Grid' 'size' size=Coordinates
;
Coordinates:
'('x=INT','y=INT')'
;
...
And this is my validation definition:
@Check
def void checkGridCoordinates(Game game) {
val minValue = 1
val maxValue = 10
var x = game.grid.size.x
var y = game.grid.size.y
var literal = MetaGameLanguagePackage.Literals.GRID_SIZE__SIZE
if(x < minValue || y < minValue){
error("Grid size must be at least 1.",literal)
} else if(x > maxValue || y > maxValue) {
this.error("Grid size must be 10 or under.", literal)
}
}
I get the following error, which happens if I try to set the grid x and y to be either 0 or under or above 10 (which is expected but I want it to display the error message and not fail to validate):
Description Resource Path Location Type
Error executing EValidator TestingFile.gl /IndividualExtension/src /IndividualExtension/src/TestingFile.gl GameLang Problem
Since this is an assignment I would appreciate it if you could hint me in a direction in which I can experiment, instead of handing me a solution :)
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04264 seconds