Opened 9 years ago

Closed 9 years ago

#498 closed defect (fixed)

blank atomspecs cause errors

Reported by: Elaine Meng Owned by: Greg Couch
Priority: blocker Milestone:
Component: Command Line Version:
Keywords: Cc: Eric Pettersen, Tom Goddard, Conrad Huang
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

If the atomspec is blank, none of the special color names (byhet, bychain, byseq etc.) work in the current daily build. For example "color #1 byhet" works, but "color byhet" gives error:

Missing or invalid "objects" argument: (1:1) "byseq" is not a selector name : selector_name as_term atom_specifier

Don't know who's the culprit, reassign as needed.

Change History (6)

comment:1 by Elaine Meng, 9 years ago

Summary: "color byhet" and other special colornames broken if blank atomspecblank atomspecs cause errors

Oh, it's worse than I thought... seems like blank atomspec causes an error in many (all?) commands, even without special color names, e.g.

color red
style sphere
(etc.)

comment:2 by Elaine Meng, 9 years ago

Cc: Conrad Huang added; Greg Couch removed
Owner: changed from Conrad Huang to Greg Couch
Status: newassigned

comment:3 by Conrad Huang, 9 years ago

The color command is registered as

color (ObjectsArg|EmptyArg) [ColorArg|S!pecialColors]

When parsing "color red", ObjectsArg.parse calls AtomSpecArg.parse which calls AtomSpecArg._parse_unquoted. The parser (eventually) figures out that "red" is a word and calls _AtomSpecSemantics.selector_name to process it. selector_name sees that "red" is not a registered selector and raises grako.FailedSemantics. The problem is that it tries to set the "pos" and "endpos" attributes of the exception instance, but the parser catches the constructed FailedSemantics exception and reraises a grako.FailedParse exception. The latter does not use our custom "pos" attributes (0 in this case); instead, it uses the "pos" constructed by the parser (3 in this case). The FailedParse exception is caught by AtomSpecArg._parse_unquoted and converted to an AnnotationError with attribute "offset" set to "pos". This AnnotationError is caught by Or.parse, which reraises the Annotation exception because "offset" is non-zero.

I'm reluctant to change the exception processing in parsing since FailedSemantics is the exception that the grako documentation recommends. Changing Or.parse to ignore the offset value makes "color red" work, but I don't know what it breaks. Greg?

Last edited 9 years ago by Greg Couch (previous) (diff)

comment:4 by Conrad Huang, 9 years ago

Greg wrote the cli.Or class and needs to determine how to handle AnnotationError exceptions. Still not sure when this broke.

comment:5 by Greg Couch, 9 years ago

This bug looks like it is due to a change in grako 3.17: "Report the parse exception (grako.exceptions.FailedParse) ocurring furthest in the input so error messages are more meningful even when no cut (~) expressions are used."

ChimeraX's AnnotationErrors expects the "pos" attribute to reflect how much input was successfully parsed before there was an error. In this case, was the "red" successfully parsed or not? From ChimeraX's point of view, it was not, it did not match an atomspec. But grako did find a token. Need to look at how atomspec parser works.

Last edited 9 years ago by Greg Couch (previous) (diff)

comment:6 by Greg Couch, 9 years ago

Resolution: fixed
Status: assignedclosed

Reverted to grako 3.16.5.

Note: See TracTickets for help on using tickets.