]> git.lyx.org Git - lyx.git/blobdiff - src/tex2lyx/Parser.cpp
FindAdv: Comments
[lyx.git] / src / tex2lyx / Parser.cpp
index 495f8524fe905645b9ad584384c9ec51dcfbe723..5b12dddb9e4854a0683c67f4cfddee1e47f9ba93 100644 (file)
@@ -453,7 +453,7 @@ bool Parser::good()
 }
 
 
-bool Parser::hasOpt()
+bool Parser::hasOpt(string const l)
 {
        // An optional argument can occur in any of the following forms:
        // - \foo[bar]
@@ -479,7 +479,7 @@ bool Parser::hasOpt()
                putback();
                break;
        }
-       bool const retval = (next_token().asInput() == "[");
+       bool const retval = (next_token().asInput() == l);
        pos_ = oldpos;
        return retval;
 }
@@ -650,6 +650,27 @@ string const Parser::plainCommand(char left, char right, string const & name)
 }
 
 
+string const Parser::getCommandLatexParam()
+{
+       if (!good())
+               return string();
+       string res;
+       size_t offset = 0;
+       while (true) {
+               if (pos_ + offset >= tokens_.size())
+                       tokenize_one();
+               if (pos_ + offset >= tokens_.size())
+                       break;
+               Token t = tokens_[pos_ + offset];
+               if (t.cat() == catBegin)
+                       break;
+               res += t.asInput();
+               ++offset;
+       }
+       return res;
+}
+
+
 Parser::Arg Parser::verbatimStuff(string const & end_string, bool const allow_linebreak)
 {
        if (!good())