6#include <click/glue.hh>
7#include <click/variableenv.hh>
32 Lexeme(
int k,
const String &s,
bool compact =
false)
33 : _kind(k), _s(compact ? s.compact() : s) {
36 int kind()
const {
return _kind; }
37 bool is(
int k)
const {
return _kind == k; }
39 const String &string()
const {
return _s; }
40 String &string() {
return _s; }
51 enum { TUNNEL_TYPE = 0, ERROR_TYPE = 1 };
55 typedef Router::Port Port;
56 typedef Router::Connection Connection;
61 static Lexer* get_lexer();
62 static bool lexer_initialized();
63 static void static_cleanup();
68 VariableEnvironment &global_scope() {
return _global_scope; }
71 String remaining_text()
const;
72 void set_remaining_text(
const String &);
75 return _unlex_pos ? _unlex[--_unlex_pos] : next_lexeme();
77 void unlex(
const Lexeme &t) {
78 assert(_unlex_pos < UNLEX_SIZE);
79 _unlex[_unlex_pos++] = t;
83 return _file.lex_config(
this);
86 bool expect(
int,
bool no_error =
false);
88 typedef Element *(*ElementFactory)(uintptr_t);
89#ifdef CLICK_LINUXMODULE
90 int add_element_type(
const String &, ElementFactory factory, uintptr_t thunk,
struct module *module,
bool scoped =
false);
92 int add_element_type(
const String &, ElementFactory factory, uintptr_t thunk,
bool scoped =
false);
94 void add_element_mtsafe(
const String &);
96 int element_type(
const String &name)
const {
97 return _element_type_map[name];
99 int force_element_type(
String name,
bool report_error =
true);
103 int remove_element_type(
int t) {
return remove_element_type(t, 0); }
105 bool is_mt_safe(
String element)
const;
107 String element_name(
int)
const;
108 String element_landmark(
int)
const;
110 void add_tunnels(
String name,
int *eidexes);
112 bool ydone()
const {
return !_ps; }
115 Router *create_router(Master *);
128 String _original_filename;
132 const char *skip_line(
const char *s);
133 const char *skip_slash_star(
const char *s);
134 const char *skip_backslash_angle(
const char *s);
135 const char *skip_quote(
const char *s,
char end_c);
136 const char *process_line_directive(
const char *s, Lexer *lexer);
137 Lexeme next_lexeme(Lexer *lexer);
138 String lex_config(Lexer *lexer);
147 bool _compact_config;
150 Lexeme next_lexeme() {
151 return _file.next_lexeme(
this);
153 static String lexeme_string(
int);
156 enum { UNLEX_SIZE = 2 };
162 ElementFactory factory;
164#ifdef CLICK_LINUXMODULE
165 struct module *
module;
170 inline Compound* compound()
const {
171 if (factory == compound_element_factory)
172 return reinterpret_cast<Compound*
>(thunk);
180 enum { ET_SCOPED = 0x80000000, ET_TMASK = 0x7FFFFFFF, ET_NULL = 0x7FFFFFFF };
181 int _last_element_type;
182 int _free_element_type;
183 VariableEnvironment _global_scope;
193 int _anonymous_offset;
203 static Lexer* _lexer;
205 int lerror(
const char *, ...);
206 int lerror_syntax(
const Lexeme &t);
209 int get_element(
String name,
int etype,
211 const String &filename =
String(),
unsigned lineno = 0);
212 int lexical_scoping_in()
const;
213 void lexical_scoping_out(
int);
214 int remove_element_type(
int,
int *);
215 int make_compound_element(
int);
216 void expand_compound_element(
int, VariableEnvironment &);
217 void add_router_connections(
int,
const Vector<int> &);
218 static Element* compound_element_factory(uintptr_t);
220 void yport(
bool isoutput);
221 void yelement_name();
222 void yelement_type(
int type,
bool this_ident,
bool this_implicit);
223 void yelement_config(ElementState *e,
bool this_implicit);
224 void yelement_next();
226 void yconnection_connector();
227 void yconnection_check_useless(
const Vector<int> &x,
bool isoutput);
228 static void yconnection_analyze_ports(
const Vector<int> &x,
bool isoutput,
229 int &min_ports,
int &expandable);
232 void ycompound_arguments(Compound *ct);
234 void ycompound_next();
235 void ycompound_end(
const Lexeme &t);
239 void yelementclass();
241 void yrequire_library(
const String &value);
246 TunnelEnd *find_tunnel(
const Port &p,
bool isoutput,
bool insert);
247 void expand_connection(
const Port &p,
bool isoutput,
Vector<Port> &);
249 friend class Compound;
250 friend class TunnelEnd;
251 friend struct FileState;
255class LexerExtra {
public:
258 virtual ~LexerExtra() { }
Base class for Click elements.
Definition element.hh:42
Error reporting class.
Definition error.hh:90
Hash table template.
Definition hashtable.hh:570
A router configuration.
Definition router.hh:28
A string of characters.
Definition string.hh:22
Vector template.
Definition vector.hh:111
Click's hash table container template.
The Router class implementing a router configuration.