-/* Generated by re2c 0.14.3 on Tue Sep 22 12:44:15 2015 */
+/* Generated by re2c 0.14.3 on Wed Sep 23 14:13:43 2015 */
#line 1 "../src/conf/parse_opts.re"
#include <stdio.h>
end:
- if (!opts.apply ())
+ if (!opts.check ())
{
return EXIT_FAIL;
}
+ opts.sync ();
if (!opts.source_file)
{
void context_check(CondList *clist)
{
- if (!opts.cFlag)
+ if (!opts.cFlag ())
{
delete clist;
in->fatal("conditions are only allowed when using -c switch");
static const yytype_uint16 yyrline[] =
{
0, 242, 242, 244, 248, 252, 261, 270, 274, 278,
- 287, 292, 297, 302, 307, 312, 317, 325, 329, 335,
- 339, 343, 349, 353, 359, 372, 377, 385, 390, 394,
- 399, 403, 407, 411, 417, 421, 425, 429, 436, 453,
- 462, 466, 472, 477, 483, 487, 502, 519, 524, 530,
- 536, 554, 574, 580, 588, 591, 598, 604, 614, 617,
- 625, 628, 635, 639, 646, 650, 657, 661, 668, 672,
- 687, 707, 711, 715, 719, 726, 736, 740
+ 287, 292, 297, 302, 307, 312, 317, 325, 329, 334,
+ 338, 342, 347, 351, 356, 369, 374, 382, 387, 391,
+ 396, 400, 404, 408, 412, 416, 420, 424, 431, 448,
+ 457, 461, 467, 472, 478, 482, 497, 514, 519, 525,
+ 531, 549, 569, 575, 583, 586, 593, 599, 609, 612,
+ 620, 623, 630, 634, 641, 645, 652, 656, 663, 667,
+ 682, 702, 706, 710, 714, 721, 731, 735
};
#endif
case 9:
{
- if (!opts.mapCodeName.insert (std::make_pair (*(yyvsp[(1) - (3)].str), *(yyvsp[(2) - (3)].str))).second)
+ if (!opts.sync_mapCodeName (*(yyvsp[(1) - (3)].str), *(yyvsp[(2) - (3)].str)))
{
in->fatalf ("configuration '%s' is already set and cannot be changed", (yyvsp[(1) - (3)].str)->c_str ());
}
case 10:
{
- opts.condPrefix = *(yyvsp[(2) - (3)].str);
+ opts.sync_condPrefix (*(yyvsp[(2) - (3)].str));
delete (yyvsp[(2) - (3)].str);
;}
break;
case 11:
{
- opts.condEnumPrefix = *(yyvsp[(2) - (3)].str);
+ opts.sync_condEnumPrefix (*(yyvsp[(2) - (3)].str));
delete (yyvsp[(2) - (3)].str);
;}
break;
case 12:
{
- opts.condDivider = *(yyvsp[(2) - (3)].str);
+ opts.sync_condDivider (*(yyvsp[(2) - (3)].str));
delete (yyvsp[(2) - (3)].str);
;}
break;
case 13:
{
- opts.condDividerParam = *(yyvsp[(2) - (3)].str);
+ opts.sync_condDividerParam (*(yyvsp[(2) - (3)].str));
delete (yyvsp[(2) - (3)].str);
;}
break;
case 14:
{
- opts.condGoto = *(yyvsp[(2) - (3)].str);
+ opts.sync_condGoto (*(yyvsp[(2) - (3)].str));
delete (yyvsp[(2) - (3)].str);
;}
break;
case 15:
{
- opts.condGotoParam = *(yyvsp[(2) - (3)].str);
+ opts.sync_condGotoParam (*(yyvsp[(2) - (3)].str));
delete (yyvsp[(2) - (3)].str);
;}
break;
{
in->fatal ("configuration 'cgoto:threshold' must be nonnegative");
}
- opts.cGotoThreshold = static_cast<uint32_t> ((yyvsp[(2) - (3)].num));
+ opts.sync_cGotoThreshold (static_cast<uint32_t> ((yyvsp[(2) - (3)].num)));
;}
break;
case 17:
{
- opts.bUseYYFillNaked = (yyvsp[(2) - (3)].num) != 0;
+ opts.sync_bUseYYFillNaked ((yyvsp[(2) - (3)].num) != 0);
;}
break;
case 18:
{
- opts.yyFillLength = *(yyvsp[(2) - (3)].str);
- opts.bUseYYFillParam = false;
+ opts.sync_yyFillLength (*(yyvsp[(2) - (3)].str));
delete (yyvsp[(2) - (3)].str);
;}
break;
case 19:
{
- opts.bUseYYGetConditionNaked = (yyvsp[(2) - (3)].num) != 0;
+ opts.sync_bUseYYGetConditionNaked ((yyvsp[(2) - (3)].num) != 0);
;}
break;
case 20:
{
- opts.bUseYYGetStateNaked = (yyvsp[(2) - (3)].num) != 0;
+ opts.sync_bUseYYGetStateNaked ((yyvsp[(2) - (3)].num) != 0);
;}
break;
case 21:
{
- opts.yySetConditionParam = *(yyvsp[(2) - (3)].str);
- opts.bUseYYSetConditionParam = false;
+ opts.sync_yySetConditionParam (*(yyvsp[(2) - (3)].str));
delete (yyvsp[(2) - (3)].str);
;}
break;
case 22:
{
- opts.bUseYYSetStateNaked = (yyvsp[(2) - (3)].num) != 0;
+ opts.sync_bUseYYSetStateNaked ((yyvsp[(2) - (3)].num) != 0);
;}
break;
case 23:
{
- opts.yySetStateParam = *(yyvsp[(2) - (3)].str);
- opts.bUseYYSetStateParam = false;
+ opts.sync_yySetStateParam (*(yyvsp[(2) - (3)].str));
delete (yyvsp[(2) - (3)].str);
;}
break;
{
if ((yyvsp[(2) - (3)].num) == 0)
{
- opts.encoding.unset ((yyvsp[(1) - (3)].enc));
+ opts.sync_encoding_unset ((yyvsp[(1) - (3)].enc));
}
- else if (!opts.encoding.set ((yyvsp[(1) - (3)].enc)))
+ else if (!opts.sync_encoding ((yyvsp[(1) - (3)].enc)))
{
in->fatalf ("Cannot set %s encoding: please reset %s encoding first"
, Enc::name ((yyvsp[(1) - (3)].enc))
- , Enc::name (opts.encoding.type ()));
+ , Enc::name (opts.encoding ().type ()));
}
;}
break;
case 25:
{
- opts.indString = *(yyvsp[(2) - (3)].str);
+ opts.sync_indString (*(yyvsp[(2) - (3)].str));
delete (yyvsp[(2) - (3)].str);
;}
break;
{
in->fatal ("configuration 'indent:top' must be nonnegative");
}
- opts.topIndent = static_cast<uint32_t> ((yyvsp[(2) - (3)].num));
+ opts.sync_topIndent (static_cast<uint32_t> ((yyvsp[(2) - (3)].num)));
;}
break;
case 27:
{
- opts.labelPrefix = *(yyvsp[(2) - (3)].str);
+ opts.sync_labelPrefix (*(yyvsp[(2) - (3)].str));
delete (yyvsp[(2) - (3)].str);
;}
break;
case 30:
{
- opts.bUseStateAbort = (yyvsp[(2) - (3)].num) != 0;
+ opts.sync_bUseStateAbort ((yyvsp[(2) - (3)].num) != 0);
;}
break;
case 31:
{
- opts.bUseStateNext = (yyvsp[(2) - (3)].num) != 0;
+ opts.sync_bUseStateNext ((yyvsp[(2) - (3)].num) != 0);
;}
break;
case 32:
{
- opts.yybmHexTable = (yyvsp[(2) - (3)].num) != 0;
+ opts.sync_yybmHexTable ((yyvsp[(2) - (3)].num) != 0);
;}
break;
case 33:
{
- opts.yychConversion = (yyvsp[(2) - (3)].num) == 0
- ? ""
- : "(" + opts.mapCodeName["YYCTYPE"] + ")";
+ opts.sync_yychConversion ((yyvsp[(2) - (3)].num) != 0);
;}
break;
case 34:
{
- opts.bEmitYYCh = (yyvsp[(2) - (3)].num) != 0;
+ opts.sync_bEmitYYCh ((yyvsp[(2) - (3)].num) != 0);
;}
break;
case 35:
{
- opts.bUseYYFillCheck = (yyvsp[(2) - (3)].num) != 0;
+ opts.sync_bUseYYFillCheck ((yyvsp[(2) - (3)].num) != 0);
;}
break;
case 36:
{
- opts.bUseYYFill = (yyvsp[(2) - (3)].num) != 0;
+ opts.sync_bUseYYFill ((yyvsp[(2) - (3)].num) != 0);
;}
break;
case 37:
{
- opts.bUseYYFillParam = (yyvsp[(2) - (3)].num) != 0;
+ opts.sync_bUseYYFillParam ((yyvsp[(2) - (3)].num) != 0);
;}
break;
case 38:
{
- if (opts.cFlag)
+ if (opts.cFlag ())
{
in->fatal("condition or '<*>' required when using -c switch");
}
case 39:
{
- if (opts.cFlag)
+ if (opts.cFlag ())
in->fatal("condition or '<*>' required when using -c switch");
if (ruleDefault != NULL)
in->fatal("code to default rule is already defined");
o.source.write_version_time ();
o.source.write_line_info (in->get_cline (), in->get_fname ().c_str ());
- if (opts.flag_skeleton)
+ if (opts.flag_skeleton ())
{
Skeleton::emit_prolog (o.source);
}
- Enc encodingOld = opts.encoding;
+ Enc encodingOld = opts.encoding ();
while ((parseMode = i.echo()) != Scanner::Stop)
{
i.save_state(curr_state);
foundRules = false;
- if (opts.rFlag && parseMode == Scanner::Rules && dfa_map.size())
+ if (opts.rFlag () && parseMode == Scanner::Rules && dfa_map.size())
{
in->fatal("cannot have a second 'rules:re2c' block");
}
in->set_in_parse(true);
yyparse();
in->set_in_parse(false);
- if (opts.rFlag && parseMode == Scanner::Reuse)
+ if (opts.rFlag () && parseMode == Scanner::Reuse)
{
- if (foundRules || opts.encoding != encodingOld)
+ if (foundRules || opts.encoding () != encodingOld)
{
// Re-parse rules
parseMode = Scanner::Parse;
yyparse();
in->set_in_parse(false);
}
- encodingOld = opts.encoding;
+ encodingOld = opts.encoding ();
}
o.source.set_block_line (in->get_cline ());
- if (opts.cFlag)
+ uint32_t ind = opts.topIndent ();
+ if (opts.cFlag ())
{
RegExpMap::iterator it;
SetupMap::const_iterator itRuleSetup;
it->second = it->second ? mkAlt (def_rule, it->second) : def_rule;
}
- dfa_map[it->first] = genCode(it->second, o, it->first, opts.encoding.nCodeUnits ());
+ dfa_map[it->first] = genCode(it->second, o, it->first, opts.encoding ().nCodeUnits ());
}
if (parseMode != Scanner::Rules && dfa_map.find(it->first) != dfa_map.end())
{
- dfa_map[it->first]->emit(o, opts.topIndent, !--nCount, bPrologBrace);
+ dfa_map[it->first]->emit(o, ind, !--nCount, bPrologBrace);
}
}
}
{
if (parseMode != Scanner::Reuse)
{
- dfa_map[""] = genCode(spec, o, "", opts.encoding.nCodeUnits ());
+ dfa_map[""] = genCode(spec, o, "", opts.encoding ().nCodeUnits ());
}
if (parseMode != Scanner::Rules && dfa_map.find("") != dfa_map.end())
{
- dfa_map[""]->emit(o, opts.topIndent, 0, bPrologBrace);
+ dfa_map[""]->emit(o, ind, 0, bPrologBrace);
}
}
}
o.source.write_line_info (in->get_cline (), in->get_fname ().c_str ());
/* restore original char handling mode*/
- opts.encoding = encodingOld;
+ opts.sync_reset_encoding (encodingOld);
}
- if (opts.cFlag)
+ if (opts.cFlag ())
{
SetupMap::const_iterator itRuleSetup;
for (itRuleSetup = ruleSetupMap.begin(); itRuleSetup != ruleSetupMap.end(); ++itRuleSetup)
}
}
- if (opts.flag_skeleton)
+ if (opts.flag_skeleton ())
{
Skeleton::emit_epilog (o.source, o.names);
}
-/* Generated by re2c 0.14.3 on Mon Sep 21 22:04:43 2015 */
+/* Generated by re2c 0.14.3 on Wed Sep 23 13:14:09 2015 */
#line 1 "../src/parse/scanner_lex.re"
#include <stdlib.h>
#include <string.h>
++YYCURSOR;
#line 199 "../src/parse/scanner_lex.re"
{
- if (!(ignore_eoc || opts.DFlag || opts.flag_skeleton))
+ if (!(ignore_eoc || opts.DFlag () || opts.flag_skeleton ()))
{
out.write(tok, tok_len () - 1);
// -1 so we don't write out the \0
{
ignore_cnt++;
}
- else if (!(opts.DFlag || opts.flag_skeleton))
+ else if (!(opts.DFlag () || opts.flag_skeleton ()))
{
out.write(tok, tok_len ());
}
++YYCURSOR;
#line 87 "../src/parse/scanner_lex.re"
{
- if (opts.rFlag)
+ if (opts.rFlag ())
{
- opts.mapCodeName.clear();
+ opts.sync_reset_mapCodeName ();
}
else
{
++YYCURSOR;
#line 72 "../src/parse/scanner_lex.re"
{
- if (opts.rFlag)
+ if (opts.rFlag ())
{
fatal("found standard 're2c' block while using -r flag");
}
- if (!(opts.DFlag || opts.flag_skeleton))
+ if (!(opts.DFlag () || opts.flag_skeleton ()))
{
const size_t lexeme_len = cur[-1] == '{'
? sizeof ("%{") - 1
++YYCURSOR;
#line 99 "../src/parse/scanner_lex.re"
{
- if (!opts.rFlag)
+ if (!opts.rFlag ())
{
fatal("found 'use:re2c' block without -r flag");
}
reuse();
- if (!(opts.DFlag || opts.flag_skeleton))
+ if (!(opts.DFlag () || opts.flag_skeleton ()))
{
const size_t lexeme_len = sizeof ("/*!use:re2c") - 1;
out.write(tok, tok_len () - lexeme_len);
++YYCURSOR;
#line 113 "../src/parse/scanner_lex.re"
{
- if (!opts.DFlag)
+ if (!opts.DFlag ())
{
out.insert_yymaxfill ();
}
#line 122 "../src/parse/scanner_lex.re"
{
tok = pos = cur;
- out.insert_state_goto (opts.topIndent);
+ out.insert_state_goto (opts.topIndent ());
ignore_eoc = true;
goto echo;
}
{
tok = pos = cur;
ignore_eoc = true;
- if (!opts.DFlag)
+ if (!opts.DFlag ())
{
out.insert_line_info ();
out << "\n";
ignore_eoc = false;
ignore_cnt = 0;
}
- else if (!(opts.DFlag || opts.flag_skeleton))
+ else if (!(opts.DFlag () || opts.flag_skeleton ()))
{
out.write(tok, tok_len ());
}
ignore_eoc = false;
ignore_cnt = 0;
}
- else if (!(opts.DFlag || opts.flag_skeleton))
+ else if (!(opts.DFlag () || opts.flag_skeleton ()))
{
out.write(tok, tok_len ());
}
{
std::vector<uint32_t> cpoints;
lex_cpoints ('"', cpoints);
- yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive || opts.bCaseInverted);
+ yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive () || opts.bCaseInverted ());
return REGEXP;
}
#line 759 "src/parse/scanner_lex.cc"
{
std::vector<uint32_t> cpoints;
lex_cpoints ('\'', cpoints);
- yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive || !opts.bCaseInverted);
+ yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive () || !opts.bCaseInverted ());
return REGEXP;
}
#line 773 "src/parse/scanner_lex.cc"
++YYCURSOR;
#line 345 "../src/parse/scanner_lex.re"
{
- if (!opts.FFlag) {
+ if (!opts.FFlag ()) {
fatal("curly braces for names only allowed with -F switch");
}
yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces
YYCURSOR = YYCTXMARKER;
#line 373 "../src/parse/scanner_lex.re"
{
- if (!opts.FFlag) {
+ if (!opts.FFlag ()) {
yylval.str = new std::string (tok, tok_len ());
return ID;
} else {
{
cpoints.push_back (static_cast<uint8_t> (*p));
}
- yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive || opts.bCaseInverted);
+ yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive () || opts.bCaseInverted ());
return REGEXP;
}
}
#line 355 "../src/parse/scanner_lex.re"
{
yylval.str = new std::string (tok, tok_len ());
- if (opts.FFlag)
+ if (opts.FFlag ())
{
lexer_state = LEX_FLEX_NAME;
return FID;
{
if (first && bUsedYYBitmap)
{
- o << indent(ind) << "static const unsigned char " << opts.mapCodeName["yybm"] << "[] = {";
+ o << indent(ind) << "static const unsigned char " << opts.mapCodeName ()["yybm"] << "[] = {";
uint32_t c = 1, n = ub - lb;
const BitMap *cb = first;
o << "\n" << indent(ind+1);
}
- if (opts.yybmHexTable)
+ if (opts.yybmHexTable ())
{
o.write_hex (bm[j]);
}
namespace re2c
{
-std::string& CodeNames::operator [] (const char * what)
+std::string CodeNames::operator [] (const char * what) const
{
- CodeNames::iterator it = find(std::string(what));
-
- if (it == end())
- {
- return insert(std::make_pair(std::string(what), std::string(what))).first->second;
- }
- else
- {
- return it->second;
- }
+ CodeNames::const_iterator it = find (what);
+ return it == end ()
+ ? what
+ : it->second;
}
} // end namespace re2c
class CodeNames: public std::map<std::string, std::string>
{
public:
- std::string& operator [] (const char * what);
+ std::string operator [] (const char * what) const;
};
} // end namespace re2c
void emit_match (OutputFile & o, uint32_t ind, bool & readCh, const State * const s)
{
- if (opts.DFlag)
+ if (opts.DFlag ())
{
return;
}
&& s->next->action.type != Action::RULE;
if (s->link)
{
- o << opts.input_api.stmt_skip (ind);
+ o << opts.input_api ().stmt_skip (ind);
}
else if (!read_ahead)
{
/* do not read next char if match */
- o << opts.input_api.stmt_skip (ind);
+ o << opts.input_api ().stmt_skip (ind);
readCh = true;
}
else
{
- o << opts.input_api.stmt_skip_peek (ind);
+ o << opts.input_api ().stmt_skip_peek (ind);
readCh = false;
}
void emit_initial (OutputFile & o, uint32_t ind, bool & readCh, const State * const s, const Initial & initial, const std::set<label_t> & used_labels)
{
- if (opts.DFlag)
+ if (opts.DFlag ())
{
return;
}
{
if (s->link)
{
- o << opts.input_api.stmt_skip (ind);
+ o << opts.input_api ().stmt_skip (ind);
}
else
{
- o << opts.input_api.stmt_skip_peek (ind);
+ o << opts.input_api ().stmt_skip_peek (ind);
}
}
if (used_labels.count(initial.label))
{
- o << opts.labelPrefix << initial.label << ":\n";
+ o << opts.labelPrefix () << initial.label << ":\n";
}
- if (opts.dFlag)
+ if (opts.dFlag ())
{
- o << indent(ind) << opts.mapCodeName["YYDEBUG"] << "(" << initial.label << ", *" << opts.mapCodeName["YYCURSOR"] << ");" << "\n";
+ o << indent(ind) << opts.mapCodeName ()["YYDEBUG"] << "(" << initial.label << ", *" << opts.mapCodeName ()["YYCURSOR"] << ");" << "\n";
}
if (s->link)
{
if (initial.setMarker)
{
- o << opts.input_api.stmt_backup (ind);
+ o << opts.input_api ().stmt_backup (ind);
}
readCh = false;
}
void emit_save (OutputFile & o, uint32_t ind, bool & readCh, const State * const s, uint32_t save, bool save_yyaccept)
{
- if (opts.DFlag)
+ if (opts.DFlag ())
{
return;
}
if (save_yyaccept)
{
- o << indent (ind) << opts.mapCodeName["yyaccept"] << " = " << save << ";\n";
+ o << indent (ind) << opts.mapCodeName ()["yyaccept"] << " = " << save << ";\n";
}
if (s->link)
{
- o << opts.input_api.stmt_skip_backup (ind);
+ o << opts.input_api ().stmt_skip_backup (ind);
need(o, ind, readCh, s->depth, false);
}
else
{
- o << opts.input_api.stmt_skip_backup_peek (ind);
+ o << opts.input_api ().stmt_skip_backup_peek (ind);
readCh = false;
}
}
if (l < r)
{
const uint32_t m = (l + r) >> 1;
- o << indent(ind) << "if (" << opts.mapCodeName["yyaccept"] << (r == l+1 ? " == " : " <= ") << m << ") {\n";
+ o << indent(ind) << "if (" << opts.mapCodeName ()["yyaccept"] << (r == l+1 ? " == " : " <= ") << m << ") {\n";
emit_accept_binary (o, ++ind, readCh, s, accepts, l, m);
o << indent(--ind) << "} else {\n";
emit_accept_binary (o, ++ind, readCh, s, accepts, m + 1, r);
const uint32_t accepts_size = static_cast<uint32_t> (accepts.size ());
if (accepts_size > 0)
{
- if (!opts.DFlag)
+ if (!opts.DFlag ())
{
- o << opts.input_api.stmt_restore (ind);
+ o << opts.input_api ().stmt_restore (ind);
}
if (readCh) // shouldn't be necessary, but might become at some point
{
- o << opts.input_api.stmt_peek (ind);
+ o << opts.input_api ().stmt_peek (ind);
readCh = false;
}
if (accepts_size > 1)
{
- if (opts.gFlag && accepts_size >= opts.cGotoThreshold)
+ if (opts.gFlag () && accepts_size >= opts.cGotoThreshold ())
{
o << indent(ind++) << "{\n";
- o << indent(ind++) << "static void *" << opts.mapCodeName["yytarget"] << "[" << accepts_size << "] = {\n";
+ o << indent(ind++) << "static void *" << opts.mapCodeName ()["yytarget"] << "[" << accepts_size << "] = {\n";
for (uint32_t i = 0; i < accepts_size; ++i)
{
- o << indent(ind) << "&&" << opts.labelPrefix << accepts[i]->label << ",\n";
+ o << indent(ind) << "&&" << opts.labelPrefix () << accepts[i]->label << ",\n";
}
o << indent(--ind) << "};\n";
- o << indent(ind) << "goto *" << opts.mapCodeName["yytarget"] << "[" << opts.mapCodeName["yyaccept"] << "];\n";
+ o << indent(ind) << "goto *" << opts.mapCodeName ()["yytarget"] << "[" << opts.mapCodeName ()["yyaccept"] << "];\n";
o << indent(--ind) << "}\n";
}
- else if (opts.sFlag || (accepts_size == 2 && !opts.DFlag))
+ else if (opts.sFlag () || (accepts_size == 2 && !opts.DFlag ()))
{
emit_accept_binary (o, ind, readCh, s, accepts, 0, accepts_size - 1);
}
- else if (opts.DFlag)
+ else if (opts.DFlag ())
{
for (uint32_t i = 0; i < accepts_size; ++i)
{
}
else
{
- o << indent(ind) << "switch (" << opts.mapCodeName["yyaccept"] << ") {\n";
+ o << indent(ind) << "switch (" << opts.mapCodeName ()["yyaccept"] << ") {\n";
for (uint32_t i = 0; i < accepts_size - 1; ++i)
{
o << indent(ind) << "case " << i << ": \t";
void emit_rule (OutputFile & o, uint32_t ind, const State * const s, const RuleOp * const rule, const std::string & condName, const std::string & name)
{
- if (opts.DFlag)
+ if (opts.DFlag ())
{
o << s->label;
if (rule->code)
}
uint32_t back = rule->ctx->fixedLength();
- if (back != 0u && !opts.DFlag)
+ if (back != 0u && !opts.DFlag ())
{
- o << opts.input_api.stmt_restorectx (ind);
+ o << opts.input_api ().stmt_restorectx (ind);
}
- if (opts.flag_skeleton)
+ if (opts.flag_skeleton ())
{
Skeleton::emit_action (o, ind, rule->rank, name);
}
}
else if (!rule->newcond.empty ())
{
- o << indent (ind) << replaceParam(opts.condGoto, opts.condGotoParam, opts.condPrefix + rule->newcond) << "\n";
+ o << indent (ind) << replaceParam(opts.condGoto (), opts.condGotoParam (), opts.condPrefix () + rule->newcond) << "\n";
}
}
}
void need (OutputFile & o, uint32_t ind, bool & readCh, uint32_t n, bool bSetMarker)
{
- if (opts.DFlag)
+ if (opts.DFlag ())
{
return;
}
uint32_t fillIndex = last_fill_index;
- if (opts.fFlag)
+ if (opts.fFlag ())
{
last_fill_index++;
- if (opts.bUseYYSetStateParam)
+ if (opts.bUseYYSetStateParam ())
{
- o << indent(ind) << opts.mapCodeName["YYSETSTATE"] << "(" << fillIndex << ");\n";
+ o << indent(ind) << opts.mapCodeName ()["YYSETSTATE"] << "(" << fillIndex << ");\n";
}
else
{
- o << indent(ind) << replaceParam(opts.mapCodeName["YYSETSTATE"], opts.yySetStateParam, fillIndex) << "\n";
+ o << indent(ind) << replaceParam(opts.mapCodeName ()["YYSETSTATE"], opts.yySetStateParam (), fillIndex) << "\n";
}
}
- if (opts.bUseYYFill && n > 0)
+ if (opts.bUseYYFill () && n > 0)
{
o << indent(ind);
if (n == 1)
{
- if (opts.bUseYYFillCheck)
+ if (opts.bUseYYFillCheck ())
{
- o << "if (" << opts.input_api.expr_lessthan_one () << ") ";
+ o << "if (" << opts.input_api ().expr_lessthan_one () << ") ";
}
genYYFill(o, n);
}
else
{
- if (opts.bUseYYFillCheck)
+ if (opts.bUseYYFillCheck ())
{
- o << "if (" << opts.input_api.expr_lessthan (n) << ") ";
+ o << "if (" << opts.input_api ().expr_lessthan (n) << ") ";
}
genYYFill(o, n);
}
}
- if (opts.fFlag)
+ if (opts.fFlag ())
{
- o << opts.mapCodeName["yyFillLabel"] << fillIndex << ":\n";
+ o << opts.mapCodeName ()["yyFillLabel"] << fillIndex << ":\n";
}
if (n > 0)
{
if (bSetMarker)
{
- o << opts.input_api.stmt_backup_peek (ind);
+ o << opts.input_api ().stmt_backup_peek (ind);
}
else
{
- o << opts.input_api.stmt_peek (ind);
+ o << opts.input_api ().stmt_peek (ind);
}
readCh = false;
}
void genYYFill(OutputFile & o, uint32_t need)
{
- if (opts.bUseYYFillParam)
+ if (opts.bUseYYFillParam ())
{
- o << opts.mapCodeName["YYFILL"];
- if (!opts.bUseYYFillNaked)
+ o << opts.mapCodeName ()["YYFILL"];
+ if (!opts.bUseYYFillNaked ())
{
o << "(" << need << ");";
}
}
else
{
- o << replaceParam(opts.mapCodeName["YYFILL"], opts.yyFillLength, need);
- if (!opts.bUseYYFillNaked)
+ o << replaceParam(opts.mapCodeName ()["YYFILL"], opts.yyFillLength (), need);
+ if (!opts.bUseYYFillNaked ())
{
o << ";";
}
void genSetCondition(OutputFile & o, uint32_t ind, const std::string& newcond)
{
- if (opts.bUseYYSetConditionParam)
+ if (opts.bUseYYSetConditionParam ())
{
- o << indent(ind) << opts.mapCodeName["YYSETCONDITION"] << "(" << opts.condEnumPrefix << newcond << ");\n";
+ o << indent(ind) << opts.mapCodeName ()["YYSETCONDITION"] << "(" << opts.condEnumPrefix () << newcond << ");\n";
}
else
{
- o << indent(ind) << replaceParam(opts.mapCodeName["YYSETCONDITION"], opts.yySetConditionParam, opts.condEnumPrefix + newcond) << "\n";
+ o << indent(ind) << replaceParam(opts.mapCodeName ()["YYSETCONDITION"], opts.yySetConditionParam (), opts.condEnumPrefix () + newcond) << "\n";
}
}
std::string genGetCondition()
{
- if (opts.bUseYYGetConditionNaked)
+ if (opts.bUseYYGetConditionNaked ())
{
- return opts.mapCodeName["YYGETCONDITION"];
+ return opts.mapCodeName ()["YYGETCONDITION"];
}
else
{
- return opts.mapCodeName["YYGETCONDITION"] + "()";
+ return opts.mapCodeName ()["YYGETCONDITION"] + "()";
}
}
void genGoTo(OutputFile & o, uint32_t ind, const State *from, const State *to, bool & readCh)
{
- if (opts.DFlag)
+ if (opts.DFlag ())
{
o << from->label << " -> " << to->label << "\n";
return;
if (readCh && from->next != to)
{
- o << opts.input_api.stmt_peek (ind);
+ o << opts.input_api ().stmt_peek (ind);
readCh = false;
}
- o << indent(ind) << "goto " << opts.labelPrefix << to->label << ";\n";
+ o << indent(ind) << "goto " << opts.labelPrefix () << to->label << ";\n";
}
void emit_state (OutputFile & o, uint32_t ind, const State * s, bool used_label)
{
- if (!opts.DFlag)
+ if (!opts.DFlag ())
{
if (used_label)
{
- o << opts.labelPrefix << s->label << ":\n";
+ o << opts.labelPrefix () << s->label << ":\n";
}
- if (opts.dFlag && (s->action.type != Action::INITIAL))
+ if (opts.dFlag () && (s->action.type != Action::INITIAL))
{
- o << indent(ind) << opts.mapCodeName["YYDEBUG"] << "(" << s->label << ", " << opts.input_api.expr_peek () << ");\n";
+ o << indent(ind) << opts.mapCodeName ()["YYDEBUG"] << "(" << s->label << ", " << opts.input_api ().expr_peek () << ");\n";
}
if (s->isPreCtxt)
{
- o << opts.input_api.stmt_backupctx (ind);
+ o << opts.input_api ().stmt_backupctx (ind);
}
}
}
void DFA::count_used_labels (std::set<label_t> & used, label_t start, label_t initial, bool force_start) const
{
// In '-f' mode, default state is always state 0
- if (opts.fFlag)
+ if (opts.fFlag ())
{
used.insert (label_t::first ());
}
{
OutputFile & o = output.source;
- bool bProlog = (!opts.cFlag || !bWroteCondCheck);
+ bool bProlog = (!opts.cFlag () || !bWroteCondCheck);
// start_label points to the beginning of current re2c block
// (prior to condition dispatch in '-c' mode)
label_t start_label = o.label_counter.next ();
// initial_label points to the beginning of DFA
// in '-c' mode this is NOT equal to start_label
- label_t initial_label = bProlog && opts.cFlag
+ label_t initial_label = bProlog && opts.cFlag ()
? o.label_counter.next ()
: start_label;
for (State * s = head; s; s = s->next)
skeleton->warn_undefined_control_flow ();
- if (opts.flag_skeleton)
+ if (opts.flag_skeleton ())
{
skeleton->emit_data (o.file_name);
skeleton->emit_start (o, max_fill, need_backup, need_backupctx, need_accept);
{
o << "\n";
o.insert_line_info ();
- if (opts.DFlag)
+ if (opts.DFlag ())
{
bPrologBrace = true;
o << "digraph re2c {\n";
}
- else if ((!opts.fFlag && o.get_used_yyaccept ())
- || (!opts.fFlag && opts.bEmitYYCh)
- || (opts.bFlag && !opts.cFlag && BitMap::first)
- || (opts.cFlag && !bWroteCondCheck && opts.gFlag)
- || (opts.fFlag && !bWroteGetState && opts.gFlag)
+ else if ((!opts.fFlag () && o.get_used_yyaccept ())
+ || (!opts.fFlag () && opts.bEmitYYCh ())
+ || (opts.bFlag () && !opts.cFlag () && BitMap::first)
+ || (opts.cFlag () && !bWroteCondCheck && opts.gFlag ())
+ || (opts.fFlag () && !bWroteGetState && opts.gFlag ())
)
{
bPrologBrace = true;
{
ind = 1;
}
- if (!opts.fFlag && !opts.DFlag)
+ if (!opts.fFlag () && !opts.DFlag ())
{
- if (opts.bEmitYYCh)
+ if (opts.bEmitYYCh ())
{
- o << indent(ind) << opts.mapCodeName["YYCTYPE"] << " " << opts.mapCodeName["yych"] << ";\n";
+ o << indent(ind) << opts.mapCodeName ()["YYCTYPE"] << " " << opts.mapCodeName ()["yych"] << ";\n";
}
o.insert_yyaccept_init (ind);
}
o << "\n";
}
}
- if (opts.bFlag && !opts.cFlag && BitMap::first)
+ if (opts.bFlag () && !opts.cFlag () && BitMap::first)
{
BitMap::gen(o, ind, lbChar, ubChar <= 256 ? ubChar : 256);
}
if (bProlog)
{
- if (opts.cFlag && !bWroteCondCheck && opts.gFlag)
+ if (opts.cFlag () && !bWroteCondCheck && opts.gFlag ())
{
genCondTable(o, ind, output.types);
}
o.insert_state_goto (ind);
- if (opts.cFlag && !opts.DFlag)
+ if (opts.cFlag () && !opts.DFlag ())
{
if (used_labels.count(start_label))
{
- o << opts.labelPrefix << start_label << ":\n";
+ o << opts.labelPrefix () << start_label << ":\n";
}
}
o.write_user_start_label ();
- if (opts.cFlag && !bWroteCondCheck)
+ if (opts.cFlag () && !bWroteCondCheck)
{
genCondGoto(o, ind, output.types);
}
}
- if (opts.cFlag && !cond.empty())
+ if (opts.cFlag () && !cond.empty())
{
- if (opts.condDivider.length())
+ if (opts.condDivider ().length())
{
- o << replaceParam(opts.condDivider, opts.condDividerParam, cond) << "\n";
+ o << replaceParam(opts.condDivider (), opts.condDividerParam (), cond) << "\n";
}
- if (opts.DFlag)
+ if (opts.DFlag ())
{
o << cond << " -> " << head->label << "\n";
}
else
{
- o << opts.condPrefix << cond << ":\n";
+ o << opts.condPrefix () << cond << ":\n";
}
}
- if (opts.cFlag && opts.bFlag && BitMap::first)
+ if (opts.cFlag () && opts.bFlag () && BitMap::first)
{
o << indent(ind++) << "{\n";
BitMap::gen(o, ind, lbChar, ubChar <= 256 ? ubChar : 256);
// skip it when entering DFA.
if (used_labels.count(head->label))
{
- o << indent(ind) << "goto " << opts.labelPrefix << initial_label << ";\n";
+ o << indent(ind) << "goto " << opts.labelPrefix () << initial_label << ";\n";
}
// Generate code
emit_body (o, ind, used_labels);
- if (opts.cFlag && opts.bFlag && BitMap::first)
+ if (opts.cFlag () && opts.bFlag () && BitMap::first)
{
o << indent(--ind) << "}\n";
}
// Generate epilog
- if ((!opts.cFlag || isLastCond) && bPrologBrace)
+ if ((!opts.cFlag () || isLastCond) && bPrologBrace)
{
o << indent(--ind) << "}\n";
}
void genCondTable(OutputFile & o, uint32_t ind, const std::vector<std::string> & condnames)
{
const size_t conds = condnames.size ();
- o << indent(ind++) << "static void *" << opts.mapCodeName["yyctable"] << "[" << conds << "] = {\n";
+ o << indent(ind++) << "static void *" << opts.mapCodeName ()["yyctable"] << "[" << conds << "] = {\n";
for (size_t i = 0; i < conds; ++i)
{
- o << indent(ind) << "&&" << opts.condPrefix << condnames[i] << ",\n";
+ o << indent(ind) << "&&" << opts.condPrefix () << condnames[i] << ",\n";
}
o << indent(--ind) << "};\n";
}
{
if (cMin == cMax)
{
- o << indent(ind) << "goto " << opts.condPrefix << condnames[cMin] << ";\n";
+ o << indent(ind) << "goto " << opts.condPrefix () << condnames[cMin] << ";\n";
}
else
{
void genCondGoto(OutputFile & o, uint32_t ind, const std::vector<std::string> & condnames)
{
const size_t conds = condnames.size ();
- if (opts.DFlag)
+ if (opts.DFlag ())
{
o.warn_condition_order = false; // see note [condition order]
for (size_t i = 0; i < conds; ++i)
o << "0 -> " << cond << " [label=\"state=" << cond << "\"]\n";
}
}
- else if (opts.gFlag)
+ else if (opts.gFlag ())
{
- o << indent(ind) << "goto *" << opts.mapCodeName["yyctable"] << "[" << genGetCondition() << "];\n";
+ o << indent(ind) << "goto *" << opts.mapCodeName ()["yyctable"] << "[" << genGetCondition() << "];\n";
}
- else if (opts.sFlag)
+ else if (opts.sFlag ())
{
if (conds == 1)
{
for (size_t i = 0; i < conds; ++i)
{
const std::string & cond = condnames[i];
- o << indent(ind) << "case " << opts.condEnumPrefix << cond << ": goto " << opts.condPrefix << cond << ";\n";
+ o << indent(ind) << "case " << opts.condEnumPrefix () << cond << ": goto " << opts.condPrefix () << cond << ";\n";
}
o << indent(ind) << "}\n";
}
: type (IF)
, info ()
{
- if ((!opts.sFlag && nsp > 2) || (nsp > 8 && (sp[nsp - 2].ub - sp[0].ub <= 3 * (nsp - 2))))
+ if ((!opts.sFlag () && nsp > 2) || (nsp > 8 && (sp[nsp - 2].ub - sp[0].ub <= 3 * (nsp - 2))))
{
type = SWITCH;
info.cases = new Cases (sp, nsp);
}
const uint32_t dSpans = nSpans - hSpans - nBitmaps;
- if (opts.DFlag)
+ if (opts.DFlag ())
{
type = DOT;
info.dot = new Dot (span, nSpans, from);
}
- else if (opts.gFlag && (dSpans >= opts.cGotoThreshold))
+ else if (opts.gFlag () && (dSpans >= opts.cGotoThreshold ()))
{
type = CPGOTO;
info.cpgoto = new Cpgoto (span, nSpans, hspan, hSpans, from->next);
}
- else if (opts.bFlag && (nBitmaps > 0))
+ else if (opts.bFlag () && (nBitmaps > 0))
{
type = BITMAP;
info.bitmap = new GoBitmap (span, nSpans, hspan, hSpans, bitmap, bitmap_state, from->next);
if (readCh)
{
readCh = false;
- return "(" + opts.input_api.expr_peek_save () + ")";
+ return "(" + opts.input_api ().expr_peek_save () + ")";
}
else
{
- return opts.mapCodeName["yych"];
+ return opts.mapCodeName ()["yych"];
}
}
{
if (readCh)
{
- o << opts.input_api.stmt_peek (ind);
+ o << opts.input_api ().stmt_peek (ind);
readCh = false;
}
- o << indent (ind) << "goto " << opts.labelPrefix << to << ";\n";
+ o << indent (ind) << "goto " << opts.labelPrefix () << to << ";\n";
}
std::string output_hgo (OutputFile & o, uint32_t ind, bool & readCh, SwitchIf * hgo)
o << indent (ind) << "if (" << yych <<" & ~0xFF) {\n";
hgo->emit (o, ind + 1, readCh);
o << indent (ind) << "} else ";
- yych = opts.mapCodeName["yych"];
+ yych = opts.mapCodeName ()["yych"];
}
else
{
o << indent (ind) << "case ";
o.write_char_hex (b);
o << ":";
- if (opts.dFlag && opts.encoding.type () == Enc::EBCDIC)
+ if (opts.dFlag () && opts.encoding ().type () == Enc::EBCDIC)
{
- const uint32_t c = opts.encoding.decodeUnsafe (b);
+ const uint32_t c = opts.encoding ().decodeUnsafe (b);
if (is_print (c))
o << " /* " << static_cast<char> (c) << " */";
}
void GoBitmap::emit (OutputFile & o, uint32_t ind, bool & readCh)
{
std::string yych = output_hgo (o, ind, readCh, hgo);
- o << "if (" << opts.mapCodeName["yybm"] << "[" << bitmap->i << "+" << yych << "] & ";
- if (opts.yybmHexTable)
+ o << "if (" << opts.mapCodeName ()["yybm"] << "[" << bitmap->i << "+" << yych << "] & ";
+ if (opts.yybmHexTable ())
{
o.write_hex (bitmap->m);
}
void CpgotoTable::emit (OutputFile & o, uint32_t ind)
{
- o << indent (ind) << "static void *" << opts.mapCodeName["yytarget"] << "[256] = {\n";
+ o << indent (ind) << "static void *" << opts.mapCodeName ()["yytarget"] << "[256] = {\n";
o << indent (++ind);
const uint32_t max_digits = max_label ().width ();
for (uint32_t i = 0; i < TABLE_SIZE; ++i)
{
- o << "&&" << opts.labelPrefix << table[i]->label;
+ o << "&&" << opts.labelPrefix () << table[i]->label;
if (i == TABLE_SIZE - 1)
{
o << "\n";
std::string yych = output_hgo (o, ind, readCh, hgo);
o << "{\n";
table->emit (o, ++ind);
- o << indent(ind) << "goto *" << opts.mapCodeName["yytarget"] << "[" << yych << "];\n";
+ o << indent(ind) << "goto *" << opts.mapCodeName ()["yytarget"] << "[" << yych << "];\n";
o << indent(--ind) << "}\n";
}
{
std::string str;
- while (!opts.DFlag && ind-- > 0)
+ while (!opts.DFlag () && ind-- > 0)
{
- str += opts.indString;
+ str += opts.indString ();
}
return str;
}
type_ = t;
}
-std::string InputAPI::expr_peek ()
+std::string InputAPI::expr_peek () const
{
std::string s;
switch (type_)
{
case DEFAULT:
- s = "*" + opts.mapCodeName["YYCURSOR"];
+ s = "*" + opts.mapCodeName ()["YYCURSOR"];
break;
case CUSTOM:
- s = opts.mapCodeName["YYPEEK"] + " ()";
+ s = opts.mapCodeName ()["YYPEEK"] + " ()";
break;
}
return s;
}
-std::string InputAPI::expr_peek_save ()
+std::string InputAPI::expr_peek_save () const
{
- return opts.mapCodeName["yych"] + " = " + opts.yychConversion + expr_peek ();
+ return opts.mapCodeName ()["yych"] + " = " + opts.yychConversion () + expr_peek ();
}
-std::string InputAPI::stmt_peek (uint32_t ind)
+std::string InputAPI::stmt_peek (uint32_t ind) const
{
return indent (ind) + expr_peek_save () + ";\n";
}
-std::string InputAPI::stmt_skip (uint32_t ind)
+std::string InputAPI::stmt_skip (uint32_t ind) const
{
std::string s;
switch (type_)
{
case DEFAULT:
- s = "++" + opts.mapCodeName["YYCURSOR"];
+ s = "++" + opts.mapCodeName ()["YYCURSOR"];
break;
case CUSTOM:
- s = opts.mapCodeName["YYSKIP"] + " ()";
+ s = opts.mapCodeName ()["YYSKIP"] + " ()";
break;
}
return indent (ind) + s + ";\n";
}
-std::string InputAPI::stmt_backup (uint32_t ind)
+std::string InputAPI::stmt_backup (uint32_t ind) const
{
std::string s;
switch (type_)
{
case DEFAULT:
- s = opts.mapCodeName["YYMARKER"] + " = " + opts.mapCodeName["YYCURSOR"];
+ s = opts.mapCodeName ()["YYMARKER"] + " = " + opts.mapCodeName ()["YYCURSOR"];
break;
case CUSTOM:
- s = opts.mapCodeName["YYBACKUP"] + " ()";
+ s = opts.mapCodeName ()["YYBACKUP"] + " ()";
break;
}
return indent (ind) + s + ";\n";
}
-std::string InputAPI::stmt_backupctx (uint32_t ind)
+std::string InputAPI::stmt_backupctx (uint32_t ind) const
{
std::string s;
switch (type_)
{
case DEFAULT:
// backward compatibility: '+1' here instead of '++YYCURSOR;' in stmt_restorectx
- s = opts.mapCodeName["YYCTXMARKER"] + " = " + opts.mapCodeName["YYCURSOR"] + " + 1";
+ s = opts.mapCodeName ()["YYCTXMARKER"] + " = " + opts.mapCodeName ()["YYCURSOR"] + " + 1";
break;
case CUSTOM:
- s = opts.mapCodeName["YYBACKUPCTX"] + " ()";
+ s = opts.mapCodeName ()["YYBACKUPCTX"] + " ()";
break;
}
return indent (ind) + s + ";\n";
}
-std::string InputAPI::stmt_restore (uint32_t ind)
+std::string InputAPI::stmt_restore (uint32_t ind) const
{
std::string s;
switch (type_)
{
case DEFAULT:
- s = opts.mapCodeName["YYCURSOR"] + " = " + opts.mapCodeName["YYMARKER"];
+ s = opts.mapCodeName ()["YYCURSOR"] + " = " + opts.mapCodeName ()["YYMARKER"];
break;
case CUSTOM:
- s = opts.mapCodeName["YYRESTORE"] + " ()";
+ s = opts.mapCodeName ()["YYRESTORE"] + " ()";
break;
}
return indent (ind) + s + ";\n";
}
-std::string InputAPI::stmt_restorectx (uint32_t ind)
+std::string InputAPI::stmt_restorectx (uint32_t ind) const
{
std::string s;
switch (type_)
{
case DEFAULT:
// backward compatibility: 'no ++YYCURSOR;' here; instead '+1' in stmt_backupctx
- s = indent (ind) + opts.mapCodeName["YYCURSOR"] + " = " + opts.mapCodeName["YYCTXMARKER"] + ";\n";
+ s = indent (ind) + opts.mapCodeName ()["YYCURSOR"] + " = " + opts.mapCodeName ()["YYCTXMARKER"] + ";\n";
break;
case CUSTOM:
- s = indent (ind) + opts.mapCodeName["YYRESTORECTX"] + " ();\n" + stmt_skip (ind);
+ s = indent (ind) + opts.mapCodeName ()["YYRESTORECTX"] + " ();\n" + stmt_skip (ind);
break;
}
return s;
}
-std::string InputAPI::stmt_skip_peek (uint32_t ind)
+std::string InputAPI::stmt_skip_peek (uint32_t ind) const
{
return type_ == DEFAULT
- ? indent (ind) + opts.mapCodeName["yych"] + " = " + opts.yychConversion + "*++" + opts.mapCodeName["YYCURSOR"] + ";\n"
+ ? indent (ind) + opts.mapCodeName ()["yych"] + " = " + opts.yychConversion () + "*++" + opts.mapCodeName ()["YYCURSOR"] + ";\n"
: stmt_skip (ind) + stmt_peek (ind);
}
-std::string InputAPI::stmt_skip_backup (uint32_t ind)
+std::string InputAPI::stmt_skip_backup (uint32_t ind) const
{
return type_ == DEFAULT
- ? indent (ind) + opts.mapCodeName["YYMARKER"] + " = ++" + opts.mapCodeName["YYCURSOR"] + ";\n"
+ ? indent (ind) + opts.mapCodeName ()["YYMARKER"] + " = ++" + opts.mapCodeName ()["YYCURSOR"] + ";\n"
: stmt_skip (ind) + stmt_backup (ind);
}
-std::string InputAPI::stmt_backup_peek (uint32_t ind)
+std::string InputAPI::stmt_backup_peek (uint32_t ind) const
{
return type_ == DEFAULT
- ? indent (ind) + opts.mapCodeName["yych"] + " = " + opts.yychConversion + "*(" + opts.mapCodeName["YYMARKER"] + " = " + opts.mapCodeName["YYCURSOR"] + ");\n"
+ ? indent (ind) + opts.mapCodeName ()["yych"] + " = " + opts.yychConversion () + "*(" + opts.mapCodeName ()["YYMARKER"] + " = " + opts.mapCodeName ()["YYCURSOR"] + ");\n"
: stmt_backup (ind) + stmt_peek (ind);
}
-std::string InputAPI::stmt_skip_backup_peek (uint32_t ind)
+std::string InputAPI::stmt_skip_backup_peek (uint32_t ind) const
{
return type_ == DEFAULT
- ? indent (ind) + opts.mapCodeName["yych"] + " = " + opts.yychConversion + "*(" + opts.mapCodeName["YYMARKER"] + " = ++" + opts.mapCodeName["YYCURSOR"] + ");\n"
+ ? indent (ind) + opts.mapCodeName ()["yych"] + " = " + opts.yychConversion () + "*(" + opts.mapCodeName ()["YYMARKER"] + " = ++" + opts.mapCodeName ()["YYCURSOR"] + ");\n"
: stmt_skip (ind) + stmt_backup (ind) + stmt_peek (ind);
}
-std::string InputAPI::expr_lessthan_one ()
+std::string InputAPI::expr_lessthan_one () const
{
return type_ == DEFAULT
- ? opts.mapCodeName["YYLIMIT"] + " <= " + opts.mapCodeName["YYCURSOR"]
+ ? opts.mapCodeName ()["YYLIMIT"] + " <= " + opts.mapCodeName ()["YYCURSOR"]
: expr_lessthan (1);
}
-std::string InputAPI::expr_lessthan (uint32_t n)
+std::string InputAPI::expr_lessthan (uint32_t n) const
{
std::ostringstream s;
switch (type_)
{
case DEFAULT:
- s << "(" << opts.mapCodeName["YYLIMIT"] << " - " << opts.mapCodeName["YYCURSOR"] << ") < " << n;
+ s << "(" << opts.mapCodeName ()["YYLIMIT"] << " - " << opts.mapCodeName ()["YYCURSOR"] << ") < " << n;
break;
case CUSTOM:
- s << opts.mapCodeName["YYLESSTHAN"] << " (" << n << ")";
+ s << opts.mapCodeName ()["YYLESSTHAN"] << " (" << n << ")";
break;
}
return s.str ();
public:
type_t type () const;
void set (type_t t);
- std::string expr_peek ();
- std::string expr_peek_save ();
- std::string stmt_peek (uint32_t ind);
- std::string stmt_skip (uint32_t ind);
- std::string stmt_backup (uint32_t ind);
- std::string stmt_backupctx (uint32_t ind);
- std::string stmt_restore (uint32_t ind);
- std::string stmt_restorectx (uint32_t ind);
- std::string stmt_skip_peek (uint32_t ind);
- std::string stmt_skip_backup (uint32_t ind);
- std::string stmt_backup_peek (uint32_t ind);
- std::string stmt_skip_backup_peek (uint32_t ind);
- std::string expr_lessthan_one ();
- std::string expr_lessthan (uint32_t n);
+ std::string expr_peek () const;
+ std::string expr_peek_save () const;
+ std::string stmt_peek (uint32_t ind) const;
+ std::string stmt_skip (uint32_t ind) const;
+ std::string stmt_backup (uint32_t ind) const;
+ std::string stmt_backupctx (uint32_t ind) const;
+ std::string stmt_restore (uint32_t ind) const;
+ std::string stmt_restorectx (uint32_t ind) const;
+ std::string stmt_skip_peek (uint32_t ind) const;
+ std::string stmt_skip_backup (uint32_t ind) const;
+ std::string stmt_backup_peek (uint32_t ind) const;
+ std::string stmt_skip_backup_peek (uint32_t ind) const;
+ std::string expr_lessthan_one () const;
+ std::string expr_lessthan (uint32_t n) const;
};
} // end namespace re2c
, file (NULL)
, blocks ()
, label_counter ()
- , warn_condition_order (!opts.tFlag) // see note [condition order]
+ , warn_condition_order (!opts.tFlag ()) // see note [condition order]
{
new_block ();
}
void OutputFile::insert_state_goto (uint32_t ind)
{
- if (opts.fFlag && !bWroteGetState)
+ if (opts.fFlag () && !bWroteGetState)
{
blocks.back ()->fragments.push_back (new OutputFragment (OutputFragment::STATE_GOTO, ind));
insert_code ();
void output_state_goto (std::ostream & o, uint32_t ind, uint32_t start_label)
{
o << indent(ind) << "switch (" << output_get_state() << ") {\n";
- if (opts.bUseStateAbort)
+ if (opts.bUseStateAbort ())
{
o << indent(ind) << "default: abort();\n";
- o << indent(ind) << "case -1: goto " << opts.labelPrefix << start_label << ";\n";
+ o << indent(ind) << "case -1: goto " << opts.labelPrefix () << start_label << ";\n";
}
else
{
- o << indent(ind) << "default: goto " << opts.labelPrefix << start_label << ";\n";
+ o << indent(ind) << "default: goto " << opts.labelPrefix () << start_label << ";\n";
}
for (uint32_t i = 0; i < last_fill_index; ++i)
{
- o << indent(ind) << "case " << i << ": goto " << opts.mapCodeName["yyFillLabel"] << i << ";\n";
+ o << indent(ind) << "case " << i << ": goto " << opts.mapCodeName ()["yyFillLabel"] << i << ";\n";
}
o << indent(ind) << "}\n";
- if (opts.bUseStateNext)
+ if (opts.bUseStateNext ())
{
- o << opts.mapCodeName["yyNext"] << ":\n";
+ o << opts.mapCodeName ()["yyNext"] << ":\n";
}
}
{
if (used_yyaccept)
{
- o << indent (ind) << "unsigned int " << opts.mapCodeName["yyaccept"] << " = 0;\n";
+ o << indent (ind) << "unsigned int " << opts.mapCodeName ()["yyaccept"] << " = 0;\n";
}
}
void output_line_info (std::ostream & o, uint32_t line_number, const char * file_name)
{
- if (!opts.iFlag)
+ if (!opts.iFlag ())
{
o << "#line " << line_number << " \"" << file_name << "\"\n";
}
void output_types (std::ostream & o, uint32_t ind, const std::vector<std::string> & types)
{
- o << indent (ind++) << "enum " << opts.mapCodeName["YYCONDTYPE"] << " {\n";
+ o << indent (ind++) << "enum " << opts.mapCodeName ()["YYCONDTYPE"] << " {\n";
for (unsigned int i = 0; i < types.size (); ++i)
{
- o << indent (ind) << opts.condEnumPrefix << types[i] << ",\n";
+ o << indent (ind) << opts.condEnumPrefix () << types[i] << ",\n";
}
o << indent (--ind) << "};\n";
}
void output_version_time (std::ostream & o)
{
o << "/* Generated by re2c " PACKAGE_VERSION;
- if (!opts.bNoGenerationDate)
+ if (!opts.bNoGenerationDate ())
{
o << " on ";
time_t now = time (NULL);
std::string output_get_state ()
{
- if (opts.bUseYYGetStateNaked)
+ if (opts.bUseYYGetStateNaked ())
{
- return opts.mapCodeName["YYGETSTATE"];
+ return opts.mapCodeName ()["YYGETSTATE"];
}
else
{
- return opts.mapCodeName["YYGETSTATE"] + "()";
+ return opts.mapCodeName ()["YYGETSTATE"] + "()";
}
}
s->isBase = true;
split(s);
- if (opts.bFlag)
+ if (opts.bFlag ())
{
BitMap::find(&s->next->go, s);
}
void prtChOrHex(std::ostream& o, uint32_t c)
{
- if (opts.encoding.type () != Enc::EBCDIC
+ if (opts.encoding ().type () != Enc::EBCDIC
&& (is_print (c) || is_space (c)))
{
o << '\'';
void prtHex(std::ostream& o, uint32_t c)
{
o << "0x";
- const uint32_t cunit_size = opts.encoding.szCodeUnit ();
+ const uint32_t cunit_size = opts.encoding ().szCodeUnit ();
if (cunit_size >= 4)
{
o << hexCh (c >> 28u)
switch (c)
{
case '\'':
- o << (opts.DFlag ? "'" : "\\'");
+ o << (opts.DFlag () ? "'" : "\\'");
break;
case '"':
- o << (opts.DFlag ? "\\\"" : "\"");
+ o << (opts.DFlag () ? "\\\"" : "\"");
break;
case '\n':
- o << (opts.DFlag ? "\\\\n" : "\\n");
+ o << (opts.DFlag () ? "\\\\n" : "\\n");
break;
case '\t':
- o << (opts.DFlag ? "\\\\t" : "\\t");
+ o << (opts.DFlag () ? "\\\\t" : "\\t");
break;
case '\v':
- o << (opts.DFlag ? "\\\\v" : "\\v");
+ o << (opts.DFlag () ? "\\\\v" : "\\v");
break;
case '\b':
- o << (opts.DFlag ? "\\\\b" : "\\b");
+ o << (opts.DFlag () ? "\\\\b" : "\\b");
break;
case '\r':
- o << (opts.DFlag ? "\\\\r" : "\\r");
+ o << (opts.DFlag () ? "\\\\r" : "\\r");
break;
case '\f':
- o << (opts.DFlag ? "\\\\f" : "\\f");
+ o << (opts.DFlag () ? "\\\\f" : "\\f");
break;
case '\a':
- o << (opts.DFlag ? "\\\\a" :"\\a");
+ o << (opts.DFlag () ? "\\\\a" :"\\a");
break;
case '\\':
void prtChOrHexForSpan(std::ostream& o, uint32_t c)
{
- if (opts.encoding.type () != Enc::EBCDIC
+ if (opts.encoding ().type () != Enc::EBCDIC
&& is_print (c)
&& (c != ']'))
{
void Skeleton::emit_prolog (OutputFile & o)
{
- const std::string & ind = opts.indString;
+ const std::string & ind = opts.indString ();
o << "\n" << "#include <stdio.h>";
o << "\n" << "#include <stdlib.h> /* malloc, free */";
, bool accept
) const
{
- const std::string & ind = opts.indString;
+ const std::string & ind = opts.indString ();
const uint32_t default_rule = maxkey ();
o << "\n" << "#define YYCTYPE ";
- exact_uint (o, opts.encoding.szCodeUnit ());
+ exact_uint (o, opts.encoding ().szCodeUnit ());
o << "\n" << "#define YYKEYTYPE ";
exact_uint (o, sizeof_key);
o << "\n" << "#define YYPEEK() *cursor";
{
o << "\n" << ind << ind << "unsigned int yyaccept = 0;";
}
- if (opts.bFlag && BitMap::first)
+ if (opts.bFlag () && BitMap::first)
{
- BitMap::gen (o, 2, 0, std::min (0xFFu, opts.encoding.nCodeUnits ()));
+ BitMap::gen (o, 2, 0, std::min (0xFFu, opts.encoding ().nCodeUnits ()));
}
o << "\n";
}
, bool backupctx
) const
{
- const std::string & ind = opts.indString;
+ const std::string & ind = opts.indString ();
o << "\n" << ind << "}";
o << "\n" << ind << "if (status == 0)";
const size_t names_count = names.size ();
for (size_t i = 0; i < names_count; ++i)
{
- o << "\n" << opts.indString << "if (lex_" << names[i] << " () != 0) return 1;";
+ o << "\n" << opts.indString () << "if (lex_" << names[i] << " () != 0) return 1;";
}
- o << "\n" << opts.indString << "return 0;";
+ o << "\n" << opts.indString () << "return 0;";
o << "\n" << "}";
o << "\n";
}
void Skeleton::generate_paths (FILE * input, FILE * keys)
{
- switch (opts.encoding.szCodeUnit ())
+ switch (opts.encoding ().szCodeUnit ())
{
case 4: generate_paths_cunit<uint32_t> (input, keys); break;
case 2: generate_paths_cunit<uint16_t> (input, keys); break;
, flag_skeleton (false)
, bNoGenerationDate (false)
, bEmitYYCh (true)
+ , yychConversion (false)
, bUseStateNext (false)
, bUseYYFill (true)
, bUseYYFillParam (true)
, condDividerParam ("@@")
, condGoto ("goto @@;")
, condGotoParam ("@@")
- , yychConversion ("")
, yyFillLength ("@@")
, yySetConditionParam ("@@")
, yySetStateParam ("@@")
, flag_skeleton (opt.flag_skeleton)
, bNoGenerationDate (opt.bNoGenerationDate)
, bEmitYYCh (opt.bEmitYYCh)
+ , yychConversion (opt.yychConversion)
, bUseStateNext (opt.bUseStateNext)
, bUseYYFill (opt.bUseYYFill)
, bUseYYFillParam (opt.bUseYYFillParam)
, condDividerParam (opt.condDividerParam)
, condGoto (opt.condGoto)
, condGotoParam (opt.condGotoParam)
- , yychConversion (opt.yychConversion)
, yyFillLength (opt.yyFillLength)
, yySetConditionParam (opt.yySetConditionParam)
, yySetStateParam (opt.yySetStateParam)
return *this;
}
-bool Opt::apply ()
+bool opt_t::check ()
{
- *((opt_t *) this) = useropt;
-
// check groups of mutually exclusive options
if (DFlag && flag_skeleton)
{
error ("incompatible options: '-D, --emit-dot' and '--skeleton'");
return false;
}
+ return true;
+}
- // reset to default options that make no sense in current configuration
+void opt_t::fix ()
+{
+ // some options don't make sense in current configuration
+ // reset them to default
if (DFlag)
{
- bFlag = baseopt.bFlag;
- dFlag = baseopt.dFlag;
- fFlag = baseopt.fFlag;
- gFlag = baseopt.gFlag;
- iFlag = baseopt.iFlag;
- sFlag = baseopt.sFlag;
- tFlag = baseopt.tFlag;
- header_file = baseopt.header_file;
- bEmitYYCh = baseopt.bEmitYYCh;
- bUseStateNext = baseopt.bUseStateNext;
- bUseYYFill = baseopt.bUseYYFill;
- bUseYYFillParam = baseopt.bUseYYFillParam;
- bUseYYFillCheck = baseopt.bUseYYFillCheck;
- bUseYYFillNaked = baseopt.bUseYYFillNaked;
- bUseYYSetConditionParam = baseopt.bUseYYSetConditionParam;
- bUseYYGetConditionNaked = baseopt.bUseYYGetConditionNaked;
- bUseYYSetStateParam = baseopt.bUseYYSetStateParam;
- bUseYYSetStateNaked = baseopt.bUseYYSetStateNaked;
- bUseYYGetStateNaked = baseopt.bUseYYGetStateNaked;
- yybmHexTable = baseopt.yybmHexTable;
- bUseStateAbort = baseopt.bUseStateAbort;
- cGotoThreshold = baseopt.cGotoThreshold;
- topIndent = baseopt.topIndent;
- indString = baseopt.indString;
- labelPrefix = baseopt.labelPrefix;
- condPrefix = baseopt.condPrefix;
- condEnumPrefix = baseopt.condEnumPrefix;
- condDivider = baseopt.condDivider;
- condDividerParam = baseopt.condDividerParam;
- condGoto = baseopt.condGoto;
- condGotoParam = baseopt.condGotoParam;
- yychConversion = baseopt.yychConversion;
- yyFillLength = baseopt.yyFillLength;
- yySetConditionParam = baseopt.yySetConditionParam;
- yySetStateParam = baseopt.yySetStateParam;
- mapCodeName = baseopt.mapCodeName;
- input_api = baseopt.input_api;
+ bFlag = Opt::baseopt.bFlag;
+ dFlag = Opt::baseopt.dFlag;
+ fFlag = Opt::baseopt.fFlag;
+ gFlag = Opt::baseopt.gFlag;
+ iFlag = Opt::baseopt.iFlag;
+ sFlag = Opt::baseopt.sFlag;
+ tFlag = Opt::baseopt.tFlag;
+ header_file = Opt::baseopt.header_file;
+ bEmitYYCh = Opt::baseopt.bEmitYYCh;
+ bUseStateNext = Opt::baseopt.bUseStateNext;
+ bUseYYFill = Opt::baseopt.bUseYYFill;
+ bUseYYFillParam = Opt::baseopt.bUseYYFillParam;
+ bUseYYFillCheck = Opt::baseopt.bUseYYFillCheck;
+ bUseYYFillNaked = Opt::baseopt.bUseYYFillNaked;
+ bUseYYSetConditionParam = Opt::baseopt.bUseYYSetConditionParam;
+ bUseYYGetConditionNaked = Opt::baseopt.bUseYYGetConditionNaked;
+ bUseYYSetStateParam = Opt::baseopt.bUseYYSetStateParam;
+ bUseYYSetStateNaked = Opt::baseopt.bUseYYSetStateNaked;
+ bUseYYGetStateNaked = Opt::baseopt.bUseYYGetStateNaked;
+ yybmHexTable = Opt::baseopt.yybmHexTable;
+ bUseStateAbort = Opt::baseopt.bUseStateAbort;
+ cGotoThreshold = Opt::baseopt.cGotoThreshold;
+ topIndent = Opt::baseopt.topIndent;
+ indString = Opt::baseopt.indString;
+ labelPrefix = Opt::baseopt.labelPrefix;
+ condPrefix = Opt::baseopt.condPrefix;
+ condEnumPrefix = Opt::baseopt.condEnumPrefix;
+ condDivider = Opt::baseopt.condDivider;
+ condDividerParam = Opt::baseopt.condDividerParam;
+ condGoto = Opt::baseopt.condGoto;
+ condGotoParam = Opt::baseopt.condGotoParam;
+ yychConversion = Opt::baseopt.yychConversion;
+ yyFillLength = Opt::baseopt.yyFillLength;
+ yySetConditionParam = Opt::baseopt.yySetConditionParam;
+ yySetStateParam = Opt::baseopt.yySetStateParam;
+ mapCodeName = Opt::baseopt.mapCodeName;
+ input_api = Opt::baseopt.input_api;
}
if (flag_skeleton)
{
- dFlag = baseopt.dFlag;
- fFlag = baseopt.fFlag;
- iFlag = baseopt.iFlag;
- tFlag = baseopt.tFlag;
- header_file = baseopt.header_file;
- bEmitYYCh = baseopt.bEmitYYCh;
- bUseStateNext = baseopt.bUseStateNext;
- bUseYYFill = baseopt.bUseYYFill;
- bUseYYFillParam = baseopt.bUseYYFillParam;
- bUseYYFillCheck = baseopt.bUseYYFillCheck;
- bUseYYFillNaked = baseopt.bUseYYFillNaked;
- bUseYYSetConditionParam = baseopt.bUseYYSetConditionParam;
- bUseYYGetConditionNaked = baseopt.bUseYYGetConditionNaked;
- bUseYYSetStateParam = baseopt.bUseYYSetStateParam;
- bUseYYSetStateNaked = baseopt.bUseYYSetStateNaked;
- bUseYYGetStateNaked = baseopt.bUseYYGetStateNaked;
- bUseStateAbort = baseopt.bUseStateAbort;
- topIndent = baseopt.topIndent;
- indString = baseopt.indString;
- labelPrefix = baseopt.labelPrefix;
- condPrefix = baseopt.condPrefix;
- condEnumPrefix = baseopt.condEnumPrefix;
- condDivider = baseopt.condDivider;
- condDividerParam = baseopt.condDividerParam;
- condGoto = baseopt.condGoto;
- condGotoParam = baseopt.condGotoParam;
- yychConversion = baseopt.yychConversion;
- yyFillLength = baseopt.yyFillLength;
- yySetConditionParam = baseopt.yySetConditionParam;
- yySetStateParam = baseopt.yySetStateParam;
- mapCodeName = baseopt.mapCodeName;
- input_api = baseopt.input_api;
+ dFlag = Opt::baseopt.dFlag;
+ fFlag = Opt::baseopt.fFlag;
+ iFlag = Opt::baseopt.iFlag;
+ tFlag = Opt::baseopt.tFlag;
+ header_file = Opt::baseopt.header_file;
+ bEmitYYCh = Opt::baseopt.bEmitYYCh;
+ bUseStateNext = Opt::baseopt.bUseStateNext;
+ bUseYYFill = Opt::baseopt.bUseYYFill;
+ bUseYYFillParam = Opt::baseopt.bUseYYFillParam;
+ bUseYYFillCheck = Opt::baseopt.bUseYYFillCheck;
+ bUseYYFillNaked = Opt::baseopt.bUseYYFillNaked;
+ bUseYYSetConditionParam = Opt::baseopt.bUseYYSetConditionParam;
+ bUseYYGetConditionNaked = Opt::baseopt.bUseYYGetConditionNaked;
+ bUseYYSetStateParam = Opt::baseopt.bUseYYSetStateParam;
+ bUseYYSetStateNaked = Opt::baseopt.bUseYYSetStateNaked;
+ bUseYYGetStateNaked = Opt::baseopt.bUseYYGetStateNaked;
+ bUseStateAbort = Opt::baseopt.bUseStateAbort;
+ topIndent = Opt::baseopt.topIndent;
+ indString = Opt::baseopt.indString;
+ labelPrefix = Opt::baseopt.labelPrefix;
+ condPrefix = Opt::baseopt.condPrefix;
+ condEnumPrefix = Opt::baseopt.condEnumPrefix;
+ condDivider = Opt::baseopt.condDivider;
+ condDividerParam = Opt::baseopt.condDividerParam;
+ condGoto = Opt::baseopt.condGoto;
+ condGotoParam = Opt::baseopt.condGotoParam;
+ yychConversion = Opt::baseopt.yychConversion;
+ yyFillLength = Opt::baseopt.yyFillLength;
+ yySetConditionParam = Opt::baseopt.yySetConditionParam;
+ yySetStateParam = Opt::baseopt.yySetStateParam;
+ mapCodeName = Opt::baseopt.mapCodeName;
+ input_api = Opt::baseopt.input_api;
}
if (bCaseInsensitive)
{
- bCaseInverted = baseopt.bCaseInverted;
+ bCaseInverted = Opt::baseopt.bCaseInverted;
}
if (!cFlag)
{
- tFlag = baseopt.tFlag;
- header_file = baseopt.header_file;
- bUseYYSetConditionParam = baseopt.bUseYYSetConditionParam;
- bUseYYGetConditionNaked = baseopt.bUseYYGetConditionNaked;
- condPrefix = baseopt.condPrefix;
- condEnumPrefix = baseopt.condEnumPrefix;
- condDivider = baseopt.condDivider;
- condDividerParam = baseopt.condDividerParam;
- condGoto = baseopt.condGoto;
- condGotoParam = baseopt.condGotoParam;
- yySetConditionParam = baseopt.yySetConditionParam;
+ tFlag = Opt::baseopt.tFlag;
+ header_file = Opt::baseopt.header_file;
+ bUseYYSetConditionParam = Opt::baseopt.bUseYYSetConditionParam;
+ bUseYYGetConditionNaked = Opt::baseopt.bUseYYGetConditionNaked;
+ condPrefix = Opt::baseopt.condPrefix;
+ condEnumPrefix = Opt::baseopt.condEnumPrefix;
+ condDivider = Opt::baseopt.condDivider;
+ condDividerParam = Opt::baseopt.condDividerParam;
+ condGoto = Opt::baseopt.condGoto;
+ condGotoParam = Opt::baseopt.condGotoParam;
+ yySetConditionParam = Opt::baseopt.yySetConditionParam;
mapCodeName.erase ("YYCONDTYPE");
mapCodeName.erase ("YYGETCONDITION");
mapCodeName.erase ("YYSETCONDITION");
}
if (!fFlag)
{
- bUseStateNext = baseopt.bUseStateNext;
- bUseYYSetStateParam = baseopt.bUseYYSetStateParam;
- bUseYYSetStateNaked = baseopt.bUseYYSetStateNaked;
- bUseYYGetStateNaked = baseopt.bUseYYGetStateNaked;
- bUseStateAbort = baseopt.bUseStateAbort;
- yySetStateParam = baseopt.yySetStateParam;
+ bUseStateNext = Opt::baseopt.bUseStateNext;
+ bUseYYSetStateParam = Opt::baseopt.bUseYYSetStateParam;
+ bUseYYSetStateNaked = Opt::baseopt.bUseYYSetStateNaked;
+ bUseYYGetStateNaked = Opt::baseopt.bUseYYGetStateNaked;
+ bUseStateAbort = Opt::baseopt.bUseStateAbort;
+ yySetStateParam = Opt::baseopt.yySetStateParam;
mapCodeName.erase ("YYGETSTATE");
mapCodeName.erase ("YYSETSTATE");
mapCodeName.erase ("yyaccept");
}
if (!bFlag)
{
- yybmHexTable = baseopt.yybmHexTable;
+ yybmHexTable = Opt::baseopt.yybmHexTable;
mapCodeName.erase ("yybm");
}
if (!gFlag)
{
- cGotoThreshold = baseopt.cGotoThreshold;
+ cGotoThreshold = Opt::baseopt.cGotoThreshold;
mapCodeName.erase ("yytarget");
}
if (input_api.type () != InputAPI::DEFAULT)
bFlag = true;
sFlag = true;
}
+}
- return true;
+const opt_t Opt::baseopt;
+
+bool Opt::check ()
+{
+ return useropt.check ();
+}
+
+void Opt::sync ()
+{
+ realopt = useropt;
+ realopt.fix ();
}
void Opt::bit_vectors ()
return useropt.encoding.set(Enc::UTF8);
}
+bool Opt::sync_mapCodeName (const std::string & key, const std::string & val)
+{
+ if (!useropt.mapCodeName.insert (std::make_pair (key, val)).second)
+ {
+ return false;
+ }
+ sync ();
+ return true;
+}
+
+void Opt::sync_condPrefix (const std::string & s)
+{
+ useropt.condPrefix = s;
+ sync ();
+}
+
+void Opt::sync_condEnumPrefix (const std::string & s)
+{
+ useropt.condEnumPrefix = s;
+ sync ();
+}
+
+void Opt::sync_condDivider (const std::string & s)
+{
+ useropt.condDivider = s;
+ sync ();
+}
+
+void Opt::sync_condDividerParam (const std::string & s)
+{
+ useropt.condDividerParam = s;
+ sync ();
+}
+
+void Opt::sync_condGoto (const std::string & s)
+{
+ useropt.condGoto = s;
+ sync ();
+}
+
+void Opt::sync_condGotoParam (const std::string & s)
+{
+ useropt.condGotoParam = s;
+ sync ();
+}
+
+void Opt::sync_cGotoThreshold (uint32_t n)
+{
+ useropt.cGotoThreshold = n;
+ sync ();
+}
+
+void Opt::sync_bUseYYFillNaked (bool b)
+{
+ useropt.bUseYYFillNaked = b;
+ sync ();
+}
+
+void Opt::sync_yyFillLength (const std::string & s)
+{
+ useropt.yyFillLength = s;
+ useropt.bUseYYFillParam = false;
+ sync ();
+}
+
+void Opt::sync_bUseYYGetConditionNaked (bool b)
+{
+ useropt.bUseYYGetConditionNaked = b;
+ sync ();
+}
+
+void Opt::sync_bUseYYGetStateNaked (bool b)
+{
+ useropt.bUseYYGetStateNaked = b;
+ sync ();
+}
+
+void Opt::sync_yySetConditionParam (const std::string & s)
+{
+ useropt.yySetConditionParam = s;
+ useropt.bUseYYSetConditionParam = false;
+ sync ();
+}
+
+void Opt::sync_bUseYYSetStateNaked (bool b)
+{
+ useropt.bUseYYSetStateNaked = b;
+ sync ();
+}
+
+void Opt::sync_yySetStateParam (const std::string & s)
+{
+ useropt.yySetStateParam = s;
+ useropt.bUseYYSetStateParam = false;
+ sync ();
+}
+
+bool Opt::sync_encoding (Enc::type_t t)
+{
+ if (!useropt.encoding.set (t))
+ {
+ return false;
+ }
+ sync ();
+ return true;
+}
+
+void Opt::sync_encoding_unset (Enc::type_t t)
+{
+ useropt.encoding.unset (t);
+ sync ();
+}
+
+void Opt::sync_indString (const std::string & s)
+{
+ useropt.indString = s;
+ sync ();
+}
+
+void Opt::sync_topIndent (uint32_t n)
+{
+ useropt.topIndent = n;
+ sync ();
+}
+
+void Opt::sync_labelPrefix (const std::string & s)
+{
+ useropt.labelPrefix = s;
+ sync ();
+}
+
+void Opt::sync_bUseStateAbort (bool b)
+{
+ useropt.bUseStateAbort = b;
+ sync ();
+}
+
+void Opt::sync_bUseStateNext (bool b)
+{
+ useropt.bUseStateNext = b;
+ sync ();
+}
+
+void Opt::sync_yybmHexTable (bool b)
+{
+ useropt.yybmHexTable = b;
+ sync ();
+}
+
+void Opt::sync_yychConversion (bool b)
+{
+ useropt.yychConversion = b;
+ sync ();
+}
+
+void Opt::sync_bEmitYYCh (bool b)
+{
+ useropt.bEmitYYCh = b;
+ sync ();
+}
+
+void Opt::sync_bUseYYFillCheck (bool b)
+{
+ useropt.bUseYYFillCheck = b;
+ sync ();
+}
+
+void Opt::sync_bUseYYFill (bool b)
+{
+ useropt.bUseYYFill = b;
+ sync ();
+}
+
+void Opt::sync_bUseYYFillParam (bool b)
+{
+ useropt.bUseYYFillParam = b;
+ sync ();
+}
+
+void Opt::sync_reset_encoding (const Enc & enc)
+{
+ useropt.encoding = enc;
+ sync ();
+}
+
+void Opt::sync_reset_mapCodeName ()
+{
+ useropt.mapCodeName.clear ();
+ sync ();
+}
+
} // namespace re2c
bool flag_skeleton;
bool bNoGenerationDate;
bool bEmitYYCh;
+ bool yychConversion;
bool bUseStateNext;
bool bUseYYFill;
bool bUseYYFillParam;
std::string condDividerParam;
std::string condGoto;
std::string condGotoParam;
- std::string yychConversion;
std::string yyFillLength;
std::string yySetConditionParam;
std::string yySetStateParam;
opt_t ();
opt_t (const opt_t & opt);
opt_t & operator = (const opt_t & opt);
+ bool check ();
+ void fix ();
};
-struct Opt : public opt_t
+struct Opt
{
+ static const opt_t baseopt;
+
const char * source_file;
const char * output_file;
private:
- const opt_t baseopt;
opt_t useropt;
+ opt_t realopt;
public:
Opt ()
- : opt_t ()
- , source_file (NULL)
+ : source_file (NULL)
, output_file (NULL)
- , baseopt ()
, useropt ()
+ , realopt ()
{}
- bool apply ();
+ bool check ();
+ void sync ();
void bit_vectors ();
void start_conditions ();
bool utf_16 ();
bool utf_8 ();
+ // Inplace configurations are applied immediately when parsed.
+ // This is very bad: first, re2c behaviour is changed in the middle
+ // of the block; second, we have to re-sync config every time.
+ bool sync_mapCodeName (const std::string & key, const std::string & val);
+ bool sync_encoding (Enc::type_t t);
+ void sync_encoding_unset (Enc::type_t t);
+ void sync_condPrefix (const std::string & s);
+ void sync_condEnumPrefix (const std::string & s);
+ void sync_condDivider (const std::string & s);
+ void sync_condDividerParam (const std::string & s);
+ void sync_condGoto (const std::string & s);
+ void sync_condGotoParam (const std::string & s);
+ void sync_cGotoThreshold (uint32_t n);
+ void sync_bUseYYFillNaked (bool b);
+ void sync_yyFillLength (const std::string & s);
+ void sync_bUseYYGetConditionNaked (bool b);
+ void sync_bUseYYGetStateNaked (bool b);
+ void sync_yySetConditionParam (const std::string & s);
+ void sync_bUseYYSetStateNaked (bool b);
+ void sync_yySetStateParam (const std::string & s);
+ void sync_indString (const std::string & s);
+ void sync_topIndent (uint32_t n);
+ void sync_labelPrefix (const std::string & s);
+ void sync_bUseStateAbort (bool b);
+ void sync_bUseStateNext (bool b);
+ void sync_yybmHexTable (bool b);
+ void sync_yychConversion (bool b);
+ void sync_bEmitYYCh (bool b);
+ void sync_bUseYYFillCheck (bool b);
+ void sync_bUseYYFill (bool b);
+ void sync_bUseYYFillParam (bool b);
+ // bad temporary hacks
+ // should be fixed by proper scoping in config (parts).
+ void sync_reset_encoding (const Enc & enc);
+ void sync_reset_mapCodeName ();
+
+ bool bFlag () const { return realopt.bFlag; }
+ bool cFlag () const { return realopt.cFlag; }
+ bool dFlag () const { return realopt.dFlag; }
+ bool DFlag () const { return realopt.DFlag; }
+ bool fFlag () const { return realopt.fFlag; }
+ bool FFlag () const { return realopt.FFlag; }
+ bool gFlag () const { return realopt.gFlag; }
+ bool iFlag () const { return realopt.iFlag; }
+ bool rFlag () const { return realopt.rFlag; }
+ bool sFlag () const { return realopt.sFlag; }
+ bool tFlag () const { return realopt.tFlag; }
+ const char * header_file () const { return realopt.header_file; }
+ bool flag_skeleton () const { return realopt.flag_skeleton; }
+ bool bNoGenerationDate () const { return realopt.bNoGenerationDate; }
+ bool bEmitYYCh () const { return realopt.bEmitYYCh; }
+ std::string yychConversion () const
+ {
+ return realopt.yychConversion
+ ? "(" + realopt.mapCodeName["YYCTYPE"] + ")"
+ : "";
+ }
+ bool bUseStateNext () const { return realopt.bUseStateNext; }
+ bool bUseYYFill () const { return realopt.bUseYYFill; }
+ bool bUseYYFillParam () const { return realopt.bUseYYFillParam; }
+ bool bUseYYFillCheck () const { return realopt.bUseYYFillCheck; }
+ bool bUseYYFillNaked () const { return realopt.bUseYYFillNaked; }
+ bool bUseYYSetConditionParam () const { return realopt.bUseYYSetConditionParam; }
+ bool bUseYYGetConditionNaked () const { return realopt.bUseYYGetConditionNaked; }
+ bool bUseYYSetStateParam () const { return realopt.bUseYYSetStateParam; }
+ bool bUseYYSetStateNaked () const { return realopt.bUseYYSetStateNaked; }
+ bool bUseYYGetStateNaked () const { return realopt.bUseYYGetStateNaked; }
+ bool yybmHexTable () const { return realopt.yybmHexTable; }
+ bool bUseStateAbort () const { return realopt.bUseStateAbort; }
+ bool bCaseInsensitive () const { return realopt.bCaseInsensitive; }
+ bool bCaseInverted () const { return realopt.bCaseInverted; }
+ uint32_t cGotoThreshold () const { return realopt.cGotoThreshold; }
+ uint32_t topIndent () const { return realopt.topIndent; }
+ const std::string & indString () const { return realopt.indString; }
+ const std::string & labelPrefix () const { return realopt.labelPrefix; }
+ const std::string & condPrefix () const { return realopt.condPrefix; }
+ const std::string & condEnumPrefix () const { return realopt.condEnumPrefix; }
+ const std::string & condDivider () const { return realopt.condDivider; }
+ const std::string & condDividerParam () const { return realopt.condDividerParam; }
+ const std::string & condGoto () const { return realopt.condGoto; }
+ const std::string & condGotoParam () const { return realopt.condGotoParam; }
+ const std::string & yyFillLength () const { return realopt.yyFillLength; }
+ const std::string & yySetConditionParam () const { return realopt.yySetConditionParam; }
+ const std::string & yySetStateParam () const { return realopt.yySetStateParam; }
+ const CodeNames & mapCodeName () const { return realopt.mapCodeName; }
+ const Enc & encoding () const { return realopt.encoding; }
+ const InputAPI & input_api () const { return realopt.input_api; }
+ empty_class_policy_t empty_class_policy () const { return realopt.empty_class_policy; }
+
FORBID_COPY (Opt);
};
*/
end:
- if (!opts.apply ())
+ if (!opts.check ())
{
return EXIT_FAIL;
}
+ opts.sync ();
if (!opts.source_file)
{
RegExp * Scanner::matchSymbol(uint32_t c) const
{
- if (!opts.encoding.encode(c))
+ if (!opts.encoding ().encode(c))
fatalf("Bad code point: '0x%X'", c);
- switch (opts.encoding.type ())
+ switch (opts.encoding ().type ())
{
case Enc::UTF16: return UTF16Symbol(c);
case Enc::UTF8: return UTF8Symbol(c);
{
if (!r)
{
- switch (opts.empty_class_policy)
+ switch (opts.empty_class_policy ())
{
case EMPTY_CLASS_MATCH_EMPTY:
warn.empty_class (get_line ());
}
}
- switch (opts.encoding.type ())
+ switch (opts.encoding ().type ())
{
case Enc::UTF16: return UTF16Range(r);
case Enc::UTF8: return UTF8Range(r);
warn.swapped_range (get_line (), l, u);
std::swap (l, u);
}
- Range * s = opts.encoding.encodeRange (l, u);
+ Range * s = opts.encoding ().encodeRange (l, u);
if (!s)
{
fatalf ("Bad code point range: '0x%X - 0x%X'", l, u);
}
if (neg)
{
- r = Range::sub (opts.encoding.fullRange (), r);
+ r = Range::sub (opts.encoding ().fullRange (), r);
}
return matchSymbolRange (r);
}
RegExp * Scanner::mkDot() const
{
- Range * full = opts.encoding.fullRange();
+ Range * full = opts.encoding ().fullRange();
uint32_t c = '\n';
- if (!opts.encoding.encode(c))
+ if (!opts.encoding ().encode(c))
fatalf("Bad code point: '0x%X'", c);
Range * ran = Range::sym (c);
Range * inv = Range::sub (full, ran);
*/
RegExp * Scanner::mkDefault() const
{
- Range * def = Range::ran (0, opts.encoding.nCodeUnits());
+ Range * def = Range::ran (0, opts.encoding ().nCodeUnits());
return new MatchOp(def);
}
}
// set up the output streams
- re2c::Output output (opts.output_file, opts.header_file);
+ re2c::Output output (opts.output_file, opts.header_file ());
if (!output.source.open ())
{
error ("cannot open output file: %s", opts.output_file);
return 1;
}
- if (opts.tFlag && !output.header.open ())
+ if (opts.tFlag () && !output.header.open ())
{
- error ("cannot open header file: %s", opts.header_file);
+ error ("cannot open header file: %s", opts.header_file ());
return 1;
}
void context_check(CondList *clist)
{
- if (!opts.cFlag)
+ if (!opts.cFlag ())
{
delete clist;
in->fatal("conditions are only allowed when using -c switch");
}
| CONF STRING ';'
{
- if (!opts.mapCodeName.insert (std::make_pair (*$1, *$2)).second)
+ if (!opts.sync_mapCodeName (*$1, *$2))
{
in->fatalf ("configuration '%s' is already set and cannot be changed", $1->c_str ());
}
}
| CONF_CONDPREFIX STRING ';'
{
- opts.condPrefix = *$2;
+ opts.sync_condPrefix (*$2);
delete $2;
}
| CONF_CONDENUMPREFIX STRING ';'
{
- opts.condEnumPrefix = *$2;
+ opts.sync_condEnumPrefix (*$2);
delete $2;
}
| CONF_COND_DIVIDER STRING ';'
{
- opts.condDivider = *$2;
+ opts.sync_condDivider (*$2);
delete $2;
}
| CONF_COND_DIVIDER_COND STRING ';'
{
- opts.condDividerParam = *$2;
+ opts.sync_condDividerParam (*$2);
delete $2;
}
| CONF_COND_GOTO STRING ';'
{
- opts.condGoto = *$2;
+ opts.sync_condGoto (*$2);
delete $2;
}
| CONF_COND_GOTO_COND STRING ';'
{
- opts.condGotoParam = *$2;
+ opts.sync_condGotoParam (*$2);
delete $2;
}
| CONF_CGOTO_THRESHOLD NUM ';'
{
in->fatal ("configuration 'cgoto:threshold' must be nonnegative");
}
- opts.cGotoThreshold = static_cast<uint32_t> ($2);
+ opts.sync_cGotoThreshold (static_cast<uint32_t> ($2));
}
| CONF_DEFINE_YYFILL_NAKED NUM ';'
{
- opts.bUseYYFillNaked = $2 != 0;
+ opts.sync_bUseYYFillNaked ($2 != 0);
}
| CONF_DEFINE_YYFILL_LEN STRING ';'
{
- opts.yyFillLength = *$2;
- opts.bUseYYFillParam = false;
+ opts.sync_yyFillLength (*$2);
delete $2;
}
| CONF_DEFINE_YYGETCONDITION_NAKED NUM ';'
{
- opts.bUseYYGetConditionNaked = $2 != 0;
+ opts.sync_bUseYYGetConditionNaked ($2 != 0);
}
| CONF_DEFINE_YYGETSTATE_NAKED NUM ';'
{
- opts.bUseYYGetStateNaked = $2 != 0;
+ opts.sync_bUseYYGetStateNaked ($2 != 0);
}
| CONF_DEFINE_YYSETCONDITION_COND STRING ';'
{
- opts.yySetConditionParam = *$2;
- opts.bUseYYSetConditionParam = false;
+ opts.sync_yySetConditionParam (*$2);
delete $2;
}
| CONF_DEFINE_YYSETSTATE_NAKED NUM ';'
{
- opts.bUseYYSetStateNaked = $2 != 0;
+ opts.sync_bUseYYSetStateNaked ($2 != 0);
}
| CONF_DEFINE_YYSETSTATE_STATE STRING ';'
{
- opts.yySetStateParam = *$2;
- opts.bUseYYSetStateParam = false;
+ opts.sync_yySetStateParam (*$2);
delete $2;
}
| CONF_FLAGS NUM ';'
{
if ($2 == 0)
{
- opts.encoding.unset ($1);
+ opts.sync_encoding_unset ($1);
}
- else if (!opts.encoding.set ($1))
+ else if (!opts.sync_encoding ($1))
{
in->fatalf ("Cannot set %s encoding: please reset %s encoding first"
, Enc::name ($1)
- , Enc::name (opts.encoding.type ()));
+ , Enc::name (opts.encoding ().type ()));
}
}
| CONF_INDENT_STRING STRING ';'
{
- opts.indString = *$2;
+ opts.sync_indString (*$2);
delete $2;
}
| CONF_INDENT_TOP NUM ';'
{
in->fatal ("configuration 'indent:top' must be nonnegative");
}
- opts.topIndent = static_cast<uint32_t> ($2);
+ opts.sync_topIndent (static_cast<uint32_t> ($2));
}
| CONF_LABELPREFIX STRING ';'
{
- opts.labelPrefix = *$2;
+ opts.sync_labelPrefix (*$2);
delete $2;
}
| CONF_STARTLABEL NUM ';'
}
| CONF_STATE_ABORT NUM ';'
{
- opts.bUseStateAbort = $2 != 0;
+ opts.sync_bUseStateAbort ($2 != 0);
}
| CONF_STATE_NEXTLABEL NUM ';'
{
- opts.bUseStateNext = $2 != 0;
+ opts.sync_bUseStateNext ($2 != 0);
}
| CONF_YYBM_HEX NUM ';'
{
- opts.yybmHexTable = $2 != 0;
+ opts.sync_yybmHexTable ($2 != 0);
}
| CONF_YYCH_CONVERSION NUM ';'
{
- opts.yychConversion = $2 == 0
- ? ""
- : "(" + opts.mapCodeName["YYCTYPE"] + ")";
+ opts.sync_yychConversion ($2 != 0);
}
| CONF_YYCH_EMIT NUM ';'
{
- opts.bEmitYYCh = $2 != 0;
+ opts.sync_bEmitYYCh ($2 != 0);
}
| CONF_YYFILL_CHECK NUM ';'
{
- opts.bUseYYFillCheck = $2 != 0;
+ opts.sync_bUseYYFillCheck ($2 != 0);
}
| CONF_YYFILL_ENABLE NUM ';'
{
- opts.bUseYYFill = $2 != 0;
+ opts.sync_bUseYYFill ($2 != 0);
}
| CONF_YYFILL_PARAMETER NUM ';'
{
- opts.bUseYYFillParam = $2 != 0;
+ opts.sync_bUseYYFillParam ($2 != 0);
}
;
rule:
expr look CODE
{
- if (opts.cFlag)
+ if (opts.cFlag ())
{
in->fatal("condition or '<*>' required when using -c switch");
}
}
| STAR CODE /* default rule */
{
- if (opts.cFlag)
+ if (opts.cFlag ())
in->fatal("condition or '<*>' required when using -c switch");
if (ruleDefault != NULL)
in->fatal("code to default rule is already defined");
o.source.write_version_time ();
o.source.write_line_info (in->get_cline (), in->get_fname ().c_str ());
- if (opts.flag_skeleton)
+ if (opts.flag_skeleton ())
{
Skeleton::emit_prolog (o.source);
}
- Enc encodingOld = opts.encoding;
+ Enc encodingOld = opts.encoding ();
while ((parseMode = i.echo()) != Scanner::Stop)
{
i.save_state(curr_state);
foundRules = false;
- if (opts.rFlag && parseMode == Scanner::Rules && dfa_map.size())
+ if (opts.rFlag () && parseMode == Scanner::Rules && dfa_map.size())
{
in->fatal("cannot have a second 'rules:re2c' block");
}
in->set_in_parse(true);
yyparse();
in->set_in_parse(false);
- if (opts.rFlag && parseMode == Scanner::Reuse)
+ if (opts.rFlag () && parseMode == Scanner::Reuse)
{
- if (foundRules || opts.encoding != encodingOld)
+ if (foundRules || opts.encoding () != encodingOld)
{
// Re-parse rules
parseMode = Scanner::Parse;
yyparse();
in->set_in_parse(false);
}
- encodingOld = opts.encoding;
+ encodingOld = opts.encoding ();
}
o.source.set_block_line (in->get_cline ());
- if (opts.cFlag)
+ uint32_t ind = opts.topIndent ();
+ if (opts.cFlag ())
{
RegExpMap::iterator it;
SetupMap::const_iterator itRuleSetup;
it->second = it->second ? mkAlt (def_rule, it->second) : def_rule;
}
- dfa_map[it->first] = genCode(it->second, o, it->first, opts.encoding.nCodeUnits ());
+ dfa_map[it->first] = genCode(it->second, o, it->first, opts.encoding ().nCodeUnits ());
}
if (parseMode != Scanner::Rules && dfa_map.find(it->first) != dfa_map.end())
{
- dfa_map[it->first]->emit(o, opts.topIndent, !--nCount, bPrologBrace);
+ dfa_map[it->first]->emit(o, ind, !--nCount, bPrologBrace);
}
}
}
{
if (parseMode != Scanner::Reuse)
{
- dfa_map[""] = genCode(spec, o, "", opts.encoding.nCodeUnits ());
+ dfa_map[""] = genCode(spec, o, "", opts.encoding ().nCodeUnits ());
}
if (parseMode != Scanner::Rules && dfa_map.find("") != dfa_map.end())
{
- dfa_map[""]->emit(o, opts.topIndent, 0, bPrologBrace);
+ dfa_map[""]->emit(o, ind, 0, bPrologBrace);
}
}
}
o.source.write_line_info (in->get_cline (), in->get_fname ().c_str ());
/* restore original char handling mode*/
- opts.encoding = encodingOld;
+ opts.sync_reset_encoding (encodingOld);
}
- if (opts.cFlag)
+ if (opts.cFlag ())
{
SetupMap::const_iterator itRuleSetup;
for (itRuleSetup = ruleSetupMap.begin(); itRuleSetup != ruleSetupMap.end(); ++itRuleSetup)
}
}
- if (opts.flag_skeleton)
+ if (opts.flag_skeleton ())
{
Skeleton::emit_epilog (o.source, o.names);
}
{
/* Do not get rid of anything when rFlag is active. Otherwise
* get rid of everything that was already handedout. */
- if (!opts.rFlag)
+ if (!opts.rFlag ())
{
const ptrdiff_t diff = tok - bot;
if (diff > 0)
last_fill_index = 0;
bWroteGetState = false;
bWroteCondCheck = false;
- opts.mapCodeName.clear();
+ opts.sync_reset_mapCodeName ();
}
void Scanner::restore_state(const ScannerState& state)
/*!re2c
beginRE = "%{" | "/*!re2c";
beginRE {
- if (opts.rFlag)
+ if (opts.rFlag ())
{
fatal("found standard 're2c' block while using -r flag");
}
- if (!(opts.DFlag || opts.flag_skeleton))
+ if (!(opts.DFlag () || opts.flag_skeleton ()))
{
const size_t lexeme_len = cur[-1] == '{'
? sizeof ("%{") - 1
return Parse;
}
"/*!rules:re2c" {
- if (opts.rFlag)
+ if (opts.rFlag ())
{
- opts.mapCodeName.clear();
+ opts.sync_reset_mapCodeName ();
}
else
{
return Rules;
}
"/*!use:re2c" {
- if (!opts.rFlag)
+ if (!opts.rFlag ())
{
fatal("found 'use:re2c' block without -r flag");
}
reuse();
- if (!(opts.DFlag || opts.flag_skeleton))
+ if (!(opts.DFlag () || opts.flag_skeleton ()))
{
const size_t lexeme_len = sizeof ("/*!use:re2c") - 1;
out.write(tok, tok_len () - lexeme_len);
return Reuse;
}
"/*!max:re2c" {
- if (!opts.DFlag)
+ if (!opts.DFlag ())
{
out.insert_yymaxfill ();
}
}
"/*!getstate:re2c" {
tok = pos = cur;
- out.insert_state_goto (opts.topIndent);
+ out.insert_state_goto (opts.topIndent ());
ignore_eoc = true;
goto echo;
}
"/*!types:re2c" {
tok = pos = cur;
ignore_eoc = true;
- if (!opts.DFlag)
+ if (!opts.DFlag ())
{
out.insert_line_info ();
out << "\n";
ignore_eoc = false;
ignore_cnt = 0;
}
- else if (!(opts.DFlag || opts.flag_skeleton))
+ else if (!(opts.DFlag () || opts.flag_skeleton ()))
{
out.write(tok, tok_len ());
}
ignore_eoc = false;
ignore_cnt = 0;
}
- else if (!(opts.DFlag || opts.flag_skeleton))
+ else if (!(opts.DFlag () || opts.flag_skeleton ()))
{
out.write(tok, tok_len ());
}
{
ignore_cnt++;
}
- else if (!(opts.DFlag || opts.flag_skeleton))
+ else if (!(opts.DFlag () || opts.flag_skeleton ()))
{
out.write(tok, tok_len ());
}
goto echo;
}
zero {
- if (!(ignore_eoc || opts.DFlag || opts.flag_skeleton))
+ if (!(ignore_eoc || opts.DFlag () || opts.flag_skeleton ()))
{
out.write(tok, tok_len () - 1);
// -1 so we don't write out the \0
{
std::vector<uint32_t> cpoints;
lex_cpoints ('\'', cpoints);
- yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive || !opts.bCaseInverted);
+ yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive () || !opts.bCaseInverted ());
return REGEXP;
}
"\""
{
std::vector<uint32_t> cpoints;
lex_cpoints ('"', cpoints);
- yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive || opts.bCaseInverted);
+ yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive () || opts.bCaseInverted ());
return REGEXP;
}
"["
}
"{" name "}" {
- if (!opts.FFlag) {
+ if (!opts.FFlag ()) {
fatal("curly braces for names only allowed with -F switch");
}
yylval.str = new std::string (tok + 1, tok_len () - 2); // -2 to omit braces
name / (space+ [^=>,]) {
yylval.str = new std::string (tok, tok_len ());
- if (opts.FFlag)
+ if (opts.FFlag ())
{
lexer_state = LEX_FLEX_NAME;
return FID;
}
name / [^] {
- if (!opts.FFlag) {
+ if (!opts.FFlag ()) {
yylval.str = new std::string (tok, tok_len ());
return ID;
} else {
{
cpoints.push_back (static_cast<uint8_t> (*p));
}
- yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive || opts.bCaseInverted);
+ yylval.regexp = cpoint_string (cpoints, opts.bCaseInsensitive () || opts.bCaseInverted ());
return REGEXP;
}
}