So I'm writing a simple parser for Pascal in SWI-Prolog using Definite Clause Grammars.
I don't understand how to implement repeating (2 or more) or optionally repeating (1 or more) predicates.
For example, in EBNF, for Pascal's "program" is:
"PROGRAM" identifier "(" identifierlist ")" ";" block "."
Where "identifierlist" is:
identifier { "," identifier }
and "identifier" is:
letter { letter | digit }
I know in prolog's DCG form program is:
program --> ["PROGRAM"], identifier, ["("], identifierlist, [")"], [";"], block, ["."].
How do I implement "identifierlist" or even "identifier", which contains an optionally repeating number of "identifier" or "letter" or "digit" predicates?
identifierlist
doesn't seem to indicate so. – lurker