-
Haskell allows users to define custom infix operators (see, e.g., https://jplahn.gitbooks.io/a-happy-haskell/content/functions/infix_operators.html for examples). Is it possible to make a Langium grammar, or extend the Langium parser, to similarly allow users to declare / define custom infix notation? (or to do perhaps a nearby but weaker variant of this?) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @ym-han, I think that should be possible purely by implementing additional parser rules. Kind of similar to the arithmetics example, you would have a new kind of expression: langium/examples/arithmetics/src/language-server/arithmetics.langium Lines 25 to 26 in b2a6fe9
Note that you can replace <+> :: Num a => a -> a -> a
<+> b = a + b
ghci> 1 <+> 1
2 That would require something like this:
|
Beta Was this translation helpful? Give feedback.
Hey @ym-han,
I think that should be possible purely by implementing additional parser rules. Kind of similar to the arithmetics example, you would have a new kind of expression:
langium/examples/arithmetics/src/language-server/arithmetics.langium
Lines 25 to 26 in b2a6fe9