Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
filter_string.cpp File Reference
#include "filter_string.h"
#include <QByteArray>
#include <QDebug>
#include <QRegularExpression>
#include <QString>
#include <functional>
#include <libcockatrice/utility/peglib.h>
Include dependency graph for filter_string.cpp:

Functions

static void setupParserRules ()

Variables

static peg::parser search (R"( Start <- QueryPartList ~ws <- [ ]+ QueryPartList <- ComplexQueryPart ( ws ("AND" ws)? ComplexQueryPart)* ws* ComplexQueryPart <- SomewhatComplexQueryPart ws "OR" ws ComplexQueryPart / SomewhatComplexQueryPart SomewhatComplexQueryPart <- [(] QueryPartList [)] / QueryPart QueryPart <- NotQuery / SetQuery / RarityQuery / CMCQuery / FormatQuery / PowerQuery / ToughnessQuery / ColorQuery / TypeQuery / OracleQuery / FieldQuery / GenericQuery NotQuery <- ('NOT' ws/'-') SomewhatComplexQueryPart SetQuery <- ('e'/'set') [:] FlexStringValue OracleQuery <- 'o' [:] MatcherString CMCQuery <- ('cmc'/'mv') ws? NumericExpression PowerQuery <- [Pp] 'ow' 'er'? ws? NumericExpression ToughnessQuery <- [Tt] 'ou' 'ghness'? ws? NumericExpression RarityQuery <- [rR] ':' Rarity Rarity <- [Cc] 'ommon'? / [Uu] 'ncommon'? / [Rr] 'are'? / [Mm] 'ythic'? / [Ss] 'pecial'? / [a-zA-Z] [a-z]* FormatQuery <- 'f' ':' Format / Legality ':' Format Format <- [a-zA-Z] [a-z]* Legality <- [Ll] 'egal'? / [Bb] 'anned'? / [Rr] 'estricted' TypeQuery <- [tT] 'ype'? [:] StringValue Color <- < [Ww] 'hite'? / [Uu] / [Bb] 'lack'? / [Rr] 'ed'? / [Gg] 'reen'? / [Bb] 'lue'? > ColorEx <- Color / [mc] ColorQuery <- [cC] 'olor'? <[iI]?> <[:!]> ColorEx* FieldQuery <- String [:] MatcherString / String ws? NumericExpression NonDoubleQuoteUnlessEscaped <- '\\\"'. / !["]. NonSingleQuoteUnlessEscaped<- "\\\'"./![']. UnescapedStringListPart<- !['":<>=! ]. SingleApostropheString <- (UnescapedStringListPart+ ws*)* ['] (UnescapedStringListPart+ ws*)* String <- SingleApostropheString / UnescapedStringListPart+ / ["]< NonDoubleQuoteUnlessEscaped * >["] / ['] <NonSingleQuoteUnlessEscaped*> ['] StringValue <- String / [(] StringList [)] StringList <- StringListString (ws? [,] ws? StringListString)* StringListString <- UnescapedStringListPart+ GenericQuery <- MatcherString # A String that can either be a normal string or a regex search string MatcherString <- RegexMatcher / NormalMatcher NormalMatcher <- String RegexMatcher <- '/' RegexMatcherString '/' RegexMatcherString <- ('\\/' / !'/' .)+ FlexStringValue <- CompactStringSet / String / [(] StringList [)] CompactStringSet <- StringListString ([,+] StringListString)+ NumericExpression <- NumericOperator ws? NumericValue NumericOperator <- [=:] / <[><!][=]?> NumericValue <- [0-9]+ )")
static std::once_flag init

Function Documentation

◆ setupParserRules()

void setupParserRules ( )
static

Variable Documentation

◆ init

std::once_flag init
static

◆ search

