1
/***************************************************************************
2
* Copyright (c) 2010 Jürgen Riegel <juergen.riegel@web.de> *
4
* This library is free software; you can redistribute it and/or *
5
* modify it under the terms of the GNU Library General Public *
6
* License as published by the Free Software Foundation; either *
7
* version 2 of the License, or (at your option) any later version. *
9
* This library is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU Library General Public License for more details. *
14
* You should have received a copy of the GNU Library General Public *
15
* License along with this library; see the file COPYING.LIB. If not, *
16
* write to the Free Software Foundation, Inc., 59 Temple Place, *
17
* Suite 330, Boston, MA 02111-1307, USA *
19
***************************************************************************/
21
/* Parser for the FreeCAD selection filter language */
23
/* bison -o SelectionFilter.tab.c SelectionFilter.y */
26
/* Represents the many different ways we can access our data */
36
/* Define our terminal symbols (tokens). This should
37
match our tokens.l lex file. We also define the node type
40
%token <string> TIDENTIFIER
41
%token <token> TSUB TSELECT TCOUNT TSLICE TNAMESPACE
42
%token <number> TNUMBER
44
/* Define the type of node our nonterminal symbols represent.
45
The types refer to the %union declaration above.
48
%type <object> matchline
49
%type <string> type subname
50
%type <block> matchlines block
58
type : TSELECT TIDENTIFIER { $$ = $2; }
59
| TSELECT TIDENTIFIER TNAMESPACE TIDENTIFIER { $$ = StringFactory::New(*$2 + "::" + *$4); }
62
| TSUB TIDENTIFIER { $$ = $2; }
65
| TCOUNT TNUMBER TSLICE TNUMBER { $$ = new Node_Slice($2,$4); }
66
| TCOUNT TNUMBER TSLICE { $$ = new Node_Slice($2); }
67
| TCOUNT TNUMBER { $$ = new Node_Slice($2,$2); }
69
matchline : type subname count { $$ = new Node_Object($1,$2,$3); }
71
matchlines : matchline { $$ = new Node_Block($1); }
72
| matchlines matchline { $$ = $1 ; $$->Objects.emplace_back($2); }
74
block : matchlines { $$ = $1; }
76
filter: block { TopBlock = $1; }