FreeWRL/FreeX3D  3.0.0
CParse.h
1 /*
2 
3 
4 VRML-parsing routines in C.
5 
6 */
7 
8 /****************************************************************************
9  This file is part of the FreeWRL/FreeX3D Distribution.
10 
11  Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
12 
13  FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
14  it under the terms of the GNU Lesser Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  FreeWRL/FreeX3D is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  GNU General Public License for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
25 ****************************************************************************/
26 
27 
28 #ifndef __FREEWRL_CPARSE_H__
29 #define __FREEWRL_CPARSE_H__
30 
31 
32 /* for scanning and determining whether a character is part of a valid X3D name
33 http://www.web3d.org/documents/specifications/19776-2/V3.2/Part02/grammar.html#Nodes
34 http://www.web3d.org/documents/specifications/14772/V2.0/part1/grammar.html //older allows ':' in DEF/USE ids
35 See IdFirstChar IdRestChar
36 Rest char forbids:
37 0x3a : COLON // just the newer V3.2 disallows, the older 2.0 permits. We will permit
38 0x0-0x20 NUL - SPACE
39 0x22,0x23 " #
40 0x27 '
41 0x2c,0x2e ,.
42 0x5b,0x5c,0x5d [\]
43 0x7b,0x7d,0x7f {} DEL
44 
45 FirstChar = RestChar minus:
46 0X30-0X39 - digits
47 0x2b,0x2d +-
48 Sept 2015 - we now allow 0x3a colon : in First and Rest - && c!=0x3a
49 Feb 2016 - however, allowing : broke COMPONENT Core:2 splitting -Core:2 comes out as one chunk now- changed that code
50 */
51 #define IS_ID_REST(c) \
52  (c>0x20 && c!=0x22 && c!=0x23 && c!=0x27 && c!=0x2C && c!=0x2E && c!=0x5B && \
53  c!=0x5C && c!=0x5D && c!=0x7B && c!=0x7D && c!=0x7F )
54 #define IS_ID_FIRST(c) \
55  (IS_ID_REST(c) && (c<0x30 || c>0x39) && c!=0x2B && c!=0x2D )
56 
57 BOOL cParse(void *ectx, void* ptr, unsigned offset, const char* cdata);
58 
59 /* Destroy all data associated with the currently parsed world kept. */
60 #define destroyCParserData(me) \
61  parser_destroyData(me)
62 
63 /* Some accessor-methods */
64 struct X3D_Node* parser_getNodeFromName(const char*);
65 char* parser_getNameFromNode(struct X3D_Node*);
66 char* parser_getPROTONameFromNode(struct X3D_Node*);
67 //extern struct VRMLParser* globalParser;
68 
69 /* tie assert in here to give better failure methodology */
70 /* #define ASSERT(cond) if(!(cond)){fw_assert(__FILE__,__LINE__);} */
71 /* void fw_assert(char *,int); */
72 
73 
74 #endif /* __FREEWRL_CPARSE_H__ */