peg::parser search(R"( Start <- QueryPartList ~ws <- [ ]+ QueryPartList <- ComplexQueryPart ( ws ("AND" ws)? ComplexQueryPart)* ws* ComplexQueryPart <- SomewhatComplexQueryPart ws "OR" ws ComplexQueryPart / SomewhatComplexQueryPart SomewhatComplexQueryPart <- [(] QueryPartList [)] / QueryPart QueryPart <- NotQuery / SetQuery / RarityQuery / CMCQuery / FormatQuery / PowerQuery / ToughnessQuery / ColorQuery / TypeQuery / OracleQuery / FieldQuery / GenericQuery NotQuery <- ('NOT' ws/'-') SomewhatComplexQueryPart SetQuery <- ('e'/'set') [:] FlexStringValue OracleQuery <- 'o' [:] MatcherString CMCQuery <- ('cmc'/'mv') ws? NumericExpression PowerQuery <- [Pp] 'ow' 'er'? ws? NumericExpression ToughnessQuery <- [Tt] 'ou' 'ghness'? ws? NumericExpression RarityQuery <- [rR] ':' Rarity Rarity <- [Cc] 'ommon'? / [Uu] 'ncommon'? / [Rr] 'are'? / [Mm] 'ythic'? / [Ss] 'pecial'? / [a-zA-Z] [a-z]* FormatQuery <- 'f' ':' Format / Legality ':' Format Format <- [a-zA-Z] [a-z]* Legality <- [Ll] 'egal'? / [Bb] 'anned'? / [Rr] 'estricted' TypeQuery <- [tT] 'ype'? [:] StringValue Color <- < [Ww] 'hite'? / [Uu] / [Bb] 'lack'? / [Rr] 'ed'? / [Gg] 'reen'? / [Bb] 'lue'? > ColorEx <- Color / [mc] ColorQuery <- [cC] 'olor'? <[iI]?> <[:!]> ColorEx* FieldQuery <- String [:] MatcherString / String ws? NumericExpression NonDoubleQuoteUnlessEscaped <- '\\\"'. / !["]. NonSingleQuoteUnlessEscaped<- "\\\'"./![']. UnescapedStringListPart<- !['":<>=! ]. SingleApostropheString <- (UnescapedStringListPart+ ws*)* ['] (UnescapedStringListPart+ ws*)* String <- SingleApostropheString / UnescapedStringListPart+ / ["]< NonDoubleQuoteUnlessEscaped * >["] / ['] <NonSingleQuoteUnlessEscaped*> ['] StringValue <- String / [(] StringList [)] StringList <- StringListString (ws? [,] ws? StringListString)* StringListString <- UnescapedStringListPart+ GenericQuery <- MatcherString # A String that can either be a normal string or a regex search string MatcherString <- RegexMatcher / NormalMatcher NormalMatcher <- String RegexMatcher <- '/' RegexMatcherString '/' RegexMatcherString <- ('\\/' / !'/' .)+ FlexStringValue <- CompactStringSet / String / [(] StringList [)] CompactStringSet <- StringListString ([,+] StringListString)+ NumericExpression <- NumericOperator ws? NumericValue NumericOperator <- [=:] / <[><!][=]?> NumericValue <- [0-9]+ )") ( R"(Start <- QueryPartList~ws <- [ ]+QueryPartList <- ComplexQueryPart ( ws ("AND" ws)? ComplexQueryPart)* ws*ComplexQueryPart <- SomewhatComplexQueryPart ws "OR" ws ComplexQueryPart / SomewhatComplexQueryPartSomewhatComplexQueryPart <- [(] QueryPartList [)] / QueryPartQueryPart <- NotQuery / SetQuery / RarityQuery / CMCQuery / FormatQuery / PowerQuery / ToughnessQuery / ColorQuery / TypeQuery / OracleQuery / FieldQuery / GenericQueryNotQuery <- ('NOT' ws/'-') SomewhatComplexQueryPartSetQuery <- ('e'/'set') [:] FlexStringValueOracleQuery <- 'o' [:] MatcherStringCMCQuery <- ('cmc'/'mv') ws? NumericExpressionPowerQuery <- [Pp] 'ow' 'er'? ws? NumericExpressionToughnessQuery <- [Tt] 'ou' 'ghness'? ws? NumericExpressionRarityQuery <- [rR] ':' RarityRarity <- [Cc] 'ommon'? / [Uu] 'ncommon'? / [Rr] 'are'? / [Mm] 'ythic'? / [Ss] 'pecial'? / [a-zA-Z] [a-z]*FormatQuery <- 'f' ':' Format / Legality ':' FormatFormat <- [a-zA-Z] [a-z]*Legality <- [Ll] 'egal'? / [Bb] 'anned'? / [Rr] 'estricted'TypeQuery <- [tT] 'ype'? [:] StringValueColor <- < [Ww] 'hite'? / [Uu] / [Bb] 'lack'? / [Rr] 'ed'? / [Gg] 'reen'? / [Bb] 'lue'? >ColorEx <- Color / [mc]ColorQuery <- [cC] 'olor'? <[iI]?> <[:!]> ColorEx*FieldQuery <- String [:] MatcherString / String ws? NumericExpressionNonDoubleQuoteUnlessEscaped <- '\\\"'. / !["].NonSingleQuoteUnlessEscaped<- "\\\'"./!['].UnescapedStringListPart<- !['":<>=! ].SingleApostropheString <- (UnescapedStringListPart+ ws*)* ['] (UnescapedStringListPart+ ws*)*String <- SingleApostropheString / UnescapedStringListPart+ / ["]< NonDoubleQuoteUnlessEscaped * >["] / ['] <NonSingleQuoteUnlessEscaped*> [']StringValue <- String / [(] StringList [)]StringList <- StringListString (ws? [,] ws? StringListString)*StringListString <- UnescapedStringListPart+GenericQuery <- MatcherString# A String that can either be a normal string or a regex search stringMatcherString <- RegexMatcher / NormalMatcherNormalMatcher <- StringRegexMatcher <- '/' RegexMatcherString '/'RegexMatcherString <- ('\\/' / !'/' .)+FlexStringValue <- CompactStringSet / String / [(] StringList [)]CompactStringSet <- StringListString ([,+] StringListString)+NumericExpression <- NumericOperator ws? NumericValueNumericOperator <- [=:] / <[><!][=]?>NumericValue <- [0-9]+)" )
static