X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FConsole%2FParse.hh;h=4303fc2a4d162dfb8ae21fa58253bb76fe28df64;hb=a1fdb7bb122f0b05be809a922d4b7ef5e125fa67;hp=cfa871be5c0c6de62f1002099d108a848bdcaf6e;hpb=958bdb52c39fa39f4ef91cafd9628bcb4f85a03c;p=senf.git diff --git a/Utils/Console/Parse.hh b/Utils/Console/Parse.hh index cfa871b..4303fc2 100644 --- a/Utils/Console/Parse.hh +++ b/Utils/Console/Parse.hh @@ -85,11 +85,12 @@ returned as punctuation tokens - - - - - + + + + + +
/path component separator
( )argument grouping
{ }directory grouping
;command terminator
, =punctuation tokens
#Comments are marked with '#' and continue to the end of the line
/path component separator
( )argument grouping
{ }directory grouping
;command terminator
, =punctuation tokens
\subsection console_basic Basic elements @@ -205,6 +206,8 @@ namespace senf { namespace console { + namespace detail { class FilePositionWithIndex; } + namespace detail { struct ParserAccess; } /** \brief Single argument token @@ -253,7 +256,10 @@ namespace console { }; Token(); ///< Create empty token - Token(TokenType type, std::string token); ///< Create token with given type and value + Token(TokenType type, std::string token); + ///< Create token with given type and value + Token(TokenType type, std::string token, detail::FilePositionWithIndex const & pos); + ///< Create token with given type and value std::string const & value() const; ///< String value of token @@ -261,6 +267,10 @@ namespace console { TokenType type() const; ///< Token type + unsigned line() const; ///< Line number of token in source + unsigned column() const; ///< Column number of token in source + unsigned index() const; ///< Index (char count) of token in source + bool is(unsigned tokens) const; ///< Check, whether tokens type matches \a tokens /**< \a tokens is a bit-mask of token types to check. */ @@ -272,6 +282,9 @@ namespace console { private: TokenType type_; std::string token_; + unsigned line_; + unsigned column_; + unsigned index_; }; std::ostream & operator<<(std::ostream & os, Token const & token); @@ -599,6 +612,11 @@ namespace console { of the command). The argument tokens are written into \a info. */ + void parsePath(std::string const & path, ParseCommandInfo & info); + ///< Parse \a path + /**< parsePath() parses the string \a path as an arbitrary + command path. The result is written into \a info. */ + std::string::size_type parseIncremental(std::string const & commands, Callback cb); ///< Incremental parse /**< An incremental parse will parse all complete statements @@ -610,6 +628,12 @@ namespace console { to be terminated explicitly. This means, that the last ';' is \e not optional in this case. */ + static bool isSpecialChar(char ch); ///< Check, if \a ch is a special character + static bool isPunctuationChar(char ch); ///< Check, if \a ch is a punctuation character + static bool isSpaceChar(char ch); ///< Check, if \a ch is a space character + static bool isInvalidChar(char ch); ///< Check, if \a ch is an invalid character + static bool isWordChar(char ch); ///< Check, if \a ch is a word character + /** \brief Exception thrown when the parser detects an error */ struct ParserErrorException : public SyntaxErrorException { explicit ParserErrorException(std::string const & msg) : SyntaxErrorException(msg) {} };