summaryrefslogtreecommitdiffstats
path: root/dimension/grammar.rules
blob: 0963a1e566f8452cd7ac3b0fd6891457b36f4d6a (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
#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: "assumed_gamma" FLOAT {
                      dmnsn_diagnostic(@1,
                                       "WARNING: assumed_gamma not supported");
                      $$ = dmnsn_new_astnode1(DMNSN_AST_ASSUMED_GAMMA, @$, $2);
                    }
                    | "max_trace_level" INT {
                      $$ = dmnsn_new_astnode1(DMNSN_AST_MAX_TRACE_LEVEL,
                                              @$, $2);
                    }
;

/* Atmospheric effects */

ATMOSPHERIC_EFFECT: BACKGROUND
;

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