From a77cd8c0c6bce535f3bb5fc873e1f9bbabce0a5a Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 18 Apr 2008 12:26:21 +0000 Subject: [PATCH] cleanup parser code at least git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@24323 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/tex2lyx/Parser.cpp | 6 ++++-- src/tex2lyx/Parser.h | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/tex2lyx/Parser.cpp b/src/tex2lyx/Parser.cpp index f1b3514316..3ceda050f5 100644 --- a/src/tex2lyx/Parser.cpp +++ b/src/tex2lyx/Parser.cpp @@ -307,7 +307,7 @@ string Parser::getFullOpt() Arg arg = getFullArg('[', ']'); if (arg.first) return '[' + arg.second + ']'; - return arg.second; + return string(); } @@ -317,14 +317,16 @@ string Parser::getOpt() return res.empty() ? string() : '[' + res + ']'; } + string Parser::getFullParentheseArg() { Arg arg = getFullArg('(', ')'); if (arg.first) return '(' + arg.second + ')'; - return arg.second; + return string(); } + string const Parser::verbatimEnvironment(string const & name) { if (!good()) diff --git a/src/tex2lyx/Parser.h b/src/tex2lyx/Parser.h index 5dcbc56aaa..713cbfcfa1 100644 --- a/src/tex2lyx/Parser.h +++ b/src/tex2lyx/Parser.h @@ -148,20 +148,29 @@ public: std::string getArg(char left, char right); /*! * \returns getFullArg('[', ']') including the brackets or the - * empty string if no argument was found. + * empty string if there is no such argument. */ std::string getFullOpt(); - /// \returns getArg('[', ']') including the brackets + /*! + * \returns getArg('[', ']') including the brackets or the + * empty string if there is no such argument. + */ std::string getOpt(); + /*! + * \returns getFullArg('(', ')') including the parentheses or the + * empty string if there is no such argument. + */ + std::string getFullParentheseArg(); /*! * \returns the contents of the environment \p name. * \begin{name} must be parsed already, \end{name} * is parsed but not returned. */ - std::string getFullParentheseArg(); - /// \returns getArg('(', ')') including the parentheses std::string const verbatimEnvironment(std::string const & name); - /// Returns the character of the current token and increments the token position. + /*! + * Returns the character of the current token and increments + * the token position. + */ char getChar(); /// void error(std::string const & msg);