-
Notifications
You must be signed in to change notification settings - Fork 0
Pag Grammar Definition
This is a work in Progress
You read that right, this is a grammar for our grammar. That is, this defines the format for the grammars one can use for procedural generation.
PAG := SECTION+
SECTION := COMMENT NEWLINE SECTION | PRIORITY NEWLINE SECTION | RULE
COMMENT := ##[^NEWLINE]+
PRIORITY := Priority NUMBER:
RULE := (PREDECESSOR : CONDITIONAL -> SUCCESSOR : PROBABILITY)
PREDECESSOR := ALPHANUMERIC+(LPAREN PARAM(,PARAM)* RPAREN)?
CONDITIONAL := CONDVAR OP CONDVAR | OCCLUSION | !LPAREN CONDITIONAL RPAREN | CONDITIONAL && CONDITIONAL | CONDITIONAL || CONDITIONAL
CONDVAR := PROBVAR | VARARITHMETIC
SCOPEVAR := Scope\.(X | Y | Z | S | P)
OCCLUSION := (Shape.occ LPAREN "LETTER+ " RPAREN (== | !=) ("none" | "part" | "full")) | (Shape.visible LPAREN "LETTER+ " RPAREN)
OP := == | != | > | >= | < | <=
PROBABILITY := FLOAT | VARARITHMETIC
VARARITHMETIC := PROBVAR ARITHMETIC PROBVAR | LPAREN VARARITHMETIC RPAREN ARITHMETIC LPAREN VARARITHMETIC RPAREN
PROBVAR := SCOPEVAR | NUMBER | PARAM | FLOAT
ARITHMETIC := \+ | - | \* | \\
SUCCESSOR := PREDECESSOR | BASERULE
BASERULE := TODO
PARAM := LETTER
ALPHANUMERIC := LETTER | NUMBER
NUMBER := [0-9]
LETTER := [A-Za-z]
LPAREN := \ (
RPAREN := \ )
FLOAT := NUMBER*\.NUMBER+
NEWLINE := \n (maybe use \s instead?)
I use the regular expression notation for + (1 or more), ? (at most 1), brackets for characters, * (for 0 or more), backslash for escaping, and parenthesis for grouping.