Namespace mata::parser¶
-
namespace parser
Parser from
.mataformat to automata (currentlyNfaandAfaare supported).This includes parsing either from files or from other streams (strings, etc.).
Typedefs
-
using Parsed = std::vector<ParsedSection>
Parsed data.
Functions
-
Parsed parse_mf(const std::string &input, bool keepQuotes = false)
Parses a string into an intermediary structure.
-
Parsed parse_mf(std::istream &input, bool keepQuotes = false)
Parses a stream into an intermediary structure.
-
ParsedSection parse_mf_section(std::istream &input, bool keepQuotes = false)
Parses one section from a stream into an intermediary structure.
-
ParsedSection parse_mf_section(const std::string &input, bool keepQuotes = false)
Parses one section from a string into an intermediary structure.
-
void init()
registers dispatcher
-
nfa::Nfa create_nfa(const std::string &pattern, bool use_epsilon = false, mata::Symbol epsilon_value = 306, bool use_reduce = true, const Encoding encoding = Encoding::Latin1)
Creates NFA from regular expression using RE2 parser.
At https://github.com/google/re2/wiki/Syntax, you can find the syntax of regular expressions with following futher limitations: 1) If you use UTF8 encoding, the created NFA will have the values of bytes instead of full symbols. For example, the character Ā whose Unicode code point is U+0100 and is represented in UTF8 as two bytes c4 80 will have two transitions, one with c4 followed with by 80, to encode it. 2) The created automaton represents the language of the regex and is not expected to be used in regex matching. Therefore, stuff like ^, $, , etc. are ignored in the regex.
- Parameters:
pattern – regex as a string
use_epsilon – whether to keep epsilon transitions in created NFA
epsilon_value – symbol representing epsilon
use_reduce – if set to true the result is trimmed and reduced using simulation reduction
encoding – encoding of the regex, default is Latin1
- Returns:
Nfa corresponding to pattern
-
struct ParsedSection
- #include <parser.hh>
Parsed data (single section)
Public Functions
-
inline bool empty() const
Is the section empty?
-
bool operator==(const ParsedSection &rhs) const
Equality operator.
-
const std::vector<std::string> &operator[](const std::string &key) const
subscript operator for the key-value store
-
inline bool haskey(const std::string &key) const
check whether the key-value store contains a key
-
inline bool empty() const
-
using Parsed = std::vector<ParsedSection>