Prolog中DCG表示中的语法错误?

时间:2015-05-12 20:11:08

标签: prolog syntax-error dcg

我正在使用prolog的DCG为游戏模拟编写语法。我假设逻辑是正确的,我得到以下语法错误。

program --> envsetup, commands. 
envsetup --> boardsize, obstacles, itinerary, character. 
boardsize --> xsize, ysize.
xsize --> "XSIZE", xysizenext.
xysizenext --> ':', integer, ';'.
ysize --> "YSIZE", xysizenext.
obstacles --> "OBSTACLE", coordinates, obs.
coordinates --> '[', integer , ',', integer , ']', ';'.
obs --> [obstacles].
character --> "CHARACTER", char.
itinerary --> start, end.
start --> "START", coordinates.
end --> "END", coordinates.
commands --> going, commands; turning, commands; changingspeed, commands; sensing, commands; printing, commands; stopping, commands; stat, commands.
going --> "GO", integer , ';', go.
go --> [going].
turning --> "TURN", direction, ';', turn.
turn --> [turning].
direction --> '(', "LEFT" ,')' ';' ; '(', "LEFT" ,')' ';'.
changingspeed --> "CHANGESPEED", '+'; '-', integer , ';', changingspeed.
sensing --> "SENSE", '(', integer,')',';' sense.
sense --> [sensing].
printing --> "PRINT", arguments.
arguments --> String, ';'; ',', arguments; integer ,  ';'; ','.
stopping --> "STOP".
stat --> "OKAY"; "ERROR".

这是我得到的错误:

ERROR: c:/users/its/desktop/dcggame.p:19:37: Syntax error: Operator expected
ERROR: c:/users/its/desktop/dcggame.p:21:42: Syntax error: Operator expected
Warning: c:/users/its/desktop/dcggame.p:24:
        Singleton variables: [String]
Warning: c:/users/its/desktop/dcggame.p:24:
       Singleton variable in branch: String

错误可能是什么?

0 个答案:

没有答案