lshifr / CodeFormatter

A pretty-printer for Mathematica language, working on the box level
Other
33 stars 7 forks source link

CodeFormatterPrint sometimes produces unparsable code #8

Open Masterxilo opened 8 years ago

Masterxilo commented 8 years ago

I'd like to use CodeFormatterPrint to serialize definitions and a canonical but readable way. For this, all the code it produces should, when evaluated, restore the definitions I had in place.

But this does not always work:

ClearAll@f
f[veryveryveryveryveryveryveryverylongname, 
    veryveryveryveryveryveryveryverylongname] /; a > 0 := a;
CodeFormatterPrint@f

produces

f[    
     veryveryveryveryveryveryveryverylongname,
     veryveryveryveryveryveryveryverylongname
 ]
/;
  (a > 0) :=
     a

which cannot be parsed correctly because /; stands on its own.

/; should be at the end of the line above such that the expression is not yet complete.

Masterxilo commented 8 years ago

Probably a fix similar to this is needed: https://github.com/lshifr/CodeFormatter/pull/7