annotate extensions/rt_default/rtd_conf.y @ 974:2091bf698fb1

Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR (as far as sed could find them) with manual fixing afterwards.
author Thomas Klausner <tk@giga.or.at>
date Thu, 14 Mar 2013 18:14:35 +0100
parents d59decafe9c0
children 1af09cc156d6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
167
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1 /*********************************************************************************************************
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
2 * Software License Agreement (BSD License) *
740
4a9f08d6b6ba Updated my mail address
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 258
diff changeset
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> *
167
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
4 * *
741
d59decafe9c0 Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
5 * Copyright (c) 2011, WIDE Project and NICT *
167
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
6 * All rights reserved. *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
7 * *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
8 * Redistribution and use of this software in source and binary forms, with or without modification, are *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
9 * permitted provided that the following conditions are met: *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
10 * *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
11 * * Redistributions of source code must retain the above *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
12 * copyright notice, this list of conditions and the *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
13 * following disclaimer. *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
14 * *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
15 * * Redistributions in binary form must reproduce the above *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
16 * copyright notice, this list of conditions and the *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
17 * following disclaimer in the documentation and/or other *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
18 * materials provided with the distribution. *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
19 * *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
20 * * Neither the name of the WIDE Project or NICT nor the *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
21 * names of its contributors may be used to endorse or *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
22 * promote products derived from this software without *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
23 * specific prior written permission of WIDE Project and *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
24 * NICT. *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
25 * *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
34 *********************************************************************************************************/
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
35
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
36 /* Yacc extension's configuration parser.
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
37 * See doc/rt_default.conf.sample for configuration file format
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
38 */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
39
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
40 /* For development only : */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
41 %debug
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
42 %error-verbose
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
43
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
44 /* The parser receives the configuration file filename as parameter */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
45 %parse-param {char * conffile}
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
46
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
47 /* Keep track of location */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
48 %locations
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
49 %pure-parser
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
50
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
51 %{
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
52 #include "rt_default.h"
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
53 #include "rtd_conf.tab.h" /* bison is not smart enough to define the YYLTYPE before including this code, so... */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
54
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
55 /* Forward declaration */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
56 int yyparse(char * conffile);
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
57
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
58 static int rules_added = 0;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
59
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
60 /* Parse the configuration file */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
61 int rtd_conf_handle(char * conffile)
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
62 {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
63 extern FILE * rtd_confin;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
64 int ret;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
65
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
66 TRACE_ENTRY("%p", conffile);
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
67
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
68 TRACE_DEBUG (FULL, "Parsing configuration file: %s...", conffile);
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
69
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
70 rtd_confin = fopen(conffile, "r");
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
71 if (rtd_confin == NULL) {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
72 ret = errno;
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 741
diff changeset
73 fd_log_debug("Unable to open extension configuration file %s for reading: %s", conffile, strerror(ret));
167
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
74 TRACE_DEBUG (INFO, "Error occurred, message logged -- configuration file.");
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
75 return ret;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
76 }
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
77
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
78 ret = yyparse(conffile);
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
79
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
80 fclose(rtd_confin);
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
81
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
82 if (ret != 0) {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
83 TRACE_DEBUG (INFO, "Unable to parse the configuration file.");
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
84 return EINVAL;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
85 } else {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
86 TRACE_DEBUG(FULL, "Added %d RULES routing entries successfully.", rules_added);
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
87 }
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
88
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
89 return 0;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
90 }
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
91
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
92 /* The Lex parser prototype */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
93 int rtd_conflex(YYSTYPE *lvalp, YYLTYPE *llocp);
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
94
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
95 /* Function to report the errors */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
96 void yyerror (YYLTYPE *ploc, char * conffile, char const *s)
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
97 {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
98 TRACE_DEBUG(INFO, "Error in configuration parsing");
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
99
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
100 if (ploc->first_line != ploc->last_line)
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 741
diff changeset
101 fd_log_debug("%s:%d.%d-%d.%d : %s", conffile, ploc->first_line, ploc->first_column, ploc->last_line, ploc->last_column, s);
167
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
102 else if (ploc->first_column != ploc->last_column)
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 741
diff changeset
103 fd_log_debug("%s:%d.%d-%d : %s", conffile, ploc->first_line, ploc->first_column, ploc->last_column, s);
167
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
104 else
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 741
diff changeset
105 fd_log_debug("%s:%d.%d : %s", conffile, ploc->first_line, ploc->first_column, s);
167
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
106 }
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
107
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
108 %}
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
109
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
110 /* Values returned by lex for token */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
111 %union {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
112 int integer; /* Store integer values */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
113 char *string; /* The string is allocated by strdup in lex.*/
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
114 struct {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
115 char * str;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
116 int regex;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
117 } tstring; /* typed string */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
118 struct {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
119 char * str;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
120 int regex;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
121 enum rtd_crit_type type;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
122 } criteria;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
123 struct {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
124 char * str;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
125 int regex;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
126 enum rtd_targ_type type;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
127 } target;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
128 }
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
129
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
130 /* In case of error in the lexical analysis */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
131 %token LEX_ERROR
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
132
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
133 /* A (de)quoted string (malloc'd in lex parser; it must be freed after use) */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
134 %token <string> QSTRING
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
135 /* A (de)bracket-quoted string (malloc'd in lex parser; it must be freed after use): ["blahblah"] */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
136 %token <string> BQSTRING
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
137
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
138 /* An integer value */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
139 %token <integer> INTEGER
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
140
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
141 /* The types for this gramar */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
142 %type <tstring> TSTRING
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
143 %type <criteria> CRITERIA
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
144 %type <target> TARGET
169
f8507f57a3c0 Allow '+' and '-' operators in conf file
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 168
diff changeset
145 %type <integer> EXPR_INT
167
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
146
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
147 /* Tokens */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
148 %token OH
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
149 %token OR
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
150 %token DH
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
151 %token DR
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
152 %token UN
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
153 %token SI
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
154
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
155 %token REALM
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
156
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
157
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
158
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
159 /* -------------------------------------- */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
160 %%
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
161
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
162 /* The grammar definition */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
163 conffile: /* empty grammar is OK */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
164 | conffile rule
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
165 ;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
166
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
167 /* a RULE entry */
169
f8507f57a3c0 Allow '+' and '-' operators in conf file
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 168
diff changeset
168 rule: CRITERIA ':' TARGET '+' '=' EXPR_INT ';'
167
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
169 {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
170 int flag = 0;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
171 if ($1.regex)
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
172 flag |= RTD_CRIT_REG;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
173 if ($3.regex)
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
174 flag |= RTD_TARG_REG;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
175
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
176 /* Add this rule to the repository */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
177 CHECK_FCT_DO( rtd_add($1.type, $1.str, $3.type, $3.str, $6, flag),
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
178 {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
179 yyerror (&yylloc, conffile, "An error occurred while adding a rule, aborting...");
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
180 YYERROR;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
181 } );
168
6db078b955e3 Completed rt_default extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 167
diff changeset
182
6db078b955e3 Completed rt_default extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 167
diff changeset
183 rules_added++;
167
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
184 }
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
185 ;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
186
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
187 /* QSTRING and BQSTRING are equivalent in the grammar */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
188 TSTRING: QSTRING
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
189 {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
190 $$.str = $1;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
191 $$.regex = 0;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
192 }
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
193 | BQSTRING
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
194 {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
195 $$.str = $1;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
196 $$.regex = 1;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
197 }
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
198 ;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
199
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
200 /* Details of the CRITERIA type */
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
201 CRITERIA: '*'
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
202 {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
203 $$.str = NULL;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
204 $$.regex = 0;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
205 $$.type = RTD_CRI_ALL;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
206 }
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
207 | OH '=' TSTRING
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
208 {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
209 $$.str = $3.str;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
210 $$.regex =$3.regex;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
211 $$.type = RTD_CRI_OH;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
212 }
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
213 | OR '=' TSTRING
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
214 {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
215 $$.str = $3.str;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
216 $$.regex =$3.regex;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
217 $$.type = RTD_CRI_OR;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
218 }
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
219 | DH '=' TSTRING
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
220 {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
221 $$.str = $3.str;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
222 $$.regex =$3.regex;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
223 $$.type = RTD_CRI_DH;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
224 }
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
225 | DR '=' TSTRING
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
226 {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
227 $$.str = $3.str;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
228 $$.regex =$3.regex;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
229 $$.type = RTD_CRI_DR;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
230 }
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
231 | UN '=' TSTRING
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
232 {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
233 $$.str = $3.str;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
234 $$.regex =$3.regex;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
235 $$.type = RTD_CRI_UN;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
236 }
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
237 | SI '=' TSTRING
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
238 {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
239 $$.str = $3.str;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
240 $$.regex =$3.regex;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
241 $$.type = RTD_CRI_SI;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
242 }
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
243 ;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
244
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
245 /* Details of the TARGET type */
168
6db078b955e3 Completed rt_default extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 167
diff changeset
246 TARGET: TSTRING
167
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
247 {
168
6db078b955e3 Completed rt_default extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 167
diff changeset
248 $$.str = $1.str;
6db078b955e3 Completed rt_default extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 167
diff changeset
249 $$.regex =$1.regex;
167
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
250 $$.type = RTD_TAR_ID;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
251 }
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
252 | REALM '=' TSTRING
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
253 {
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
254 $$.str = $3.str;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
255 $$.regex =$3.regex;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
256 $$.type = RTD_TAR_REALM;
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
257 }
967e579beb64 Backup work in progress on rt_default
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
258 ;
169
f8507f57a3c0 Allow '+' and '-' operators in conf file
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 168
diff changeset
259
f8507f57a3c0 Allow '+' and '-' operators in conf file
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 168
diff changeset
260 /* An expression that has an integer value; we allow + and - operators cause it is convenient */
f8507f57a3c0 Allow '+' and '-' operators in conf file
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 168
diff changeset
261 EXPR_INT: INTEGER
f8507f57a3c0 Allow '+' and '-' operators in conf file
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 168
diff changeset
262 {
f8507f57a3c0 Allow '+' and '-' operators in conf file
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 168
diff changeset
263 $$ = $1;
f8507f57a3c0 Allow '+' and '-' operators in conf file
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 168
diff changeset
264 }
f8507f57a3c0 Allow '+' and '-' operators in conf file
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 168
diff changeset
265 | EXPR_INT '+' INTEGER
f8507f57a3c0 Allow '+' and '-' operators in conf file
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 168
diff changeset
266 {
f8507f57a3c0 Allow '+' and '-' operators in conf file
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 168
diff changeset
267 $$ = $1 + $3;
f8507f57a3c0 Allow '+' and '-' operators in conf file
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 168
diff changeset
268 }
f8507f57a3c0 Allow '+' and '-' operators in conf file
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 168
diff changeset
269 | EXPR_INT '-' INTEGER
f8507f57a3c0 Allow '+' and '-' operators in conf file
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 168
diff changeset
270 {
f8507f57a3c0 Allow '+' and '-' operators in conf file
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 168
diff changeset
271 $$ = $1 - $3;
f8507f57a3c0 Allow '+' and '-' operators in conf file
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 168
diff changeset
272 }
f8507f57a3c0 Allow '+' and '-' operators in conf file
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 168
diff changeset
273 ;
"Welcome to our mercurial repository"