FreeWRL / FreeX3D 4.3.0
CParse.h
1/*
2
3
4VRML-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
33http://www.web3d.org/documents/specifications/19776-2/V3.2/Part02/grammar.html#Nodes
34http://www.web3d.org/documents/specifications/14772/V2.0/part1/grammar.html //older allows ':' in DEF/USE ids
35See IdFirstChar IdRestChar
36Rest char forbids:
370x3a : COLON // just the newer V3.2 disallows, the older 2.0 permits. We will permit
380x0-0x20 NUL - SPACE
390x22,0x23 " #
400x27 '
410x2c,0x2e ,.
420x5b,0x5c,0x5d [\]
430x7b,0x7d,0x7f {} DEL
44
45FirstChar = RestChar minus:
460X30-0X39 - digits
470x2b,0x2d +-
48Sept 2015 - we now allow 0x3a colon : in First and Rest - && c!=0x3a
49Feb 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
57BOOL 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 */
64struct X3D_Node* parser_getNodeFromName(const char*);
65char* parser_getNameFromNode(struct X3D_Node*);
66char* 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__ */