You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Several PFA library functions (e.g., interp.linear) require records with the field name to, but trying to define a record with a field to leads to an error.
Minimal reproducible example:
In [1]: fromtitusimportprettypfa
:
: doc=""" : types: MyRecord = record(x: int, to: double); : input: int : output: int : action: 1 : """
:
: prettypfa.jsonNode(doc)
:
:
---------------------------------------------------------------------------PrettyPfaExceptionTraceback (mostrecentcalllast)
<ipython-input-1-0a736b5ef5a3>in<module>()
8""" 9---> 10 prettypfa.jsonNode(doc) 11/Users/brandon/miniconda2/lib/python2.7/site-packages/titus/prettypfa.pyc in jsonNode(text, lineNumbers, check, version, subs, **subs2) 2214 :return: PFA in Pythonized JSON 2215 """->2216returnast(text, check, version, subs, **subs2).jsonNode(lineNumbers, set())
22172218defjson(text, lineNumbers=True, check=True, version=None, subs={}, **subs2):
/Users/brandon/miniconda2/lib/python2.7/site-packages/titus/prettypfa.pycinast(text, check, version, subs, **subs2)
2187parser.initialize(lex, yacc)
2188->2189out=parser.parse(text, subs2)
21902191anysubs=lambdax: x/Users/brandon/miniconda2/lib/python2.7/site-packages/titus/prettypfa.pycinparse(self, text, subs)
2122self.text=text2123self.subs=subs->2124out=self.yacc.parse(text, lexer=self.lexer)
2125ifself.wholeDocument:
2126returnout/Users/brandon/miniconda2/lib/python2.7/site-packages/ply/yacc.pycinparse(self, input, lexer, debug, tracking, tokenfunc)
329returnself.parseopt(input, lexer, debug, tracking, tokenfunc)
330else:
-->331returnself.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
332333/Users/brandon/miniconda2/lib/python2.7/site-packages/ply/yacc.pycinparseopt_notrack(self, input, lexer, debug, tracking, tokenfunc)
1197errtoken.lexer=lexer1198self.state=state->1199tok=call_errorfunc(self.errorfunc, errtoken, self)
1200ifself.errorok:
1201# User must have done some kind of panic/Users/brandon/miniconda2/lib/python2.7/site-packages/ply/yacc.pycincall_errorfunc(errorfunc, token, parser)
191_token=parser.token192_restart=parser.restart-->193r=errorfunc(token)
194try:
195del_errok, _token, _restart/Users/brandon/miniconda2/lib/python2.7/site-packages/titus/prettypfa.pycinp_error(p)
2103else:
2104offendingLine="\n".join(insertArrow(lines[(lineno-1):(lineno+2)], 1))
->2105raisePrettyPfaException("Parsing syntax error on line {0}:\n{1}".format(p.lineno, offendingLine))
21062107self.yacc=yacc.yacc(debug=False, write_tables=False)
PrettyPfaException: Parsingsyntaxerroronline2:
types: MyRecord=record(x: int, to: double);
input: int<----output: int
The text was updated successfully, but these errors were encountered:
That's a PrettyPFA limitation— which developed separately from the PFA library. "to" is a reserved word in the PrettyPFA parser, but it's a required field in records that passed into interpolation functions.
Since the PFA specification is more robust than PrettyPFA (which is just an implementation), I think the best solution to this is to modify PrettyPFA, un-reserving "to" as a keyword and replacing it with some punctuation, such as "-->".
bmwilly
pushed a commit
to arenadotio/hadrian
that referenced
this issue
Apr 30, 2017
`to` is both a reserved keyword in PrettyPFA and a required key
name in the PFA `interp` library, which results in an error when
trying to use `interp` functions in PrettyPFA.
As a fix, rename the `to` keyword to `to_`.
Fixesmodelop#34
bmwilly
pushed a commit
to arenadotio/hadrian
that referenced
this issue
May 1, 2017
`to` is both a reserved keyword in PrettyPFA and a required key
name in the PFA `interp` library, which results in an error when
trying to use `interp` functions in PrettyPFA.
As a fix, rename the `to` keyword to `to_`.
Fixesmodelop#34
Several PFA library functions (e.g.,
interp.linear
) require records with the field nameto
, but trying to define a record with a fieldto
leads to an error.Minimal reproducible example:
The text was updated successfully, but these errors were encountered: