summaryrefslogtreecommitdiffstats
path: root/dimension/common.rules
diff options
context:
space:
mode:
Diffstat (limited to 'dimension/common.rules')
-rw-r--r--dimension/common.rules73
1 files changed, 59 insertions, 14 deletions
diff --git a/dimension/common.rules b/dimension/common.rules
index b4cf631..32eadc7 100644
--- a/dimension/common.rules
+++ b/dimension/common.rules
@@ -526,25 +526,32 @@ TEXTURE_ITEMS: /* empty */ {
/* Pigments */
PIGMENT: "pigment" "{"
- PIGMENT_TYPE
- PIGMENT_MODIFIERS
+ PIGMENT_BODY
"}"
{
- $$ = dmnsn_new_astnode2(DMNSN_AST_PIGMENT, @$, $3, $4);
- }
- | "pigment" "{"
- "checker" COLOR_LIST2
- PIGMENT_MODIFIERS
- "}"
- {
- dmnsn_astnode checker = dmnsn_new_astnode(DMNSN_AST_CHECKER, @3);
- dmnsn_astnode pattern = dmnsn_new_astnode1(DMNSN_AST_PATTERN, @3,
- checker);
- dmnsn_array_push($5.children, &$4);
- $$ = dmnsn_new_astnode2(DMNSN_AST_PIGMENT, @$, pattern, $5);
+ $$ = $3;
}
;
+PIGMENT_BODY: PIGMENT_TYPE PIGMENT_MODIFIERS {
+ $$ = dmnsn_new_astnode2(DMNSN_AST_PIGMENT, @$, $1, $2);
+ }
+ | "checker" COLOR_LIST2 PIGMENT_MODIFIERS {
+ dmnsn_astnode checker = dmnsn_new_astnode(DMNSN_AST_CHECKER, @1);
+ dmnsn_astnode pattern = dmnsn_new_astnode1(DMNSN_AST_PATTERN, @1,
+ checker);
+ dmnsn_array_push($3.children, &$2);
+ $$ = dmnsn_new_astnode2(DMNSN_AST_PIGMENT, @$, pattern, $3);
+ }
+ | "checker" PIGMENT_LIST2 PIGMENT_MODIFIERS {
+ dmnsn_astnode checker = dmnsn_new_astnode(DMNSN_AST_CHECKER, @1);
+ dmnsn_astnode pattern = dmnsn_new_astnode1(DMNSN_AST_PATTERN, @1,
+ checker);
+ dmnsn_array_push($3.children, &$2);
+ $$ = dmnsn_new_astnode2(DMNSN_AST_PIGMENT, @$, pattern, $3);
+ }
+;
+
PIGMENT_TYPE: COLOR
| CONTINUOUS_PATTERN_TYPE
| "image_map" "{"
@@ -578,6 +585,10 @@ PIGMENT_MODIFIERS: /* empty */ {
$$ = $1;
dmnsn_array_push($$.children, &$2);
}
+ | PIGMENT_MODIFIERS PIGMENT_MAP {
+ $$ = $1;
+ dmnsn_array_push($$.children, &$2);
+ }
| PIGMENT_MODIFIERS "quick_color" COLOR {
dmnsn_astnode quick_color
= dmnsn_new_astnode1(DMNSN_AST_QUICK_COLOR, @2, $3);
@@ -619,6 +630,40 @@ COLOR_MAP_ENTRY: "[" FLOAT "color" COLOR_BODY "]" {
}
;
+PIGMENT_LIST2: PIGMENT {
+ $$ = dmnsn_new_astnode1(DMNSN_AST_PIGMENT_LIST, @$, $1);
+ }
+ | PIGMENT PIGMENT {
+ $$ = dmnsn_new_astnode2(DMNSN_AST_PIGMENT_LIST, @$, $1, $2);
+ }
+ | PIGMENT "," PIGMENT {
+ $$ = dmnsn_new_astnode2(DMNSN_AST_PIGMENT_LIST, @$, $1, $3);
+ }
+;
+
+PIGMENT_MAP: "pigment_map" "{"
+ PIGMENT_MAP_ENTRIES
+ "}"
+ {
+ $$ = $3;
+ }
+;
+
+PIGMENT_MAP_ENTRIES: PIGMENT_MAP_ENTRY {
+ $$ = dmnsn_new_astnode1(DMNSN_AST_PIGMENT_MAP, @$, $1);
+ }
+ | PIGMENT_MAP_ENTRIES PIGMENT_MAP_ENTRY {
+ $$ = $1;
+ dmnsn_array_push($$.children, &$2);
+ }
+;
+
+PIGMENT_MAP_ENTRY: "[" FLOAT PIGMENT_BODY "]" {
+ $$ = dmnsn_new_astnode2(DMNSN_AST_PIGMENT_MAP_ENTRY, @$,
+ $2, $3);
+ }
+;
+
/* Finishes */
FINISH: "finish" "{"
FINISH_ITEMS