1 /****************************************************************************
4 * This header file is included by all all language parsing C modules in
7 * from Persistence of Vision(tm) Ray Tracer
8 * Copyright 1996,1999 Persistence of Vision Team
9 *---------------------------------------------------------------------------
10 * NOTICE: This source code file is provided so that users may experiment
11 * with enhancements to POV-Ray and to port the software to platforms other
12 * than those supported by the POV-Ray Team. There are strict rules under
13 * which you are permitted to use this file. The rules are in the file
14 * named POVLEGAL.DOC which should be distributed with this file.
15 * If POVLEGAL.DOC is not available or for more info please contact the POV-Ray
16 * Team Coordinator by email to team-coord@povray.org or visit us on the web at
17 * http://www.povray.org. The latest version of POV-Ray may be found at this site.
19 * This program is based on the popular DKB raytracer version 2.12.
20 * DKBTrace was originally written by David K. Buck.
21 * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
23 *****************************************************************************/
29 /*****************************************************************************
30 * Global preprocessor defines
31 ******************************************************************************/
33 #define MAX_STRING_INDEX 127
35 /* Here we create our own little language for doing the parsing. It
36 makes the code easier to read. */
38 #define EXPECT { int Exit_Flag; Exit_Flag = FALSE; \
39 while (!Exit_Flag) {Get_Token(); switch (Token.Token_Id) {
40 #define CASE(x) case x:
41 #define CASE2(x, y) case x: case y:
42 #define CASE3(x, y, z) case x: case y: case z:
43 #define CASE4(w, x, y, z) case w: case x: case y: case z:
44 #define CASE5(v, w, x, y, z) case v: case w: case x: case y: case z:
45 #define CASE6(u, v, w, x, y, z) case u: case v: case w: case x: case y: case z:
46 #define END_CASE break;
47 #define EXIT Exit_Flag = TRUE;
48 #define OTHERWISE default:
49 #define END_EXPECT } } }
50 #define GET(x) Get_Token(); if (Token.Token_Id != x) Parse_Error (x);
51 #define ALLOW(x) Get_Token(); if (Token.Token_Id != x) Unget_Token();
52 #define UNGET Unget_Token();
53 #define CASE_FLOAT CASE2 (LEFT_PAREN_TOKEN, FLOAT_FUNCT_TOKEN)\
54 CASE2 (PLUS_TOKEN, DASH_TOKEN) UNGET
55 #define CASE_VECTOR CASE2 (VECTOR_FUNCT_TOKEN,LEFT_ANGLE_TOKEN) \
56 CASE4 (U_TOKEN,V_TOKEN,UV_ID_TOKEN,VECTOR_4D_ID_TOKEN) CASE_FLOAT
57 #define CASE_EXPRESS CASE_VECTOR
59 #define CASE_COLOUR CASE3 (COLOUR_TOKEN,COLOUR_KEY_TOKEN,COLOUR_ID_TOKEN) UNGET
61 #define MAX_BRACES 200
63 /* Token Definitions for Parser */
109 DIMENSION_SIZE_TOKEN
,
113 /*WARNING: All new functions returning a float value must be placed
114 before FLOAT_FUNCT_TOKEN or the parser won't work right. */
126 /*WARNING: All new functions returning a vector value must be placed
127 before VECTOR_FUNCT_TOKEN or the parser won't work right. */
141 /*WARNING: All new keywords which may preceed a COLOUR must be placed
142 before COLOUR_KEY_TOKEN or the parser won't work right. */
148 /*Note:Not 100% sure about the above tokens. May move them up later. */
235 MAX_TRACE_LEVEL_TOKEN
,
281 SMOOTH_TRIANGLE_TOKEN
,
287 STRING_LITERAL_TOKEN
,
323 IRID_WAVELENGTH_TOKEN
,
327 NUMBER_OF_WAVES_TOKEN
,
350 ULTRA_WIDE_ANGLE_TOKEN
,
355 QUADRATIC_SPLINE_TOKEN
,
375 PIGMENT_MAP_ID_TOKEN
,
378 TEXTURE_MAP_ID_TOKEN
,
379 SUPERELLIPSOID_TOKEN
,
428 DISTANCE_MAXIMUM_TOKEN
,
430 GRAY_THRESHOLD_TOKEN
,
431 LOW_ERROR_FACTOR_TOKEN
,
434 RECURSION_LIMIT_TOKEN
,
436 GLOBAL_SETTINGS_TOKEN
,
439 MEDIA_ATTENUATION_TOKEN
,
440 MEDIA_INTERACTION_TOKEN
,
498 DENSITY_MAP_ID_TOKEN
,
499 REFLECTION_EXPONENT_TOKEN
,
510 /*****************************************************************************
512 ******************************************************************************/
515 /*****************************************************************************
517 ******************************************************************************/
519 extern short Not_In_Default
;
520 extern short Ok_To_Declare
;
521 extern short LValue_Ok
;
524 /*****************************************************************************
526 ******************************************************************************/
528 void Parse_Error (TOKEN Token_Id
);
529 void Parse_Error_Str (char *str
);
530 void Parse_Begin (void);
531 void Parse_End (void);
532 void Parse_Comma (void);
533 void Parse_Semi_Colon (void);
534 void Destroy_Frame (void);
536 void MAError (char *str
, size_t size
);
537 void Warn_State (TOKEN Token_Id
, TOKEN Type
);
538 void Warn (DBL Level
, char *str
);
539 void Only_In (char *s1
,char *s2
);
540 void Not_With (char *s1
,char *s2
);
541 void Warn_Compat (int f
);
542 void Link_Textures (TEXTURE
**Old_Texture
, TEXTURE
*New_Texture
);
544 void Parse_Object_Mods (OBJECT
*Object
);
545 OBJECT
*Parse_Object (void);
546 void Parse_Default (void);
547 void Parse_Declare (void);
548 void Parse_Matrix (MATRIX Matrix
);
549 void Destroy_Ident_Data (void *Data
, int Type
);
550 int Parse_RValue (int Previous
, int *NumberPtr
, void **DataPtr
, int ParFlag
, int SemiFlag
);
551 char *Get_Token_String (TOKEN Token_Id
);
552 void Test_Redefine(TOKEN Previous
, TOKEN
*NumberPtr
, void *Data
);