summaryrefslogtreecommitdiffstats
path: root/dimension/grammar.rules
blob: 0e9d6f1b9d614fd97fd66de7832364f7101dafdb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#line 2 "grammar.rules"

/*************************************************************************
 * Copyright (C) 2010 Tavian Barnes <tavianator@gmail.com>               *
 *                                                                       *
 * This file is part of Dimension.                                       *
 *                                                                       *
 * Dimension is free software; you can redistribute it and/or modify it  *
 * under the terms of the GNU General Public License as published by the *
 * Free Software Foundation; either version 3 of the License, or (at     *
 * your option) any later version.                                       *
 *                                                                       *
 * Dimension is distributed in the hope that it will be useful, but      *
 * WITHOUT ANY WARRANTY; without even the implied warranty of            *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 * General Public License for more details.                              *
 *                                                                       *
 * You should have received a copy of the GNU General Public License     *
 * along with this program.  If not, see <http://www.gnu.org/licenses/>. *
 *************************************************************************/

/*
 * Start symbol
 */

SCENE: /* empty */
     | SCENE SCENE_ITEM {
       dmnsn_array_push(astree, &$2);
     }
;

/* Top-level scene item */
SCENE_ITEM: GLOBAL_SETTINGS
          | ATMOSPHERIC_EFFECT
          | CAMERA
          | OBJECT
;

/* Global settings */

GLOBAL_SETTINGS: "global_settings" "{"
                   GLOBAL_SETTINGS_ITEMS
                 "}"
               {
                 $$ = $3;
               }
;

GLOBAL_SETTINGS_ITEMS: /* empty */ {
                       $$ = dmnsn_new_astnode(DMNSN_AST_GLOBAL_SETTINGS, @$);
                     }
                     | GLOBAL_SETTINGS_ITEMS GLOBAL_SETTINGS_ITEM {
                       $$ = $1;
                       dmnsn_array_push($$.children, &$2);
                     }
;

GLOBAL_SETTINGS_ITEM: "ambient_light" COLOR {
                      $$ = dmnsn_new_astnode1(DMNSN_AST_AMBIENT, @$, $2);
                    }
                    | "assumed_gamma" FLOAT {
                      dmnsn_diagnostic(@1,
                                       "WARNING: assumed_gamma not supported");
                      $$ = dmnsn_new_astnode1(DMNSN_AST_ASSUMED_GAMMA, @$, $2);
                    }
                    | "charset" GLOBAL_CHARSET {
                      dmnsn_diagnostic(@1,
                                       "WARNING: charset not supported");
                      $$ = dmnsn_new_astnode1(DMNSN_AST_CHARSET, @$, $2);
                    }
                    | "max_intersections" INT {
                      dmnsn_diagnostic(@1,
                                       "WARNING: max_intersections is"
                                       " unnecessary for Dimension");
                      $$ = dmnsn_new_astnode1(DMNSN_AST_MAX_INTERSECTIONS, @$,
                                              $2);
                    }
                    | "max_trace_level" INT {
                      $$ = dmnsn_new_astnode1(DMNSN_AST_MAX_TRACE_LEVEL, @$,
                                              $2);
                    }
;

GLOBAL_CHARSET: "ascii" {
                $$ = dmnsn_new_astnode(DMNSN_AST_ASCII, @$);
              }
              | "utf8" {
                $$ = dmnsn_new_astnode(DMNSN_AST_UTF8, @$);
              }
              | "sys" {
                $$ = dmnsn_new_astnode(DMNSN_AST_SYS, @$);
              }

/* Atmospheric effects */

ATMOSPHERIC_EFFECT: BACKGROUND
;

BACKGROUND: "background" "{" COLOR "}" {
            $$ = dmnsn_new_astnode1(DMNSN_AST_BACKGROUND, @$, $3);
          }
;