Alloy Community

User login

Suggestion for better parsing errors

 
Posted on: Tue, 09/09/2008 - 20:10
Joined: 2008-09-09
Points: 8
User is offline
Suggestion for better parsing errors
Here's a suggestion.  I got a strange syntax error because I was loking at the book
and copying and forgot to copy (...) as [...], due to the syntax change to Alloy4.
It gave me an error on a comma and said it expected a ).  Of course putting that in
is wrong.

My suggestion is that you run several of the old alloy programs through the new parser,
to find common syntax errors that result from the change of () to [] for predicates
and functions, and then change the syntax error recovery of your parser so that it
suggests to the user that perhaps they may have forgotten to use [] in such cases.

Gary T. Leavens
 
Posted on: Tue, 09/09/2008 - 20:45    #1
Joined: 2008-09-09
Points: 8
User is offline
Another thought on this.  It's more of a difference from Alloy3, but
perhaps you should consider (or allow) the use of square brackets []
to declare functions and predicates.  It's a bit odd to use () in declarations
and use [] when applying the function or predicate...

Gary T. Leavens
 
Posted on: Tue, 09/09/2008 - 21:24    #2
Joined: 2008-09-09
Points: 8
User is offline
It seems that you already do allow [] to be used
in the declarations of predicates and functions.
So never mind this second suggestion.

Gary T. Leavens
 
Posted on: Fri, 09/12/2008 - 12:05    #3
Joined: 2008-05-15
Points: 334
User is offline
Dear Gary:

That's a very good suggestion. I will try to improve the syntax error messages.

And you were right with your second suggestion as well:
indeed predicate definitions can use "[ ]" as well as "( )".
So the following is a legal definition:

    pred equal [a, b: univ]  { a = b }

And in fact, if there are no parameters,
we can leave out the [ ] or ( ) entirely.

    pred atLeastTwoNodes { ! lone Node }

Sincerely,
Felix Chang
Alloy4 Developer

Syndicate content  

The development of this site is supported by the National Science Foundation under Computing Research Infrastructure Grant No. 0707612.

Theme originally designed by Chris Herberte