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

Regent: Parsing ambiguity in consecutive escapes #522

Open
sparkasaurusRex opened this issue Apr 20, 2019 · 2 comments

Comments

@sparkasaurusRex
Copy link

commented Apr 20, 2019

It looks like Regent has trouble parsing when two quoted statements are close to each other. I think there is also an issue for rexpr too. My fix has been to surround quoted statements with ;.

import "regent"

local function genStatement(alpha, beta)
  return rquote
    alpha = beta + 3
  end
end

task toplevel()
  var a = 1
  var b = 2
  [genStatement(a, b)] -- Fix by adding `;` here
  [genStatement(b, a)]
end
legion/language/src/regent/specialize.t:144: Errors reported during typechecking.
../bug.rg:12: unable to specialize quoted statement as an expression
  [genStatement(a, b)]
  ^

stack traceback:
	[C]: in function 'error'
	src/terralib.lua:388: in function 'finishandabortiferrors'
	/home/ellis/repos/legion/language/src/common/report.t:56: in function 'error'
	/home/ellis/repos/legion/language/src/regent/specialize.t:144: in function 'expr'
	/home/ellis/repos/legion/language/src/regent/specialize.t:547: in function 'expr'
	/home/ellis/repos/legion/language/src/regent/specialize.t:1639: in function 'stat'
	/home/ellis/repos/legion/language/src/regent/specialize.t:1369: in function 'block'
	/home/ellis/repos/legion/language/src/regent/specialize.t:1920: in function </home/ellis/repos/legion/language/src/regent/specialize.t:1899>
	/home/ellis/repos/legion/language/src/regent/passes.t:59: in function </home/ellis/repos/legion/language/src/regent/passes.t:57>
@lightsighter lightsighter added the Regent label Apr 23, 2019
@elliottslaughter

This comment has been minimized.

Copy link
Contributor

commented Apr 29, 2019

This issue is something we inherited from Terra. There is an ambiguity in the expression [...][...]: is this two escapes back-to-back, or is this a nested array reference?

Terra's solution is to insert the ; implicitly when the two sets of brackets are on different lines. I've never been super happy with this, so I didn't implement it in Regent. But I'm not sure there are any other great solutions, so maybe it's time to bite the bullet and just do it.

@elliottslaughter elliottslaughter changed the title Regent: Failing to parse metaprogrammed statements Regent: Parsing ambiguity in consecutive escapes Apr 29, 2019
@elliottslaughter

This comment has been minimized.

Copy link
Contributor

commented Aug 28, 2019

Unfortunately I think this is not something we're able to fix at the moment, though we could potentially migrate to the solution proposed at zdevito/terra#385 (comment) --- but this would be a backwards incompatible change, so it's not obvious the benefits outweigh the costs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.