FreeCAD

Форк
0
/
SelectionFilter.y 
80 строк · 3.1 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2010 Jürgen Riegel <juergen.riegel@web.de>              *
3
 *                                                                         *
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.      *
8
 *                                                                         *
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.                  *
13
 *                                                                         *
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                                *
18
 *                                                                         *
19
 ***************************************************************************/
20

21
/* Parser for the FreeCAD selection filter language */
22

23
/*  bison -o SelectionFilter.tab.c  SelectionFilter.y  */
24

25

26
/* Represents the many different ways we can access our data */
27
%union {
28
    std::string *string;
29
    Node_Object *object;
30
    Node_Slice  *slice;
31
    Node_Block  *block;
32
    int          token;
33
    int          number;
34
}
35

36
/* Define our terminal symbols (tokens). This should
37
   match our tokens.l lex file. We also define the node type
38
   they represent.
39
 */
40
%token <string> TIDENTIFIER
41
%token <token> TSUB TSELECT TCOUNT TSLICE TNAMESPACE
42
%token <number> TNUMBER
43

44
/* Define the type of node our nonterminal symbols represent.
45
   The types refer to the %union declaration above.
46
 */
47
%type <slice> count
48
%type <object> matchline
49
%type <string> type subname
50
%type <block>  matchlines block
51

52
%start filter
53

54
%%
55

56

57

58
type  : TSELECT TIDENTIFIER							{ $$ = $2; }
59
       | TSELECT TIDENTIFIER TNAMESPACE TIDENTIFIER { $$ = StringFactory::New(*$2 + "::" + *$4); }
60

61
subname :								 { $$ = 0;  }
62
         | TSUB TIDENTIFIER				 { $$ = $2; }
63

64
count :									 { $$ = 0;                     }
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); }
68

69
matchline  : type subname count                { $$ = new Node_Object($1,$2,$3); }
70

71
matchlines : matchline            { $$ = new Node_Block($1);  }
72
           | matchlines matchline { $$ = $1 ; $$->Objects.emplace_back($2); }
73

74
block : matchlines                { $$ = $1; }
75

76
filter:   block					  { TopBlock = $1; }
77
;
78

79

80
%%
81

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.