mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-12 07:14:23 +00:00
full grammar
This commit is contained in:
parent
ed4e59c8d0
commit
2f287d046d
@ -57,13 +57,17 @@ namespace query
|
|||||||
struct group_pred : if_must< one< '(' >, pad< pred, blank >, one< ')' > > {};
|
struct group_pred : if_must< one< '(' >, pad< pred, blank >, one< ')' > > {};
|
||||||
|
|
||||||
struct single_pred : pad< sor< group_pred, comparison_pred >, blank > {};
|
struct single_pred : pad< sor< group_pred, comparison_pred >, blank > {};
|
||||||
struct not_pre : pegtl::string< 'N', 'O', 'T' > {};
|
struct not_pre : sor< seq< one< '!' >, star< blank > >, seq< istring< 'N', 'O', 'T' >, plus< blank > > > {};
|
||||||
struct atom_pred : seq< opt< not_pre >, single_pred > {};
|
struct atom_pred : seq< opt< not_pre >, single_pred > {};
|
||||||
|
|
||||||
struct or_ext : if_must< two< '|' >, atom_pred > {};
|
struct and_op : sor< two< '&' >, istring< 'A', 'N', 'D' > > {};
|
||||||
struct and_ext : if_must< two< '&' >, atom_pred > {};
|
struct or_op : sor< two< '|' >, istring< 'O', 'R' > > {};
|
||||||
|
|
||||||
struct pred : seq< atom_pred, star< sor< or_ext, and_ext > > > {};
|
struct or_ext : seq< pad< or_op, blank >, pred > {};
|
||||||
|
struct and_ext : seq< pad< and_op, blank >, pred > {};
|
||||||
|
struct and_pred : seq< atom_pred, star< and_ext > > {};
|
||||||
|
|
||||||
|
struct pred : seq< and_pred, star< or_ext > > {};
|
||||||
|
|
||||||
// rules
|
// rules
|
||||||
template< typename Rule >
|
template< typename Rule >
|
||||||
@ -92,11 +96,27 @@ namespace query
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<> struct action< one< '(' > >
|
||||||
|
{
|
||||||
|
static void apply( const input & in, std::string & string_value )
|
||||||
|
{
|
||||||
|
std::cout << "<begin_group>" << std::endl;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template<> struct action< group_pred >
|
template<> struct action< group_pred >
|
||||||
{
|
{
|
||||||
static void apply( const input & in, std::string & string_value )
|
static void apply( const input & in, std::string & string_value )
|
||||||
{
|
{
|
||||||
std::cout << "<group>" << std::endl;
|
std::cout << "<end_group>" << std::endl;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> struct action< not_pre >
|
||||||
|
{
|
||||||
|
static void apply( const input & in, std::string & string_value )
|
||||||
|
{
|
||||||
|
std::cout << "<not>" << std::endl;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -106,7 +126,7 @@ int main( int argc, char ** argv )
|
|||||||
if ( argc > 1 ) {
|
if ( argc > 1 ) {
|
||||||
std::string intstring;
|
std::string intstring;
|
||||||
analyze< query::pred >();
|
analyze< query::pred >();
|
||||||
parse< must< seq< query::pred, eof > >, query::action >( 1, argv, intstring);
|
parse< must< query::pred, eof >, query::action >( 1, argv, intstring);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user