Bug fix: convertLaTeXTokenStreamRec().

This commit is contained in:
Achim D. Brucker 2018-05-19 23:36:52 +01:00
parent edbdf5fd03
commit b79230e35a
1 changed files with 8 additions and 9 deletions

View File

@ -86,7 +86,6 @@ object DofConverter {
deMarkupRec(Nil, tokens) deMarkupRec(Nil, tokens)
} }
def convertIsaDofCommand(cmd: String, tokens: List[LaTeXToken]): List[LaTeXToken] = { def convertIsaDofCommand(cmd: String, tokens: List[LaTeXToken]): List[LaTeXToken] = {
@tailrec @tailrec
def convertType(head: List[LaTeXToken], tail: List[LaTeXToken]): Tuple2[String,List[LaTeXToken]] = { def convertType(head: List[LaTeXToken], tail: List[LaTeXToken]): Tuple2[String,List[LaTeXToken]] = {
@ -189,16 +188,16 @@ object DofConverter {
} }
def convertLaTeXTokenStream(tokens: List[LaTeXToken]): List[LaTeXToken] = { def convertLaTeXTokenStream(tokens: List[LaTeXToken]): List[LaTeXToken] = {
@tailrec @tailrec
def convertLaTeXTokenStreamRec(acc:List[LaTeXToken], tokens: List[LaTeXToken]): List[LaTeXToken] = { def convertLaTeXTokenStreamRec(acc: List[LaTeXToken], tokens: List[LaTeXToken]): List[LaTeXToken] = {
val (pre, tail) = tokens match { val (res, tail, rec) = tokens match {
case Nil => (Nil, Nil) case Nil => (Nil, Nil, false)
case COMMAND("""\isacommand""") :: CURLYOPEN :: RAWTEXT(cmd) :: CURLYOPEN case COMMAND("""\isacommand""") :: CURLYOPEN :: RAWTEXT(cmd) :: CURLYOPEN
:: COMMAND("""\isacharasterisk""") :: CURLYCLOSE :: CURLYCLOSE :: ts => (convertIsaDofCommand(cmd, ts), Nil) :: COMMAND("""\isacharasterisk""") :: CURLYCLOSE :: CURLYCLOSE :: ts => (convertIsaDofCommand(cmd, ts), Nil, false)
case t :: ts => (t::Nil,ts) case t :: ts => (t::Nil, ts, true)
} }
if (tail == Nil) pre if (! rec) acc++res
else convertLaTeXTokenStreamRec(acc++pre, tail) else convertLaTeXTokenStreamRec(acc++res, tail)
} }
convertLaTeXTokenStreamRec(Nil, tokens) convertLaTeXTokenStreamRec(Nil, tokens)
} }