-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syntax for specifying operator precedence and associativity #15
Comments
I should note that I am not a fan of Haskell's parser programming interface. I'm not actually sure what happens when one specifies different precedence/associativity for the same operator, in two different modules. I am hoping that whatever solution we arrive at will be compatible with modularity. Coq's |
In any case, we should draft out a few basic examples of things we'd want to do, i.e., the kinds of operator syntax we'd like to specify. The usual suspects are:
Something that always bothers me is that precedence is typically specified as some arbitrary, hard-coded number. I would much prefer to say something like "I would like my operator to have higher precedence than |
Haskell doesn't do custom unary operators. For the moment, we can leave them built-in and later consider whether to just use Haskell's simple model or try to come up with something more. This is a low priority thing |
I believe Swift has a more "relational" specification of precedence levels (e.g., "this is above that"). It gets tricky because you need to make sure it's deterministic, feasible, etc. |
Right now, we are lexing and parsing operators like
+
,-
, etc., and then doing some late-stage parsing to assembleOpRegion
s into proper expression-level applications in AST. But we're doing so based on some hard-coded rules.We should be exposing some kind of syntax/mechanism for users to control this late-stage parsing, so that they may define their own late-stage parsers for this kind of thing. Basically, something like Haskell's
infixl
andinfixr
constructs.The text was updated successfully, but these errors were encountered: