src/globals.h \
src/parse/extop.h \
src/parse/input.h \
+ src/parse/loc.h \
src/parse/parser.h \
src/parse/scanner.h \
src/parse/token.h \
{
if (DFlag)
{
- o << s->label << " [label=\"" << rule->code->source << ":" << rule->code->line << "\"]\n";
+ o << s->label << " [label=\"" << rule->code->loc.filename << ":" << rule->code->loc.line << "\"]\n";
return;
}
o << indent(ind) << yySetupRule << "\n";
}
- o.write_line_info (rule->code->line, rule->code->source.c_str ());
+ o.write_line_info (rule->code->loc.line, rule->code->loc.filename.c_str ());
o << indent(ind);
if (flag_skeleton)
{
// warn about not shadowed rule that matches empty string
if (empty_rule && !stray_cunits.empty ())
{
- warn.match_empty_string (head->rule->code->line);
+ warn.match_empty_string (head->rule->code->loc.line);
}
// split ``base'' states into two parts
--- /dev/null
+#ifndef _RE2C_PARSE_LOC_
+#define _RE2C_PARSE_LOC_
+
+#include <string>
+
+#include "src/util/c99_stdint.h"
+
+namespace re2c
+{
+
+struct Loc
+{
+ std::string filename;
+ uint32_t line;
+
+ inline Loc (const std::string & f, uint32_t l)
+ : filename (f)
+ , line (l)
+ {}
+};
+
+} // namespace re2c
+
+#endif // _RE2C_PARSE_LOC_
{
if (ruleSetupMap.find(*it) != ruleSetupMap.end())
{
- in->fatalf_at(code->line, "code to setup rule '%s' is already defined", it->c_str());
+ in->fatalf_at(code->loc.line, "code to setup rule '%s' is already defined", it->c_str());
}
- ruleSetupMap[*it] = std::make_pair(code->line, code->text);
+ ruleSetupMap[*it] = std::make_pair(code->loc.line, code->text);
}
delete clist;
delete code;
{
if (ruleDefaultMap.find(*it) != ruleDefaultMap.end())
{
- in->fatalf_at(code->line, "code to default rule '%s' is already defined", it->c_str());
+ in->fatalf_at(code->loc.line, "code to default rule '%s' is already defined", it->c_str());
}
ruleDefaultMap[*it] = code;
}
| '<' STAR '>' expr look newcond CODE
{
context_check(NULL);
- Token *token = new Token($7, $7->source, $7->line);
+ Token *token = new Token($7, $7->loc.filename, $7->loc.line);
delete $7;
specStar.push_back(new RuleOp($4, $5, token, rank_counter.next (), RegExp::PRIVATE, $6));
delete $6;
{
in->fatal("code to handle illegal condition already defined");
}
- Token *token = new Token($3, $3->source, $3->line);
+ Token *token = new Token($3, $3->loc.filename, $3->loc.line);
delete $3;
$$ = specNone = new RuleOp(new NullOp(), new NullOp(), token, rank_counter.next (), RegExp::SHARED, $2);
delete $2;
#ifndef _RE2C_PARSE_TOKEN_
#define _RE2C_PARSE_TOKEN_
+#include "src/parse/loc.h"
#include "src/util/c99_stdint.h"
#include "src/util/forbid_copy.h"
class Token
{
public:
+ const Loc loc;
const std::string text;
- const std::string source;
- uint32_t line;
const bool autogen;
- Token (const char *, uint32_t, const std::string &, uint32_t);
- Token (const Token *, const std::string &, uint32_t);
+ inline Token (const char * t, uint32_t t_len, const std::string & s, uint32_t l)
+ : loc (s, l)
+ , text (t, t_len)
+ , autogen (false)
+ {}
+ inline Token (const Token * t, const std::string & s, uint32_t l)
+ : loc (t ? t->loc : Loc (s, l))
+ , text (t ? t->text : "")
+ , autogen (t == NULL)
+ {}
FORBID_COPY (Token);
};
-inline Token::Token (const char * t, uint32_t t_len, const std::string & s, uint32_t l)
- : text (t, t_len)
- , source (s)
- , line (l)
- , autogen (false)
-{}
-
-inline Token::Token (const Token * t, const std::string & s, uint32_t l)
- : text (t ? t->text : "")
- , source (t ? t->source : s)
- , line (t ? t->line : l)
- , autogen (t == NULL)
-{}
-
-inline Token::Token (const Token & t)
- : text (t.text)
- , source (t.source)
- , line (t.line)
- , autogen (t.autogen)
-{}
-
} // namespace re2c
#endif // _RE2C_PARSE_TOKEN_