krrepo / lea

Automatically exported from code.google.com/p/lea
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Parsing error when parsing "embedded" CPT in Leapp #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Consider the following CPT example in Leapp;

x = ?:(1/3)
y = ?:(1/4)
z1 = ?! ( ~x & ~y -> ?:(1/5),
          ~x &  y -> ?:(1/7),
           x & ~y -> ?:(1/2),
           x &  y -> ?:(1/2))

Notice that z1 is independent of y when x is true (i.e. "context-specific 
Independence"). 
The following refactoring

z4 = ?! ( ~x -> ?! ( ~y -> ?:(1/5),
                      y -> ?:(1/7)),
           x -> ?:(1/2))

is not correctly parsed by Leapp, which reports

Python error: too many values to unpack (expected 2)

After activating the debug mode of Leapp, the following trace is displayed:

Traceback (most recent call last):
  File "/Users/admin/Documents/lea2/leapp_console.py", line 108, in startCmdLoop
    self.execLeappTranslatorMultilineStatement(rMultilineStatement)
  File "/Users/admin/Documents/lea2/leapp_console.py", line 71, in execLeappTranslatorMultilineStatement
    pMultilineStatement = LeappTranslator.getTarget00(rMultilineStatement)
  File "/Users/admin/Documents/lea2/leapp_translator.py", line 107, in getTarget00
    pStatementLines.append(identStr+LeappTranslator.getTarget0(unindentedLeaStatementLine))
  File "/Users/admin/Documents/lea2/leapp_translator.py", line 143, in getTarget0
    return headTarget + LeappTranslator.getTarget0b(sourceFragment) + tailTarget
  File "/Users/admin/Documents/lea2/leapp_translator.py", line 151, in getTarget0b
    target = LeappTranslator.getTarget1(sourceFragment)
  File "/Users/admin/Documents/lea2/leapp_translator.py", line 189, in getTarget1
    unstringedTargetFragment = LeappTranslator.getTarget(unstringedFragment)
  File "/Users/admin/Documents/lea2/leapp_translator.py", line 266, in getTarget
    targetFragment = LeappTranslator.parse(targetFragment,'?!' ,'(',')','Lea.buildCPT(*(%s,))',LeappTranslator.treatCPTExpression)
  File "/Users/admin/Documents/lea2/leapp_translator.py", line 364, in parse
    body = treatFunc(body)
  File "/Users/admin/Documents/lea2/leapp_translator.py", line 258, in treatCPTExpression
    newCPTExpression = ','.join('(%s,%s)'%(f(condExpr),distribExpr) for (condExpr,distribExpr) in cptItems)
  File "/Users/admin/Documents/lea2/leapp_translator.py", line 258, in <genexpr>
    newCPTExpression = ','.join('(%s,%s)'%(f(condExpr),distribExpr) for (condExpr,distribExpr) in cptItems)
ValueError: too many values to unpack (expected 2)

Original issue reported on code.google.com by pde@n-side.com on 14 Mar 2015 at 2:04

GoogleCodeExporter commented 9 years ago
Corrected in Lea 2.1.1

Original comment by pde@n-side.com on 18 Mar 2015 at 12:18