1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2026-03-19 09:47:20 +01:00

minimal grammar to match "from" and "to", both addresses and ports

This commit is contained in:
Vadim Kurland 2011-05-22 23:17:05 -07:00
parent 9be69950eb
commit 12abcf9533
10 changed files with 3178 additions and 785 deletions

View File

@ -83,6 +83,27 @@ PFImporter::~PFImporter()
void PFImporter::clear()
{
rule_type = NATRule::Unknown;
quick = false;
direction = "";
iface = "";
address_family = "";
proto_list.clear();
src_group.clear();
dst_group.clear();
src_neg = false;
dst_neg = false;
tmp_neg = false;
tmp_port_def = "";
src_port_group.clear();
dst_port_group.clear();
tmp_port_group.clear();
queue = "";
state_op = "";
Importer::clear();
}
@ -211,7 +232,11 @@ void PFImporter::pushRule()
void PFImporter::pushPolicyRule()
{
assert(current_ruleset!=NULL);
if (current_ruleset == NULL)
{
newUnidirRuleSet("filter", libfwbuilder::Policy::TYPENAME );
}
assert(current_rule!=NULL);
// populate all elements of the rule
@ -238,6 +263,13 @@ void PFImporter::pushPolicyRule()
rule->setDirection(PolicyRule::Both);
/*
* Protocols are in proto_list
* Source addresses are in src_group
* Destination addresses are in dst_group
*/
addSrc();
addDst();
addSrv();

View File

@ -46,6 +46,30 @@ class PFImporter : public Importer
public:
std::string direction;
std::string iface;
std::string address_family;
bool quick;
bool src_neg;
bool dst_neg;
bool tmp_neg;
std::list<std::string> proto_list;
std::list<std::pair<std::string, std::string> > src_group;
std::list<std::pair<std::string, std::string> > dst_group;
std::list<std::pair<std::string, std::string> > tmp_group;
// each item in the list is a vector of 2 or 3 strings
// Unary operations are represented by 2 strings, binary operations
// use 3 strings
std::string tmp_port_def;
std::list< std::vector<std::string> > src_port_group;
std::list< std::vector<std::string> > dst_port_group;
std::list< std::vector<std::string> > tmp_port_group;
std::string queue;
std::string state_op;
libfwbuilder::NATRule::NATRuleTypes rule_type;
PFImporter(libfwbuilder::FWObject *lib,

View File

@ -79,27 +79,48 @@ void PFImporter::run()
QRegExp line_continuation("\\\\\\s*\n");
whole_input.replace(line_continuation, "");
QRegExp macro_definition("^\\s*(\\S+)\\s*=\\s*\"(.*)\"$");
QRegExp macro_definition_1("^\\s*(\\S+)\\s*=\\s*\"(.*)\"$");
QRegExp macro_definition_2("^\\s*(\\S+)\\s*=\\s*([^\"]*)$"); // no quotes
QMap<QString, QString> macros;
foreach(QString str, whole_input.split("\n"))
{
if (macro_definition.indexIn(str) != -1)
if (macro_definition_1.indexIn(str) != -1)
{
macros[macro_definition.cap(1)] = macro_definition.cap(2);
macros[macro_definition_1.cap(1)] = macro_definition_1.cap(2);
}
if (macro_definition_2.indexIn(str) != -1)
{
macros[macro_definition_2.cap(1)] = macro_definition_2.cap(2);
}
}
if (fwbdebug)
qDebug() << "Macros defined in this file: " << macros;
// make several passes: sometimes macros can use other macros
int pass = 0;
while (1)
{
bool has_macros = false;
QMapIterator<QString, QString> it(macros);
while (it.hasNext())
{
it.next();
QString macro_name = it.key();
QString macro_value = it.value();
if (whole_input.contains("$" + macro_name))
{
has_macros = true;
whole_input.replace( "$" + macro_name, macro_value);
if (fwbdebug)
qDebug() << "Pass " << pass
<< "Macro substitution: "
<< macro_name << ":" << macro_value;
}
}
if (! has_macros) break;
pass++;
}
if (fwbdebug)

View File

@ -44,47 +44,79 @@ PFCfgLexer::PFCfgLexer(const ANTLR_USE_NAMESPACE(antlr)LexerSharedInputState& st
void PFCfgLexer::initLiterals()
{
literals["host"] = 37;
literals["log"] = 40;
literals["ipinip"] = 28;
literals["icmp6"] = 19;
literals["pcp"] = 32;
literals["interface"] = 16;
literals["disable"] = 49;
literals["gre"] = 25;
literals["exit"] = 13;
literals["nos"] = 30;
literals["udp"] = 21;
literals["tcp"] = 20;
literals["pptp"] = 34;
literals["ospf"] = 31;
literals["ip"] = 17;
literals["no"] = 15;
literals["inactive"] = 50;
literals["esp"] = 24;
literals["igrp"] = 27;
literals["pass"] = 9;
literals["pim"] = 33;
literals["icmp"] = 18;
literals["emergencies"] = 44;
literals["igmp"] = 26;
literals["timeout"] = 7;
literals["range"] = 39;
literals["debugging"] = 43;
literals["drop"] = 10;
literals["eigrp"] = 23;
literals["errors"] = 45;
literals["ah"] = 22;
literals["snp"] = 36;
literals["ipsec"] = 29;
literals["warnings"] = 48;
literals["quit"] = 14;
literals["alerts"] = 41;
literals["any"] = 38;
literals["rip"] = 35;
literals["notifications"] = 47;
literals["critical"] = 42;
literals["informational"] = 46;
literals["vrrp"] = 43;
literals["critical"] = 87;
literals["ospf"] = 41;
literals["rdp"] = 35;
literals["disable"] = 94;
literals["scrub"] = 11;
literals["ipsec"] = 77;
literals["inet"] = 27;
literals["pcp"] = 79;
literals["emergencies"] = 89;
literals["debugging"] = 88;
literals["snp"] = 83;
literals["timeout"] = 15;
literals["to"] = 24;
literals["isis"] = 45;
literals["pptp"] = 81;
literals["pass"] = 16;
literals["no"] = 56;
literals["from"] = 49;
literals["igrp"] = 76;
literals["pim"] = 80;
literals["rsvp"] = 36;
literals["nos"] = 78;
literals["quit"] = 73;
literals["->"] = 96;
literals["exit"] = 72;
literals["modulate"] = 58;
literals["nat"] = 12;
literals["range"] = 85;
literals["out"] = 19;
literals["queue"] = 9;
literals["gre"] = 37;
literals["set"] = 10;
literals["warnings"] = 93;
literals["ah"] = 39;
literals["host"] = 84;
literals["interface"] = 74;
literals["rip"] = 82;
literals["icmp6"] = 75;
literals["notifications"] = 92;
literals["synproxy"] = 59;
literals["!="] = 64;
literals["altq"] = 8;
literals["any"] = 50;
literals["esp"] = 38;
literals["alerts"] = 86;
literals["inet6"] = 28;
literals["inactive"] = 95;
literals["udp"] = 34;
literals["<>"] = 69;
literals["port"] = 63;
literals["ip"] = 30;
literals[">="] = 68;
literals["eigrp"] = 40;
literals["<="] = 66;
literals["errors"] = 90;
literals["ipip"] = 42;
literals["binat"] = 13;
literals["igmp"] = 32;
literals["><"] = 70;
literals["on"] = 26;
literals["state"] = 60;
literals["proto"] = 29;
literals["log"] = 20;
literals["rdr"] = 14;
literals["informational"] = 91;
literals["in"] = 18;
literals["keep"] = 57;
literals["block"] = 17;
literals["l2tp"] = 44;
literals["quick"] = 25;
literals["icmp"] = 31;
literals["tcp"] = 33;
}
ANTLR_USE_NAMESPACE(antlr)RefToken PFCfgLexer::nextToken()
@ -103,7 +135,6 @@ ANTLR_USE_NAMESPACE(antlr)RefToken PFCfgLexer::nextToken()
theRetToken=_returnToken;
break;
}
case 0x24 /* '$' */ :
case 0x30 /* '0' */ :
case 0x31 /* '1' */ :
case 0x32 /* '2' */ :
@ -177,6 +208,12 @@ ANTLR_USE_NAMESPACE(antlr)RefToken PFCfgLexer::nextToken()
theRetToken=_returnToken;
break;
}
case 0x3a /* ':' */ :
{
mCOLON(true);
theRetToken=_returnToken;
break;
}
case 0x22 /* '\"' */ :
{
mSTRING(true);
@ -189,12 +226,6 @@ ANTLR_USE_NAMESPACE(antlr)RefToken PFCfgLexer::nextToken()
theRetToken=_returnToken;
break;
}
case 0x23 /* '#' */ :
{
mNUMBER_SIGN(true);
theRetToken=_returnToken;
break;
}
case 0x25 /* '%' */ :
{
mPERCENT(true);
@ -213,18 +244,6 @@ ANTLR_USE_NAMESPACE(antlr)RefToken PFCfgLexer::nextToken()
theRetToken=_returnToken;
break;
}
case 0x28 /* '(' */ :
{
mOPENING_PAREN(true);
theRetToken=_returnToken;
break;
}
case 0x29 /* ')' */ :
{
mCLOSING_PAREN(true);
theRetToken=_returnToken;
break;
}
case 0x2a /* '*' */ :
{
mSTAR(true);
@ -261,21 +280,9 @@ ANTLR_USE_NAMESPACE(antlr)RefToken PFCfgLexer::nextToken()
theRetToken=_returnToken;
break;
}
case 0x3c /* '<' */ :
{
mLESS_THAN(true);
theRetToken=_returnToken;
break;
}
case 0x3d /* '=' */ :
{
mEQUALS(true);
theRetToken=_returnToken;
break;
}
case 0x3e /* '>' */ :
{
mGREATER_THAN(true);
mEQUAL(true);
theRetToken=_returnToken;
break;
}
@ -291,6 +298,18 @@ ANTLR_USE_NAMESPACE(antlr)RefToken PFCfgLexer::nextToken()
theRetToken=_returnToken;
break;
}
case 0x28 /* '(' */ :
{
mOPENING_PAREN(true);
theRetToken=_returnToken;
break;
}
case 0x29 /* ')' */ :
{
mCLOSING_PAREN(true);
theRetToken=_returnToken;
break;
}
case 0x5b /* '[' */ :
{
mOPENING_SQUARE(true);
@ -303,18 +322,6 @@ ANTLR_USE_NAMESPACE(antlr)RefToken PFCfgLexer::nextToken()
theRetToken=_returnToken;
break;
}
case 0x5e /* '^' */ :
{
mCARET(true);
theRetToken=_returnToken;
break;
}
case 0x5f /* '_' */ :
{
mUNDERLINE(true);
theRetToken=_returnToken;
break;
}
case 0x7b /* '{' */ :
{
mOPENING_BRACE(true);
@ -327,31 +334,53 @@ ANTLR_USE_NAMESPACE(antlr)RefToken PFCfgLexer::nextToken()
theRetToken=_returnToken;
break;
}
case 0x5e /* '^' */ :
{
mCARET(true);
theRetToken=_returnToken;
break;
}
case 0x5f /* '_' */ :
{
mUNDERLINE(true);
theRetToken=_returnToken;
break;
}
case 0x7e /* '~' */ :
{
mTILDE(true);
theRetToken=_returnToken;
break;
}
case 0x21 /* '!' */ :
{
mEXLAMATION(true);
theRetToken=_returnToken;
break;
}
case 0x3c /* '<' */ :
{
mLESS_THAN(true);
theRetToken=_returnToken;
break;
}
case 0x3e /* '>' */ :
{
mGREATER_THAN(true);
theRetToken=_returnToken;
break;
}
default:
if ((LA(1) == 0x21 /* '!' */ ) && ((LA(2) >= 0x3 /* '\3' */ && LA(2) <= 0xff))) {
if ((LA(1) == 0x23 /* '#' */ ) && ((LA(2) >= 0x3 /* '\3' */ && LA(2) <= 0xff))) {
mLINE_COMMENT(true);
theRetToken=_returnToken;
}
else if ((LA(1) == 0x3a /* ':' */ ) && ((LA(2) >= 0x3 /* '\3' */ && LA(2) <= 0xff))) {
mCOLON_COMMENT(true);
theRetToken=_returnToken;
}
else if ((LA(1) == 0x3a /* ':' */ ) && (true)) {
mCOLON(true);
theRetToken=_returnToken;
}
else if ((_tokenSet_0.member(LA(1)))) {
mWhitespace(true);
theRetToken=_returnToken;
}
else if ((LA(1) == 0x21 /* '!' */ ) && (true)) {
mEXLAMATION(true);
else if ((LA(1) == 0x23 /* '#' */ ) && (true)) {
mNUMBER_SIGN(true);
theRetToken=_returnToken;
}
else {
@ -385,11 +414,12 @@ tryAgain:;
}
void PFCfgLexer::mLINE_COMMENT(bool _createToken) {
Tracer traceInOut(this, "mLINE_COMMENT");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = LINE_COMMENT;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match("!");
match("#");
{ // ( ... )*
for (;;) {
if ((_tokenSet_1.member(LA(1)))) {
@ -398,11 +428,11 @@ void PFCfgLexer::mLINE_COMMENT(bool _createToken) {
}
}
else {
goto _loop16;
goto _loop94;
}
}
_loop16:;
_loop94:;
} // ( ... )*
mNEWLINE(false);
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
@ -414,6 +444,7 @@ void PFCfgLexer::mLINE_COMMENT(bool _createToken) {
}
void PFCfgLexer::mNEWLINE(bool _createToken) {
Tracer traceInOut(this, "mNEWLINE");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = NEWLINE;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -434,9 +465,9 @@ void PFCfgLexer::mNEWLINE(bool _createToken) {
}
if ( inputState->guessing==0 ) {
#line 278 "pf.g"
#line 750 "pf.g"
newline();
#line 440 "PFCfgLexer.cpp"
#line 471 "PFCfgLexer.cpp"
}
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
@ -446,50 +477,8 @@ void PFCfgLexer::mNEWLINE(bool _createToken) {
_saveIndex=0;
}
void PFCfgLexer::mCOLON_COMMENT(bool _createToken) {
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = COLON_COMMENT;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
mCOLON(false);
{ // ( ... )*
for (;;) {
if ((_tokenSet_1.member(LA(1)))) {
{
match(_tokenSet_1);
}
}
else {
goto _loop20;
}
}
_loop20:;
} // ( ... )*
mNEWLINE(false);
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
_token->setText(text.substr(_begin, text.length()-_begin));
}
_returnToken = _token;
_saveIndex=0;
}
void PFCfgLexer::mCOLON(bool _createToken) {
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = COLON;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match(':' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
_token->setText(text.substr(_begin, text.length()-_begin));
}
_returnToken = _token;
_saveIndex=0;
}
void PFCfgLexer::mWhitespace(bool _createToken) {
Tracer traceInOut(this, "mWhitespace");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = Whitespace;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -558,9 +547,9 @@ void PFCfgLexer::mWhitespace(bool _createToken) {
}
}
if ( inputState->guessing==0 ) {
#line 273 "pf.g"
#line 745 "pf.g"
_ttype = ANTLR_USE_NAMESPACE(antlr)Token::SKIP;
#line 564 "PFCfgLexer.cpp"
#line 553 "PFCfgLexer.cpp"
}
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
@ -571,6 +560,7 @@ void PFCfgLexer::mWhitespace(bool _createToken) {
}
void PFCfgLexer::mINT_CONST(bool _createToken) {
Tracer traceInOut(this, "mINT_CONST");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = INT_CONST;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -584,6 +574,7 @@ void PFCfgLexer::mINT_CONST(bool _createToken) {
}
void PFCfgLexer::mHEX_CONST(bool _createToken) {
Tracer traceInOut(this, "mHEX_CONST");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = HEX_CONST;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -597,6 +588,7 @@ void PFCfgLexer::mHEX_CONST(bool _createToken) {
}
void PFCfgLexer::mNUMBER(bool _createToken) {
Tracer traceInOut(this, "mNUMBER");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = NUMBER;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -610,6 +602,7 @@ void PFCfgLexer::mNUMBER(bool _createToken) {
}
void PFCfgLexer::mNEG_INT_CONST(bool _createToken) {
Tracer traceInOut(this, "mNEG_INT_CONST");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = NEG_INT_CONST;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -623,6 +616,7 @@ void PFCfgLexer::mNEG_INT_CONST(bool _createToken) {
}
void PFCfgLexer::mDIGIT(bool _createToken) {
Tracer traceInOut(this, "mDIGIT");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = DIGIT;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -637,6 +631,7 @@ void PFCfgLexer::mDIGIT(bool _createToken) {
}
void PFCfgLexer::mHEXDIGIT(bool _createToken) {
Tracer traceInOut(this, "mHEXDIGIT");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = HEXDIGIT;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -651,20 +646,21 @@ void PFCfgLexer::mHEXDIGIT(bool _createToken) {
}
void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
Tracer traceInOut(this, "mNUMBER_ADDRESS_OR_WORD");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = NUMBER_ADDRESS_OR_WORD;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
{
bool synPredMatched69 = false;
bool synPredMatched143 = false;
if (((_tokenSet_2.member(LA(1))) && (_tokenSet_3.member(LA(2))) && (true))) {
int _m69 = mark();
synPredMatched69 = true;
int _m143 = mark();
synPredMatched143 = true;
inputState->guessing++;
try {
{
{ // ( ... )+
int _cnt68=0;
int _cnt142=0;
for (;;) {
switch ( LA(1)) {
case 0x61 /* 'a' */ :
@ -693,27 +689,27 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
}
default:
{
if ( _cnt68>=1 ) { goto _loop68; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt142>=1 ) { goto _loop142; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
}
_cnt68++;
_cnt142++;
}
_loop68:;
_loop142:;
} // ( ... )+
mCOLON(false);
}
}
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched69 = false;
synPredMatched143 = false;
}
rewind(_m69);
rewind(_m143);
inputState->guessing--;
}
if ( synPredMatched69 ) {
if ( synPredMatched143 ) {
{
{
{ // ( ... )+
int _cnt73=0;
int _cnt147=0;
for (;;) {
switch ( LA(1)) {
case 0x61 /* 'a' */ :
@ -742,15 +738,15 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
}
default:
{
if ( _cnt73>=1 ) { goto _loop73; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt147>=1 ) { goto _loop147; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
}
_cnt73++;
_cnt147++;
}
_loop73:;
_loop147:;
} // ( ... )+
{ // ( ... )+
int _cnt77=0;
int _cnt151=0;
for (;;) {
if ((LA(1) == 0x3a /* ':' */ )) {
mCOLON(false);
@ -783,34 +779,34 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
}
default:
{
goto _loop76;
goto _loop150;
}
}
}
_loop76:;
_loop150:;
} // ( ... )*
}
else {
if ( _cnt77>=1 ) { goto _loop77; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt151>=1 ) { goto _loop151; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt77++;
_cnt151++;
}
_loop77:;
_loop151:;
} // ( ... )+
}
if ( inputState->guessing==0 ) {
#line 319 "pf.g"
#line 793 "pf.g"
_ttype = IPV6;
#line 806 "PFCfgLexer.cpp"
#line 802 "PFCfgLexer.cpp"
}
}
}
else {
bool synPredMatched34 = false;
bool synPredMatched108 = false;
if ((((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && (true) && (true))) {
int _m34 = mark();
synPredMatched34 = true;
int _m108 = mark();
synPredMatched108 = true;
inputState->guessing++;
try {
{
@ -818,242 +814,242 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
}
}
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched34 = false;
synPredMatched108 = false;
}
rewind(_m34);
rewind(_m108);
inputState->guessing--;
}
if ( synPredMatched34 ) {
if ( synPredMatched108 ) {
{
bool synPredMatched43 = false;
bool synPredMatched117 = false;
if ((((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && (_tokenSet_4.member(LA(2))) && (_tokenSet_4.member(LA(3))))) {
int _m43 = mark();
synPredMatched43 = true;
int _m117 = mark();
synPredMatched117 = true;
inputState->guessing++;
try {
{
{ // ( ... )+
int _cnt38=0;
int _cnt112=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt38>=1 ) { goto _loop38; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt112>=1 ) { goto _loop112; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt38++;
_cnt112++;
}
_loop38:;
_loop112:;
} // ( ... )+
mDOT(false);
{ // ( ... )+
int _cnt40=0;
int _cnt114=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt40>=1 ) { goto _loop40; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt114>=1 ) { goto _loop114; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt40++;
_cnt114++;
}
_loop40:;
_loop114:;
} // ( ... )+
mDOT(false);
{ // ( ... )+
int _cnt42=0;
int _cnt116=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt42>=1 ) { goto _loop42; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt116>=1 ) { goto _loop116; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt42++;
_cnt116++;
}
_loop42:;
_loop116:;
} // ( ... )+
}
}
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched43 = false;
synPredMatched117 = false;
}
rewind(_m43);
rewind(_m117);
inputState->guessing--;
}
if ( synPredMatched43 ) {
if ( synPredMatched117 ) {
{
{ // ( ... )+
int _cnt46=0;
int _cnt120=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt46>=1 ) { goto _loop46; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt120>=1 ) { goto _loop120; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt46++;
_cnt120++;
}
_loop46:;
_loop120:;
} // ( ... )+
mDOT(false);
{ // ( ... )+
int _cnt48=0;
int _cnt122=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt48>=1 ) { goto _loop48; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt122>=1 ) { goto _loop122; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt48++;
_cnt122++;
}
_loop48:;
_loop122:;
} // ( ... )+
mDOT(false);
{ // ( ... )+
int _cnt50=0;
int _cnt124=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt50>=1 ) { goto _loop50; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt124>=1 ) { goto _loop124; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt50++;
_cnt124++;
}
_loop50:;
_loop124:;
} // ( ... )+
mDOT(false);
{ // ( ... )+
int _cnt52=0;
int _cnt126=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt52>=1 ) { goto _loop52; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt126>=1 ) { goto _loop126; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt52++;
_cnt126++;
}
_loop52:;
_loop126:;
} // ( ... )+
}
if ( inputState->guessing==0 ) {
#line 307 "pf.g"
#line 779 "pf.g"
_ttype = IPV4;
#line 953 "PFCfgLexer.cpp"
#line 949 "PFCfgLexer.cpp"
}
}
else {
bool synPredMatched58 = false;
bool synPredMatched132 = false;
if ((((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && (_tokenSet_4.member(LA(2))) && (_tokenSet_4.member(LA(3))))) {
int _m58 = mark();
synPredMatched58 = true;
int _m132 = mark();
synPredMatched132 = true;
inputState->guessing++;
try {
{
{ // ( ... )+
int _cnt55=0;
int _cnt129=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt55>=1 ) { goto _loop55; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt129>=1 ) { goto _loop129; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt55++;
_cnt129++;
}
_loop55:;
_loop129:;
} // ( ... )+
mDOT(false);
{ // ( ... )+
int _cnt57=0;
int _cnt131=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt57>=1 ) { goto _loop57; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt131>=1 ) { goto _loop131; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt57++;
_cnt131++;
}
_loop57:;
_loop131:;
} // ( ... )+
}
}
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& pe) {
synPredMatched58 = false;
synPredMatched132 = false;
}
rewind(_m58);
rewind(_m132);
inputState->guessing--;
}
if ( synPredMatched58 ) {
if ( synPredMatched132 ) {
{
{ // ( ... )+
int _cnt61=0;
int _cnt135=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt61>=1 ) { goto _loop61; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt135>=1 ) { goto _loop135; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt61++;
_cnt135++;
}
_loop61:;
_loop135:;
} // ( ... )+
mDOT(false);
{ // ( ... )+
int _cnt63=0;
int _cnt137=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt63>=1 ) { goto _loop63; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt137>=1 ) { goto _loop137; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt63++;
_cnt137++;
}
_loop63:;
_loop137:;
} // ( ... )+
}
if ( inputState->guessing==0 ) {
#line 310 "pf.g"
#line 782 "pf.g"
_ttype = NUMBER;
#line 1036 "PFCfgLexer.cpp"
#line 1032 "PFCfgLexer.cpp"
}
}
else if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ )) && (true) && (true)) {
{ // ( ... )+
int _cnt65=0;
int _cnt139=0;
for (;;) {
if (((LA(1) >= 0x30 /* '0' */ && LA(1) <= 0x39 /* '9' */ ))) {
mDIGIT(false);
}
else {
if ( _cnt65>=1 ) { goto _loop65; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
if ( _cnt139>=1 ) { goto _loop139; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
}
_cnt65++;
_cnt139++;
}
_loop65:;
_loop139:;
} // ( ... )+
if ( inputState->guessing==0 ) {
#line 312 "pf.g"
#line 784 "pf.g"
_ttype = INT_CONST;
#line 1057 "PFCfgLexer.cpp"
#line 1053 "PFCfgLexer.cpp"
}
}
else {
@ -1125,11 +1121,6 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
matchRange('A','Z');
break;
}
case 0x24 /* '$' */ :
{
match('$' /* charlit */ );
break;
}
default:
{
throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
@ -1139,40 +1130,19 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
{ // ( ... )*
for (;;) {
switch ( LA(1)) {
case 0x21 /* '!' */ :
case 0x22 /* '\"' */ :
case 0x23 /* '#' */ :
case 0x24 /* '$' */ :
{
match('$' /* charlit */ );
break;
}
case 0x25 /* '%' */ :
{
match('%' /* charlit */ );
break;
}
case 0x26 /* '&' */ :
case 0x27 /* '\'' */ :
{
matchRange('!','\'');
break;
}
case 0x2a /* '*' */ :
{
match('*' /* charlit */ );
break;
}
case 0x2b /* '+' */ :
{
match('+' /* charlit */ );
break;
}
case 0x2d /* '-' */ :
{
match('-' /* charlit */ );
break;
}
case 0x2e /* '.' */ :
{
match('.' /* charlit */ );
break;
}
case 0x2f /* '/' */ :
{
match('/' /* charlit */ );
match('&' /* charlit */ );
break;
}
case 0x30 /* '0' */ :
@ -1189,31 +1159,11 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
matchRange('0','9');
break;
}
case 0x3a /* ':' */ :
{
match(':' /* charlit */ );
break;
}
case 0x3b /* ';' */ :
{
match(';' /* charlit */ );
break;
}
case 0x3c /* '<' */ :
{
match('<' /* charlit */ );
break;
}
case 0x3d /* '=' */ :
{
match('=' /* charlit */ );
break;
}
case 0x3e /* '>' */ :
{
match('>' /* charlit */ );
break;
}
case 0x3f /* '?' */ :
{
match('?' /* charlit */ );
@ -1306,16 +1256,16 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
}
default:
{
goto _loop80;
goto _loop154;
}
}
}
_loop80:;
_loop154:;
} // ( ... )*
if ( inputState->guessing==0 ) {
#line 327 "pf.g"
#line 801 "pf.g"
_ttype = WORD;
#line 1319 "PFCfgLexer.cpp"
#line 1269 "PFCfgLexer.cpp"
}
}
else {
@ -1332,6 +1282,7 @@ void PFCfgLexer::mNUMBER_ADDRESS_OR_WORD(bool _createToken) {
}
void PFCfgLexer::mDOT(bool _createToken) {
Tracer traceInOut(this, "mDOT");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = DOT;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1345,7 +1296,23 @@ void PFCfgLexer::mDOT(bool _createToken) {
_saveIndex=0;
}
void PFCfgLexer::mCOLON(bool _createToken) {
Tracer traceInOut(this, "mCOLON");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = COLON;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match(':' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
_token->setText(text.substr(_begin, text.length()-_begin));
}
_returnToken = _token;
_saveIndex=0;
}
void PFCfgLexer::mSTRING(bool _createToken) {
Tracer traceInOut(this, "mSTRING");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = STRING;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1357,11 +1324,11 @@ void PFCfgLexer::mSTRING(bool _createToken) {
matchNot('\"' /* charlit */ );
}
else {
goto _loop83;
goto _loop157;
}
}
_loop83:;
_loop157:;
} // ( ... )*
match('\"' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
@ -1373,6 +1340,7 @@ void PFCfgLexer::mSTRING(bool _createToken) {
}
void PFCfgLexer::mPIPE_CHAR(bool _createToken) {
Tracer traceInOut(this, "mPIPE_CHAR");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = PIPE_CHAR;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1387,6 +1355,7 @@ void PFCfgLexer::mPIPE_CHAR(bool _createToken) {
}
void PFCfgLexer::mNUMBER_SIGN(bool _createToken) {
Tracer traceInOut(this, "mNUMBER_SIGN");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = NUMBER_SIGN;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1401,6 +1370,7 @@ void PFCfgLexer::mNUMBER_SIGN(bool _createToken) {
}
void PFCfgLexer::mPERCENT(bool _createToken) {
Tracer traceInOut(this, "mPERCENT");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = PERCENT;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1415,6 +1385,7 @@ void PFCfgLexer::mPERCENT(bool _createToken) {
}
void PFCfgLexer::mAMPERSAND(bool _createToken) {
Tracer traceInOut(this, "mAMPERSAND");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = AMPERSAND;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1429,6 +1400,7 @@ void PFCfgLexer::mAMPERSAND(bool _createToken) {
}
void PFCfgLexer::mAPOSTROPHE(bool _createToken) {
Tracer traceInOut(this, "mAPOSTROPHE");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = APOSTROPHE;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1442,35 +1414,8 @@ void PFCfgLexer::mAPOSTROPHE(bool _createToken) {
_saveIndex=0;
}
void PFCfgLexer::mOPENING_PAREN(bool _createToken) {
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = OPENING_PAREN;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match('(' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
_token->setText(text.substr(_begin, text.length()-_begin));
}
_returnToken = _token;
_saveIndex=0;
}
void PFCfgLexer::mCLOSING_PAREN(bool _createToken) {
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = CLOSING_PAREN;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match(')' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
_token->setText(text.substr(_begin, text.length()-_begin));
}
_returnToken = _token;
_saveIndex=0;
}
void PFCfgLexer::mSTAR(bool _createToken) {
Tracer traceInOut(this, "mSTAR");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = STAR;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1485,6 +1430,7 @@ void PFCfgLexer::mSTAR(bool _createToken) {
}
void PFCfgLexer::mPLUS(bool _createToken) {
Tracer traceInOut(this, "mPLUS");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = PLUS;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1499,6 +1445,7 @@ void PFCfgLexer::mPLUS(bool _createToken) {
}
void PFCfgLexer::mCOMMA(bool _createToken) {
Tracer traceInOut(this, "mCOMMA");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = COMMA;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1513,6 +1460,7 @@ void PFCfgLexer::mCOMMA(bool _createToken) {
}
void PFCfgLexer::mMINUS(bool _createToken) {
Tracer traceInOut(this, "mMINUS");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = MINUS;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1527,6 +1475,7 @@ void PFCfgLexer::mMINUS(bool _createToken) {
}
void PFCfgLexer::mSLASH(bool _createToken) {
Tracer traceInOut(this, "mSLASH");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = SLASH;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1541,6 +1490,7 @@ void PFCfgLexer::mSLASH(bool _createToken) {
}
void PFCfgLexer::mSEMICOLON(bool _createToken) {
Tracer traceInOut(this, "mSEMICOLON");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = SEMICOLON;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1554,23 +1504,10 @@ void PFCfgLexer::mSEMICOLON(bool _createToken) {
_saveIndex=0;
}
void PFCfgLexer::mLESS_THAN(bool _createToken) {
void PFCfgLexer::mEQUAL(bool _createToken) {
Tracer traceInOut(this, "mEQUAL");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = LESS_THAN;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match('<' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
_token->setText(text.substr(_begin, text.length()-_begin));
}
_returnToken = _token;
_saveIndex=0;
}
void PFCfgLexer::mEQUALS(bool _createToken) {
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = EQUALS;
_ttype = EQUAL;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match('=' /* charlit */ );
@ -1582,21 +1519,8 @@ void PFCfgLexer::mEQUALS(bool _createToken) {
_saveIndex=0;
}
void PFCfgLexer::mGREATER_THAN(bool _createToken) {
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = GREATER_THAN;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match('>' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
_token->setText(text.substr(_begin, text.length()-_begin));
}
_returnToken = _token;
_saveIndex=0;
}
void PFCfgLexer::mQUESTION(bool _createToken) {
Tracer traceInOut(this, "mQUESTION");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = QUESTION;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1611,6 +1535,7 @@ void PFCfgLexer::mQUESTION(bool _createToken) {
}
void PFCfgLexer::mCOMMERCIAL_AT(bool _createToken) {
Tracer traceInOut(this, "mCOMMERCIAL_AT");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = COMMERCIAL_AT;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1624,7 +1549,38 @@ void PFCfgLexer::mCOMMERCIAL_AT(bool _createToken) {
_saveIndex=0;
}
void PFCfgLexer::mOPENING_PAREN(bool _createToken) {
Tracer traceInOut(this, "mOPENING_PAREN");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = OPENING_PAREN;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match('(' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
_token->setText(text.substr(_begin, text.length()-_begin));
}
_returnToken = _token;
_saveIndex=0;
}
void PFCfgLexer::mCLOSING_PAREN(bool _createToken) {
Tracer traceInOut(this, "mCLOSING_PAREN");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = CLOSING_PAREN;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match(')' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
_token->setText(text.substr(_begin, text.length()-_begin));
}
_returnToken = _token;
_saveIndex=0;
}
void PFCfgLexer::mOPENING_SQUARE(bool _createToken) {
Tracer traceInOut(this, "mOPENING_SQUARE");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = OPENING_SQUARE;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1639,6 +1595,7 @@ void PFCfgLexer::mOPENING_SQUARE(bool _createToken) {
}
void PFCfgLexer::mCLOSING_SQUARE(bool _createToken) {
Tracer traceInOut(this, "mCLOSING_SQUARE");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = CLOSING_SQUARE;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1652,35 +1609,8 @@ void PFCfgLexer::mCLOSING_SQUARE(bool _createToken) {
_saveIndex=0;
}
void PFCfgLexer::mCARET(bool _createToken) {
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = CARET;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match('^' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
_token->setText(text.substr(_begin, text.length()-_begin));
}
_returnToken = _token;
_saveIndex=0;
}
void PFCfgLexer::mUNDERLINE(bool _createToken) {
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = UNDERLINE;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match('_' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
_token->setText(text.substr(_begin, text.length()-_begin));
}
_returnToken = _token;
_saveIndex=0;
}
void PFCfgLexer::mOPENING_BRACE(bool _createToken) {
Tracer traceInOut(this, "mOPENING_BRACE");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = OPENING_BRACE;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1695,6 +1625,7 @@ void PFCfgLexer::mOPENING_BRACE(bool _createToken) {
}
void PFCfgLexer::mCLOSING_BRACE(bool _createToken) {
Tracer traceInOut(this, "mCLOSING_BRACE");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = CLOSING_BRACE;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1708,7 +1639,38 @@ void PFCfgLexer::mCLOSING_BRACE(bool _createToken) {
_saveIndex=0;
}
void PFCfgLexer::mCARET(bool _createToken) {
Tracer traceInOut(this, "mCARET");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = CARET;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match('^' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
_token->setText(text.substr(_begin, text.length()-_begin));
}
_returnToken = _token;
_saveIndex=0;
}
void PFCfgLexer::mUNDERLINE(bool _createToken) {
Tracer traceInOut(this, "mUNDERLINE");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = UNDERLINE;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match('_' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
_token->setText(text.substr(_begin, text.length()-_begin));
}
_returnToken = _token;
_saveIndex=0;
}
void PFCfgLexer::mTILDE(bool _createToken) {
Tracer traceInOut(this, "mTILDE");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = TILDE;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1723,6 +1685,7 @@ void PFCfgLexer::mTILDE(bool _createToken) {
}
void PFCfgLexer::mEXLAMATION(bool _createToken) {
Tracer traceInOut(this, "mEXLAMATION");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = EXLAMATION;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
@ -1736,6 +1699,36 @@ void PFCfgLexer::mEXLAMATION(bool _createToken) {
_saveIndex=0;
}
void PFCfgLexer::mLESS_THAN(bool _createToken) {
Tracer traceInOut(this, "mLESS_THAN");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = LESS_THAN;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match('<' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
_token->setText(text.substr(_begin, text.length()-_begin));
}
_returnToken = _token;
_saveIndex=0;
}
void PFCfgLexer::mGREATER_THAN(bool _createToken) {
Tracer traceInOut(this, "mGREATER_THAN");
int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
_ttype = GREATER_THAN;
ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
match('>' /* charlit */ );
if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
_token = makeToken(_ttype);
_token->setText(text.substr(_begin, text.length()-_begin));
}
_returnToken = _token;
_saveIndex=0;
}
const unsigned long PFCfgLexer::_tokenSet_0_data_[] = { 4294958072UL, 1UL, 0UL, 2147483648UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
// 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xb 0xc 0xe 0xf 0x10 0x11 0x12 0x13 0x14
@ -1745,24 +1738,27 @@ const unsigned long PFCfgLexer::_tokenSet_1_data_[] = { 4294958072UL, 4294967295
// 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xb 0xc 0xe 0xf 0x10 0x11 0x12 0x13 0x14
// 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e 0x1f ! \" # $ %
// & \' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G
// H I J K L M N O P Q R S T U V W
// H I J K L M N O P Q R S T U V W X Y Z [ 0x5c ] ^ _ ` a b c d e f g h
// i j k l m n o p q r s t u v w x y z
const ANTLR_USE_NAMESPACE(antlr)BitSet PFCfgLexer::_tokenSet_1(_tokenSet_1_data_,16);
const unsigned long PFCfgLexer::_tokenSet_2_data_[] = { 0UL, 67043328UL, 0UL, 126UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
// 0 1 2 3 4 5 6 7 8 9
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
const ANTLR_USE_NAMESPACE(antlr)BitSet PFCfgLexer::_tokenSet_2(_tokenSet_2_data_,10);
const unsigned long PFCfgLexer::_tokenSet_3_data_[] = { 0UL, 134152192UL, 0UL, 126UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
// 0 1 2 3 4 5 6 7 8 9 :
// 0 1 2 3 4 5 6 7 8 9 : a b c d e f
const ANTLR_USE_NAMESPACE(antlr)BitSet PFCfgLexer::_tokenSet_3(_tokenSet_3_data_,10);
const unsigned long PFCfgLexer::_tokenSet_4_data_[] = { 0UL, 67059712UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
// . 0 1 2 3 4 5 6 7 8 9
const ANTLR_USE_NAMESPACE(antlr)BitSet PFCfgLexer::_tokenSet_4(_tokenSet_4_data_,10);
const unsigned long PFCfgLexer::_tokenSet_5_data_[] = { 0UL, 16UL, 134217726UL, 134217726UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
// $ A B C D E F G H I J K L M N O P Q R S T U V W
const unsigned long PFCfgLexer::_tokenSet_5_data_[] = { 0UL, 0UL, 134217726UL, 134217726UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h
// i j k l m n o p q r s t u v w x y z
const ANTLR_USE_NAMESPACE(antlr)BitSet PFCfgLexer::_tokenSet_5(_tokenSet_5_data_,10);
const unsigned long PFCfgLexer::_tokenSet_6_data_[] = { 4294967288UL, 4294967291UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
// 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf 0x10 0x11 0x12 0x13
// 0x14 0x15 0x16 0x17 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e 0x1f ! # $
// % & \' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F
// G H I J K L M N O P Q R S T U V W
// G H I J K L M N O P Q R S T U V W X Y Z [ 0x5c ] ^ _ ` a b c d e f g
// h i j k l m n o p q r s t u v w x y z
const ANTLR_USE_NAMESPACE(antlr)BitSet PFCfgLexer::_tokenSet_6(_tokenSet_6_data_,16);

View File

@ -49,8 +49,6 @@ public:
ANTLR_USE_NAMESPACE(antlr)RefToken nextToken();
public: void mLINE_COMMENT(bool _createToken);
public: void mNEWLINE(bool _createToken);
public: void mCOLON_COMMENT(bool _createToken);
public: void mCOLON(bool _createToken);
public: void mWhitespace(bool _createToken);
protected: void mINT_CONST(bool _createToken);
protected: void mHEX_CONST(bool _createToken);
@ -60,33 +58,34 @@ public:
protected: void mHEXDIGIT(bool _createToken);
public: void mNUMBER_ADDRESS_OR_WORD(bool _createToken);
public: void mDOT(bool _createToken);
public: void mCOLON(bool _createToken);
public: void mSTRING(bool _createToken);
public: void mPIPE_CHAR(bool _createToken);
public: void mNUMBER_SIGN(bool _createToken);
public: void mPERCENT(bool _createToken);
public: void mAMPERSAND(bool _createToken);
public: void mAPOSTROPHE(bool _createToken);
public: void mOPENING_PAREN(bool _createToken);
public: void mCLOSING_PAREN(bool _createToken);
public: void mSTAR(bool _createToken);
public: void mPLUS(bool _createToken);
public: void mCOMMA(bool _createToken);
public: void mMINUS(bool _createToken);
public: void mSLASH(bool _createToken);
public: void mSEMICOLON(bool _createToken);
public: void mLESS_THAN(bool _createToken);
public: void mEQUALS(bool _createToken);
public: void mGREATER_THAN(bool _createToken);
public: void mEQUAL(bool _createToken);
public: void mQUESTION(bool _createToken);
public: void mCOMMERCIAL_AT(bool _createToken);
public: void mOPENING_PAREN(bool _createToken);
public: void mCLOSING_PAREN(bool _createToken);
public: void mOPENING_SQUARE(bool _createToken);
public: void mCLOSING_SQUARE(bool _createToken);
public: void mCARET(bool _createToken);
public: void mUNDERLINE(bool _createToken);
public: void mOPENING_BRACE(bool _createToken);
public: void mCLOSING_BRACE(bool _createToken);
public: void mCARET(bool _createToken);
public: void mUNDERLINE(bool _createToken);
public: void mTILDE(bool _createToken);
public: void mEXLAMATION(bool _createToken);
public: void mLESS_THAN(bool _createToken);
public: void mGREATER_THAN(bool _createToken);
private:
static const unsigned long _tokenSet_0_data_[];

File diff suppressed because it is too large Load Diff

View File

@ -90,12 +90,45 @@ public:
}
public: void cfgfile();
public: void comment();
public: void macro_definition();
public: void altq_command();
public: void queue_command();
public: void set_command();
public: void scrub_command();
public: void nat_command();
public: void rdr_command();
public: void binat_command();
public: void pass_command();
public: void drop_command();
public: void block_command();
public: void timeout_command();
public: void unknown_command();
public: void rule_extended();
public: void single_addr();
public: void direction();
public: void logging();
public: void quick();
public: void intrface();
public: void address_family();
public: void protospec();
public: void hosts();
public: void filteropts();
public: void logopts();
public: void logopt();
public: void proto_name();
public: void proto_number();
public: void proto_list();
public: void src_hosts_part();
public: void src_port_part();
public: void dst_hosts_part();
public: void dst_port_part();
public: void host();
public: void host_list();
public: void filteropt();
public: void state();
public: void queue();
public: void unary_op();
public: void binary_op();
public: void op_list();
public: void port_def();
public:
ANTLR_USE_NAMESPACE(antlr)RefAST getAST()
{
@ -107,10 +140,10 @@ protected:
private:
static const char* tokenNames[];
#ifndef NO_STATIC_CONSTS
static const int NUM_TOKENS = 88;
static const int NUM_TOKENS = 123;
#else
enum {
NUM_TOKENS = 88
NUM_TOKENS = 123
};
#endif
@ -120,6 +153,48 @@ private:
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_1;
static const unsigned long _tokenSet_2_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_2;
static const unsigned long _tokenSet_3_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_3;
static const unsigned long _tokenSet_4_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_4;
static const unsigned long _tokenSet_5_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_5;
static const unsigned long _tokenSet_6_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_6;
static const unsigned long _tokenSet_7_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_7;
static const unsigned long _tokenSet_8_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_8;
static const unsigned long _tokenSet_9_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_9;
static const unsigned long _tokenSet_10_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_10;
static const unsigned long _tokenSet_11_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_11;
static const unsigned long _tokenSet_12_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_12;
static const unsigned long _tokenSet_13_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_13;
static const unsigned long _tokenSet_14_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_14;
static const unsigned long _tokenSet_15_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_15;
static const unsigned long _tokenSet_16_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_16;
static const unsigned long _tokenSet_17_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_17;
static const unsigned long _tokenSet_18_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_18;
static const unsigned long _tokenSet_19_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_19;
static const unsigned long _tokenSet_20_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_20;
static const unsigned long _tokenSet_21_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_21;
static const unsigned long _tokenSet_22_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_22;
static const unsigned long _tokenSet_23_data_[];
static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_23;
};
#endif /*INC_PFCfgParser_hpp_*/

View File

@ -14,88 +14,123 @@ struct CUSTOM_API PFCfgParserTokenTypes {
EOF_ = 1,
NEWLINE = 4,
LINE_COMMENT = 5,
COLON_COMMENT = 6,
TIMEOUT = 7,
WORD = 8,
PASS = 9,
DROP = 10,
IPV4 = 11,
IPV6 = 12,
EXIT = 13,
QUIT = 14,
NO = 15,
INTRFACE = 16,
IP = 17,
ICMP = 18,
ICMP6 = 19,
TCP = 20,
UDP = 21,
AH = 22,
EIGRP = 23,
ESP = 24,
GRE = 25,
IGMP = 26,
IGRP = 27,
IPINIP = 28,
IPSEC = 29,
NOS = 30,
OSPF = 31,
PCP = 32,
PIM = 33,
PPTP = 34,
RIP = 35,
SNP = 36,
HOST = 37,
ANY = 38,
RANGE = 39,
LOG = 40,
LOG_LEVEL_ALERTS = 41,
LOG_LEVEL_CRITICAL = 42,
LOG_LEVEL_DEBUGGING = 43,
LOG_LEVEL_EMERGENCIES = 44,
LOG_LEVEL_ERRORS = 45,
LOG_LEVEL_INFORMATIONAL = 46,
LOG_LEVEL_NOTIFICATIONS = 47,
LOG_LEVEL_WARNINGS = 48,
LOG_LEVEL_DISABLE = 49,
LOG_LEVEL_INACTIVE = 50,
Whitespace = 51,
INT_CONST = 52,
HEX_CONST = 53,
NUMBER = 54,
NEG_INT_CONST = 55,
DIGIT = 56,
HEXDIGIT = 57,
NUMBER_ADDRESS_OR_WORD = 58,
STRING = 59,
PIPE_CHAR = 60,
NUMBER_SIGN = 61,
PERCENT = 62,
AMPERSAND = 63,
APOSTROPHE = 64,
OPENING_PAREN = 65,
CLOSING_PAREN = 66,
STAR = 67,
PLUS = 68,
COMMA = 69,
MINUS = 70,
DOT = 71,
SLASH = 72,
COLON = 73,
SEMICOLON = 74,
LESS_THAN = 75,
EQUALS = 76,
GREATER_THAN = 77,
QUESTION = 78,
COMMERCIAL_AT = 79,
OPENING_SQUARE = 80,
CLOSING_SQUARE = 81,
CARET = 82,
UNDERLINE = 83,
OPENING_BRACE = 84,
CLOSING_BRACE = 85,
TILDE = 86,
EXLAMATION = 87,
WORD = 6,
EQUAL = 7,
ALTQ = 8,
QUEUE = 9,
SET = 10,
SCRUB = 11,
NAT = 12,
BINAT = 13,
RDR = 14,
TIMEOUT = 15,
PASS = 16,
BLOCK = 17,
IN = 18,
OUT = 19,
LOG = 20,
COMMA = 21,
ALL = 22,
USER = 23,
TO = 24,
QUICK = 25,
ON = 26,
INET = 27,
INET6 = 28,
PROTO = 29,
IP = 30,
ICMP = 31,
IGMP = 32,
TCP = 33,
UDP = 34,
RDP = 35,
RSVP = 36,
GRE = 37,
ESP = 38,
AH = 39,
EIGRP = 40,
OSPF = 41,
IPIP = 42,
VRRP = 43,
L2TP = 44,
ISIS = 45,
INT_CONST = 46,
OPENING_BRACE = 47,
CLOSING_BRACE = 48,
FROM = 49,
ANY = 50,
SELF = 51,
EXCLAMATION = 52,
IPV4 = 53,
IPV6 = 54,
SLASH = 55,
NO = 56,
KEEP = 57,
MODULATE = 58,
SYNPROXY = 59,
STATE = 60,
OPENING_PAREN = 61,
CLOSING_PAREN = 62,
PORT = 63,
NOT_EQUAL = 64,
LESS_THAN = 65,
LESS_OR_EQUAL_THAN = 66,
GREATER_THAN = 67,
GREATER_OR_EQUAL_THAN = 68,
EXCEPT_RANGE = 69,
INSIDE_RANGE = 70,
COLON = 71,
EXIT = 72,
QUIT = 73,
INTRFACE = 74,
ICMP6 = 75,
IGRP = 76,
IPSEC = 77,
NOS = 78,
PCP = 79,
PIM = 80,
PPTP = 81,
RIP = 82,
SNP = 83,
HOST = 84,
RANGE = 85,
LOG_LEVEL_ALERTS = 86,
LOG_LEVEL_CRITICAL = 87,
LOG_LEVEL_DEBUGGING = 88,
LOG_LEVEL_EMERGENCIES = 89,
LOG_LEVEL_ERRORS = 90,
LOG_LEVEL_INFORMATIONAL = 91,
LOG_LEVEL_NOTIFICATIONS = 92,
LOG_LEVEL_WARNINGS = 93,
LOG_LEVEL_DISABLE = 94,
LOG_LEVEL_INACTIVE = 95,
TRANSLATE_TO = 96,
Whitespace = 97,
HEX_CONST = 98,
NUMBER = 99,
NEG_INT_CONST = 100,
DIGIT = 101,
HEXDIGIT = 102,
NUMBER_ADDRESS_OR_WORD = 103,
STRING = 104,
PIPE_CHAR = 105,
NUMBER_SIGN = 106,
PERCENT = 107,
AMPERSAND = 108,
APOSTROPHE = 109,
STAR = 110,
PLUS = 111,
MINUS = 112,
DOT = 113,
SEMICOLON = 114,
QUESTION = 115,
COMMERCIAL_AT = 116,
OPENING_SQUARE = 117,
CLOSING_SQUARE = 118,
CARET = 119,
UNDERLINE = 120,
TILDE = 121,
EXLAMATION = 122,
NULL_TREE_LOOKAHEAD = 3
};
#ifdef __cplusplus

View File

@ -2,85 +2,120 @@
PFCfgParser // output token vocab name
NEWLINE=4
LINE_COMMENT=5
COLON_COMMENT=6
TIMEOUT="timeout"=7
WORD=8
PASS="pass"=9
DROP="drop"=10
IPV4=11
IPV6=12
EXIT="exit"=13
QUIT="quit"=14
NO="no"=15
INTRFACE="interface"=16
IP="ip"=17
ICMP="icmp"=18
ICMP6="icmp6"=19
TCP="tcp"=20
UDP="udp"=21
AH="ah"=22
EIGRP="eigrp"=23
ESP="esp"=24
GRE="gre"=25
IGMP="igmp"=26
IGRP="igrp"=27
IPINIP="ipinip"=28
IPSEC="ipsec"=29
NOS="nos"=30
OSPF="ospf"=31
PCP="pcp"=32
PIM="pim"=33
PPTP="pptp"=34
RIP="rip"=35
SNP="snp"=36
HOST="host"=37
ANY="any"=38
RANGE="range"=39
LOG="log"=40
LOG_LEVEL_ALERTS="alerts"=41
LOG_LEVEL_CRITICAL="critical"=42
LOG_LEVEL_DEBUGGING="debugging"=43
LOG_LEVEL_EMERGENCIES="emergencies"=44
LOG_LEVEL_ERRORS="errors"=45
LOG_LEVEL_INFORMATIONAL="informational"=46
LOG_LEVEL_NOTIFICATIONS="notifications"=47
LOG_LEVEL_WARNINGS="warnings"=48
LOG_LEVEL_DISABLE="disable"=49
LOG_LEVEL_INACTIVE="inactive"=50
Whitespace=51
INT_CONST=52
HEX_CONST=53
NUMBER=54
NEG_INT_CONST=55
DIGIT=56
HEXDIGIT=57
NUMBER_ADDRESS_OR_WORD=58
STRING=59
PIPE_CHAR=60
NUMBER_SIGN=61
PERCENT=62
AMPERSAND=63
APOSTROPHE=64
OPENING_PAREN=65
CLOSING_PAREN=66
STAR=67
PLUS=68
COMMA=69
MINUS=70
DOT=71
SLASH=72
COLON=73
SEMICOLON=74
LESS_THAN=75
EQUALS=76
GREATER_THAN=77
QUESTION=78
COMMERCIAL_AT=79
OPENING_SQUARE=80
CLOSING_SQUARE=81
CARET=82
UNDERLINE=83
OPENING_BRACE=84
CLOSING_BRACE=85
TILDE=86
EXLAMATION=87
WORD=6
EQUAL=7
ALTQ="altq"=8
QUEUE="queue"=9
SET="set"=10
SCRUB="scrub"=11
NAT="nat"=12
BINAT="binat"=13
RDR="rdr"=14
TIMEOUT="timeout"=15
PASS="pass"=16
BLOCK="block"=17
IN="in"=18
OUT="out"=19
LOG="log"=20
COMMA=21
ALL=22
USER=23
TO="to"=24
QUICK="quick"=25
ON="on"=26
INET="inet"=27
INET6="inet6"=28
PROTO="proto"=29
IP="ip"=30
ICMP="icmp"=31
IGMP="igmp"=32
TCP="tcp"=33
UDP="udp"=34
RDP="rdp"=35
RSVP="rsvp"=36
GRE="gre"=37
ESP="esp"=38
AH="ah"=39
EIGRP="eigrp"=40
OSPF="ospf"=41
IPIP="ipip"=42
VRRP="vrrp"=43
L2TP="l2tp"=44
ISIS="isis"=45
INT_CONST=46
OPENING_BRACE=47
CLOSING_BRACE=48
FROM="from"=49
ANY="any"=50
SELF=51
EXCLAMATION=52
IPV4=53
IPV6=54
SLASH=55
NO="no"=56
KEEP="keep"=57
MODULATE="modulate"=58
SYNPROXY="synproxy"=59
STATE="state"=60
OPENING_PAREN=61
CLOSING_PAREN=62
PORT="port"=63
NOT_EQUAL="!="=64
LESS_THAN=65
LESS_OR_EQUAL_THAN="<="=66
GREATER_THAN=67
GREATER_OR_EQUAL_THAN=">="=68
EXCEPT_RANGE="<>"=69
INSIDE_RANGE="><"=70
COLON=71
EXIT="exit"=72
QUIT="quit"=73
INTRFACE="interface"=74
ICMP6="icmp6"=75
IGRP="igrp"=76
IPSEC="ipsec"=77
NOS="nos"=78
PCP="pcp"=79
PIM="pim"=80
PPTP="pptp"=81
RIP="rip"=82
SNP="snp"=83
HOST="host"=84
RANGE="range"=85
LOG_LEVEL_ALERTS="alerts"=86
LOG_LEVEL_CRITICAL="critical"=87
LOG_LEVEL_DEBUGGING="debugging"=88
LOG_LEVEL_EMERGENCIES="emergencies"=89
LOG_LEVEL_ERRORS="errors"=90
LOG_LEVEL_INFORMATIONAL="informational"=91
LOG_LEVEL_NOTIFICATIONS="notifications"=92
LOG_LEVEL_WARNINGS="warnings"=93
LOG_LEVEL_DISABLE="disable"=94
LOG_LEVEL_INACTIVE="inactive"=95
TRANSLATE_TO="->"=96
Whitespace=97
HEX_CONST=98
NUMBER=99
NEG_INT_CONST=100
DIGIT=101
HEXDIGIT=102
NUMBER_ADDRESS_OR_WORD=103
STRING=104
PIPE_CHAR=105
NUMBER_SIGN=106
PERCENT=107
AMPERSAND=108
APOSTROPHE=109
STAR=110
PLUS=111
MINUS=112
DOT=113
SEMICOLON=114
QUESTION=115
COMMERCIAL_AT=116
OPENING_SQUARE=117
CLOSING_SQUARE=118
CARET=119
UNDERLINE=120
TILDE=121
EXLAMATION=122

View File

@ -112,26 +112,131 @@ options
cfgfile :
(
comment
|
macro_definition
|
altq_command
|
queue_command
|
set_command
|
scrub_command
|
nat_command
|
rdr_command
|
binat_command
|
pass_command
|
drop_command
block_command
|
timeout_command
|
unknown_command
|
NEWLINE
)+
)*
;
//****************************************************************
comment : LINE_COMMENT ;
//****************************************************************
macro_definition : WORD EQUAL
{
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
consumeUntil(NEWLINE);
}
;
//****************************************************************
altq_command : ALTQ
{
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
importer->addMessageToLog(
QString("Warning: import of 'altq' commands is not supported."));
consumeUntil(NEWLINE);
}
;
//****************************************************************
queue_command : QUEUE
{
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
importer->addMessageToLog(
QString("Warning: import of 'queue' commands is not supported."));
consumeUntil(NEWLINE);
}
;
//****************************************************************
set_command : SET
{
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
importer->addMessageToLog(
QString("Warning: import of 'set' commands has not been implemented yet."));
consumeUntil(NEWLINE);
}
;
//****************************************************************
scrub_command : SCRUB
{
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
importer->addMessageToLog(
QString("Warning: import of 'scrub' commands has not been implemented yet."));
consumeUntil(NEWLINE);
}
;
//****************************************************************
nat_command : NAT
{
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
importer->addMessageToLog(
QString("Warning: import of 'nat' commands has not been implemented yet."));
consumeUntil(NEWLINE);
}
;
//****************************************************************
binat_command : BINAT
{
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
importer->addMessageToLog(
QString("Warning: import of 'binat' commands is not supported."));
consumeUntil(NEWLINE);
}
;
//****************************************************************
rdr_command : RDR
{
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
importer->addMessageToLog(
QString("Warning: import of 'rdr' commands has not been implemented yet."));
consumeUntil(NEWLINE);
}
;
//****************************************************************
timeout_command : TIMEOUT
{
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
importer->addMessageToLog(
QString("Warning: import of 'timeout' commands has not been implemented yet."));
consumeUntil(NEWLINE);
}
;
@ -140,6 +245,8 @@ timeout_command : TIMEOUT
//****************************************************************
unknown_command : WORD
{
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
consumeUntil(NEWLINE);
}
;
@ -149,6 +256,7 @@ unknown_command : WORD
pass_command: PASS
{
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
importer->newPolicyRule();
importer->action = "pass";
@ -156,44 +264,372 @@ pass_command: PASS
}
rule_extended NEWLINE
{
importer->setInterfaceAndDirectionForRuleSet(
"", importer->iface, importer->direction);
importer->pushRule();
}
;
drop_command: DROP
block_command: BLOCK
{
importer->clear();
importer->setCurrentLineNumber(LT(0)->getLine());
importer->newPolicyRule();
importer->action = "drop";
*dbg << LT(1)->getLine() << ":" << " drop ";
importer->action = "block";
*dbg << LT(1)->getLine() << ":" << " block ";
}
rule_extended NEWLINE
{
importer->setInterfaceAndDirectionForRuleSet(
"", importer->iface, importer->direction);
importer->pushRule();
}
;
rule_extended:
direction
(logging)?
(quick)?
(intrface)?
(
(address_family)?
(protospec)?
hosts
filteropts
)?
;
single_addr : (h:IPV4 | v6:IPV6)
direction: (IN | OUT)
{
importer->setCurrentLineNumber(LT(0)->getLine());
if (h)
{
importer->tmp_a = h->getText();
importer->tmp_nm = "255.255.255.255";
*dbg << importer->tmp_a << " ";
importer->direction = LT(0)->getText();
}
;
logging: LOG logopts
{
importer->logging = true;
}
;
logopts:
logopt
(
COMMA
logopt
)*
;
logopt: ALL | USER | TO WORD
;
quick: QUICK
{
importer->quick = true;
}
;
intrface: ON WORD
{
importer->iface = LT(0)->getText();
importer->newInterface(importer->iface);
}
;
address_family: INET | INET6
{
importer->address_family = LT(0)->getText();
}
;
protospec: PROTO
(
proto_name
|
proto_number
|
proto_list
)
;
proto_name: (IP | ICMP | IGMP | TCP | UDP | RDP | RSVP | GRE | ESP | AH |
EIGRP | OSPF | IPIP | VRRP | L2TP | ISIS )
{
importer->proto_list.push_back(LT(0)->getText());
}
;
proto_number: INT_CONST
{
importer->proto_list.push_back(LT(0)->getText());
}
;
proto_list:
OPENING_BRACE
protospec
(
COMMA
protospec
)*
CLOSING_BRACE
;
hosts:
ALL
|
(
(
FROM
( src_hosts_part )?
( src_port_part )?
)?
(
TO
( dst_hosts_part )?
( dst_port_part )?
)
)
;
src_hosts_part:
(
ANY
{
importer->tmp_group.push_back(
std::pair<std::string, std::string>("0.0.0.0", "0.0.0.0"));
}
|
SELF
{
importer->tmp_group.push_back(
std::pair<std::string, std::string>("self", "255.255.255.255"));
}
|
host
|
host_list
)
{
importer->src_neg = importer->tmp_neg;
importer->src_group.splice(importer->src_group.begin(),
importer->tmp_group);
}
;
dst_hosts_part:
(
ANY
{
importer->tmp_group.push_back(
std::pair<std::string, std::string>("0.0.0.0", "0.0.0.0"));
}
|
SELF
{
importer->tmp_group.push_back(
std::pair<std::string, std::string>("self", "255.255.255.255"));
}
|
host
|
host_list
)
{
importer->dst_neg = importer->tmp_neg;
importer->dst_group.splice(importer->src_group.begin(),
importer->tmp_group);
}
;
host :
(
EXCLAMATION
{
importer->tmp_neg = true;
}
)?
(
(h:IPV4 | v6:IPV6) (SLASH (nm:IPV4 | nm6:INT_CONST))?
{
if (v6)
{
importer->addMessageToLog(
QString("Warning: IPv6 import is not supported. "));
consumeUntil(NEWLINE);
} else
{
std::string addr = "0.0.0.0";
std::string netm = "255.255.255.255";
if (h) addr = h->getText();
if (nm) netm = nm->getText();
importer->tmp_group.push_back(
std::pair<std::string, std::string>(addr, netm));
}
}
|
WORD
{
// This should be an interface name
importer->tmp_group.push_back(
std::pair<std::string, std::string>(
LT(0)->getText(), "255.255.255.255"));
}
// Add table matching here
)
;
host_list :
OPENING_BRACE
host
(
COMMA
host
)*
CLOSING_BRACE
;
filteropts:
filteropt
(
COMMA
filteropt
)*
;
filteropt:
(state)?
(queue)?
;
state:
(
NO
|
KEEP
|
MODULATE
|
SYNPROXY
)
{
importer->state_op = LT(0)->getText();
}
STATE
;
queue:
QUEUE
(
WORD { importer->queue += LT(0)->getText(); }
|
OPENING_PAREN { importer->queue += "("; }
WORD { importer->queue += LT(0)->getText(); }
(
COMMA { importer->queue += ","; }
WORD { importer->queue += LT(0)->getText(); }
)*
CLOSING_PAREN { importer->queue += ")"; }
)
;
//****************************************************************
src_port_part :
PORT ( unary_op | binary_op | op_list )
{
importer->src_port_group.splice(importer->src_port_group.begin(),
importer->tmp_port_group);
}
;
dst_port_part :
PORT ( unary_op | binary_op | op_list )
{
importer->dst_port_group.splice(importer->dst_port_group.begin(),
importer->tmp_port_group);
}
;
unary_op :
{
std::string op = "=";
}
(
(
EQUAL
|
NOT_EQUAL
|
LESS_THAN
|
LESS_OR_EQUAL_THAN
|
GREATER_THAN
|
GREATER_OR_EQUAL_THAN
)
{
op = LT(0)->getText();
}
)?
port_def
{
std::vector<std::string> tuple;
tuple.push_back(op);
tuple.push_back(importer->tmp_port_def);
importer->tmp_port_group.push_back(tuple);
}
;
binary_op :
{
std::string op;
std::string arg1;
std::vector<std::string> tuple;
}
port_def
{
arg1 = importer->tmp_port_def;
}
(
EXCEPT_RANGE
|
INSIDE_RANGE
|
COLON
)
{
op = LT(0)->getText();
}
port_def
{
tuple.push_back(op);
tuple.push_back(arg1);
tuple.push_back(importer->tmp_port_def);
importer->tmp_port_group.push_back(tuple);
}
;
port_def :
( WORD | INT_CONST )
{
importer->tmp_port_def = LT(0)->getText();
}
;
op_list :
OPENING_BRACE
( unary_op | binary_op )
(
COMMA
( unary_op | binary_op )
)*
CLOSING_BRACE
;
//****************************************************************
class PFCfgLexer extends Lexer;
@ -214,7 +650,21 @@ tokens
INTRFACE = "interface";
PASS = "pass";
DROP = "drop";
BLOCK = "block";
QUICK = "quick";
IN = "in";
OUT = "out";
ON = "on";
PROTO = "proto";
FROM = "from";
TO = "to";
INET = "inet";
INET6 = "inet6";
// protocols
@ -230,7 +680,7 @@ tokens
GRE = "gre";
IGMP = "igmp";
IGRP = "igrp";
IPINIP = "ipinip";
IPIP = "ipip";
IPSEC = "ipsec";
NOS = "nos";
OSPF = "ospf";
@ -239,9 +689,15 @@ tokens
PPTP = "pptp";
RIP = "rip";
SNP = "snp";
RDP = "rdp";
RSVP = "rsvp";
VRRP = "vrrp";
L2TP = "l2tp";
ISIS = "isis";
HOST = "host";
ANY = "any";
PORT = "port";
RANGE = "range";
@ -259,6 +715,28 @@ tokens
LOG_LEVEL_INACTIVE = "inactive";
TIMEOUT = "timeout";
ALTQ = "altq";
SET = "set";
SCRUB = "scrub";
NAT = "nat";
RDR = "rdr";
BINAT = "binat";
QUEUE = "queue";
NOT_EQUAL = "!=" ;
LESS_OR_EQUAL_THAN = "<=" ;
GREATER_OR_EQUAL_THAN = ">=" ;
EXCEPT_RANGE = "<>";
INSIDE_RANGE = "><";
TRANSLATE_TO = "->";
STATE = "state";
KEEP = "keep";
MODULATE = "modulate";
SYNPROXY = "synproxy";
}
LINE_COMMENT : "#" (~('\r' | '\n'))* NEWLINE ;
@ -308,15 +786,17 @@ NUMBER_ADDRESS_OR_WORD :
|
( ( 'a'..'f' | '0'..'9' )+ COLON ) =>
(
( ( 'a'..'f' | '0'..'9' )+
( COLON ( 'a'..'f' | '0'..'9' )* )+ )
(
( 'a'..'f' | '0'..'9' )+
( COLON ( 'a'..'f' | '0'..'9' )* )+
)
{ _ttype = IPV6; }
)
|
// making sure ',' '(' ')' are not part of WORD
( 'a'..'z' | 'A'..'Z' | '$' )
( '!'..'\'' | '*' | '+' | '-' | '.' | '/' | '0'..'9' | ':' |
';' | '<' | '=' | '>' |
// making sure ',' '(' ')' '=' '<' '>' '-' '+' are not part of WORD
// do not start WORD with '$' since we expand macros in PFImporterRun using regex.
( 'a'..'z' | 'A'..'Z' )
( '$' | '%' | '&' | '0'..'9' | ';' |
'?' | '@' | 'A'..'Z' | '\\' | '^' | '_' | '`' | 'a'..'z' )*
{ _ttype = WORD; }
)
@ -330,8 +810,6 @@ NUMBER_SIGN : '#' ;
PERCENT : '%' ;
AMPERSAND : '&' ;
APOSTROPHE : '\'' ;
OPENING_PAREN : '(' ;
CLOSING_PAREN : ')' ;
STAR : '*' ;
PLUS : '+' ;
COMMA : ',' ;
@ -341,19 +819,26 @@ SLASH : '/' ;
COLON : ':' ;
SEMICOLON : ';' ;
LESS_THAN : '<' ;
EQUALS : '=' ;
GREATER_THAN : '>' ;
EQUAL : '=' ;
QUESTION : '?' ;
COMMERCIAL_AT : '@' ;
OPENING_PAREN : '(' ;
CLOSING_PAREN : ')' ;
OPENING_SQUARE : '[' ;
CLOSING_SQUARE : ']' ;
CARET : '^' ;
UNDERLINE : '_' ;
OPENING_BRACE : '{' ;
CLOSING_BRACE : '}' ;
CARET : '^' ;
UNDERLINE : '_' ;
TILDE : '~' ;
EXLAMATION : '!';
LESS_THAN : '<' ;
GREATER_THAN : '>' ;