Skip to content
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

Parse infix constructors #16

Open
noughtmare opened this issue Jul 15, 2024 · 1 comment · May be fixed by #19
Open

Parse infix constructors #16

noughtmare opened this issue Jul 15, 2024 · 1 comment · May be fixed by #19

Comments

@noughtmare
Copy link
Contributor

noughtmare commented Jul 15, 2024

I've implemented a level oriented breadth first renumbering algorithm, but I didn't like how I had to write the semantic rules for Leaf:

sem Bin
  | Leaf lhs.res = { Leaf @x }
         (loc.x, lhs.xss) = { let ((x:xs):xss) = @lhs.xss in (x, (x+1:xs):xss) }

I would like to write this instead:

sem Bin
  | Leaf lhs.res = { Leaf @x }
         loc.((x : xs) : xss) = @lhs.xss
         lhs.xss = ((@x+1) : @xs) : @xss

But UUAGC doesn't parse infix constructors yet:

Main.ag:23:18: error: parser expecting symbol ) or @ or (symbol , ...)*
pattern  : 
help     : 
action   : deleting: symbol : at line 23, column 18 of file "Main.ag"
@noughtmare
Copy link
Contributor Author

noughtmare commented Jul 15, 2024

It's a bit annoying that : is a reserved keyword, but I guess we can work around it. I now have a working prototype. This now compiles properly for me:

sem Bin
  | Leaf loc.((x:xs):xss) = @lhs.xss
         lhs.res = Leaf @x
         lhs.xss = (@x + 1 : @xs) : @xss
  | Bin loc.(xs : xss') = @lhs.xss
        l.xss = @xss'
        +xss = (@xs :)
        lhs.res = Bin @l.res @r.res

@noughtmare noughtmare linked a pull request Jul 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant