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

Some TC issues in concrete patterns #481

Closed
PaulKlint opened this issue Jan 9, 2014 · 3 comments
Closed

Some TC issues in concrete patterns #481

PaulKlint opened this issue Jan 9, 2014 · 3 comments

Comments

@PaulKlint
Copy link
Member

Concrete patterns start to behave as expected. Here are some TC issues I found:

module experiments::Compiler::Examples::Tst

import ParseTree;

syntax A = a: "a";

syntax As = as: A+ alist;

syntax C = c: A a "x" As as;

test bool tstAs(){
    pt = parse(#As, "aaa");
    return as(al) := pt && pt is as && pt.alist == al;
}

test bool tstC(){
    pt = parse(#C, "axaaa");
    return c(A a, As as) := pt && pt.a == a && pt.as == as && size([x | x <- as.alist]) == 3;
}

gives

error("Name x is not in scope",|rascal:///experiments/Compiler/Examples/Tst.rsc|(361,1,<18,68>,<18,69>))
error("Only constructors or productions with a different arity are available",|rascal:///experiments/Compiler/Examples/Tst.rsc|(199,6,<13,11>,<13,17>))
error("Type of pattern could not be computed",|rascal:///experiments/Compiler/Examples/Tst.rsc|(199,6,<13,11>,<13,17>))
error("Type A+ is not enumerable",|rascal:///experiments/Compiler/Examples/Tst.rsc|(365,13,<18,72>,<18,85>))
error("A+ and inferred(1) incomparable",|rascal:///experiments/Compiler/Examples/Tst.rsc|(227,14,<13,39>,<13,53>))
error("Type of pattern could not be computed",|rascal:///experiments/Compiler/Examples/Tst.rsc|(304,13,<18,11>,<18,24>))
error("Name size is not in scope",|rascal:///experiments/Compiler/Examples/Tst.rsc|(355,4,<18,62>,<18,66>))
error("Only constructors or productions with a different arity are available",|rascal:///experiments/Compiler/Examples/Tst.rsc|(304,13,<18,11>,<18,24>))
@ghost ghost assigned mahills Jan 9, 2014
@mahills
Copy link
Member

mahills commented Jan 10, 2014

I just pushed something that fixes a bit of this, but need to look through the production-handling code to make sure that, when using the constructor forms, whitespace is not counted as an argument position (it is now, which is why the above don't match, but I'm assuming we don't want it to).

@PaulKlint
Copy link
Member Author

Thanks @mahills, the situation is indeed improved. The current situation is:

module experiments::Compiler::Examples::Tst

import Exception;
import List;
import IO;
import ParseTree;

syntax A = a: "a";

syntax As = as: A+ alist;

syntax C = c: A a "x" As as;


test bool tstAs(){
    pt = parse(#As, "aaa");
    return as(al) := pt && pt is as && pt.alist == al;
}

test bool tstC(){
    pt = parse(#C, "axaaa");
    return c(A a, As as) := pt && pt.a == a && pt.as == as && size([x | x <- as.alist]) == 3;
}

gives

error("Only constructors or productions with a different arity are available",|rascal:///experiments/Compiler/Examples/Tst.rsc|(347,13,<22,11>,<22,24>))
error("Type of pattern could not be computed",|rascal:///experiments/Compiler/Examples/Tst.rsc|(347,13,<22,11>,<22,24>))
error("A+ and inferred(1) incomparable",|rascal:///experiments/Compiler/Examples/Tst.rsc|(270,14,<17,39>,<17,53>))
error("Type of pattern could not be computed",|rascal:///experiments/Compiler/Examples/Tst.rsc|(242,6,<17,11>,<17,17>))
error("Only constructors or productions with a different arity are available",|rascal:///experiments/Compiler/Examples/Tst.rsc|(242,6,<17,11>,<17,17>))

@PaulKlint
Copy link
Member Author

All the above case now work. Great work @mahills !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants