rascal

Rascal ambiguity not resolved by disambiguation rules

梦想与她 提交于 2019-12-07 07:15:24
I'm trying to get a disambiguation working, one in the same vein as the question I asked a few days ago. In that previous question, there was an undocumented limitation in the language implementation; I'm wondering if there's something similar going on here. Tests [tuvw]1 are all throwing ambiguity exceptions (BTW: How do you catch those? [Edit: answered]). All of them look like they ought to pass. Note that they have to be unambiguous in order to pass. Neither the priority rule Scheme nor the reserve rules UnknownScheme[23] seem to be removing the ambiguity. There might be some interaction

How to cast a value type to Map in Rascal?

人走茶凉 提交于 2019-12-05 13:30:53
I have a variable of type value that stores a map, but I can not access the values by providing the keys: rascal>a value: ("s":"s") rascal>a["s"] |stdin:///|(2,3,<1,2>,<1,5>): subscript not supported on value at |stdin:///|(2,3,<1,2>,<1,5>) ☞ Advice How can I parse the value to map in order to be able to retrieve my value ? if (map[str,str] myMap := a) { // do stuff with myMap } else { throw "<a> is not a map?"; } 来源: https://stackoverflow.com/questions/20221445/how-to-cast-a-value-type-to-map-in-rascal

Layout in Rascal

孤者浪人 提交于 2019-12-02 13:53:43
问题 When I import the Lisra recipe, import demo::lang::Lisra::Syntax; This creates the syntax: layout Whitespace = [\t-\n\r\ ]*; lexical IntegerLiteral = [0-9]+ !>> [0-9]; lexical AtomExp = (![0-9()\t-\n\r\ ])+ !>> ![0-9()\t-\n\r\ ]; start syntax LispExp = IntegerLiteral | AtomExp | "(" LispExp* ")" ; Through the start syntax -definition, layout should be ignored around the input when it is parsed, as is stated in the documentation: http://tutor.rascal-mpl.org/Rascal/Declarations/SyntaxDefinition

Pretty printing AST in Rascal

本秂侑毒 提交于 2019-12-02 12:10:02
问题 I am trying to pretty print an AST generated from createAstFromFile(|cwd:///Java/Hello.java|,true); Have I just missed how to do this in the documentation? 回答1: If you mean unparsing an AST (getting the Java code back) you will have to write something yourself. If you however mean printing the AST structure nicely indented, we have iprintln exactly for this purpose. Also, for large ASTs, the REPL might not like it that much, checkout our (as pf yet) undocumented Fast print functions in util:

Layout in Rascal

人走茶凉 提交于 2019-12-02 06:03:25
When I import the Lisra recipe, import demo::lang::Lisra::Syntax; This creates the syntax: layout Whitespace = [\t-\n\r\ ]*; lexical IntegerLiteral = [0-9]+ !>> [0-9]; lexical AtomExp = (![0-9()\t-\n\r\ ])+ !>> ![0-9()\t-\n\r\ ]; start syntax LispExp = IntegerLiteral | AtomExp | "(" LispExp* ")" ; Through the start syntax -definition, layout should be ignored around the input when it is parsed, as is stated in the documentation: http://tutor.rascal-mpl.org/Rascal/Declarations/SyntaxDefinition/SyntaxDefinition.html However, when I type: rascal>(LispExp)` (something)` This gives me a concrete

Pretty printing AST in Rascal

被刻印的时光 ゝ 提交于 2019-12-02 04:35:11
I am trying to pretty print an AST generated from createAstFromFile(|cwd:///Java/Hello.java|,true); Have I just missed how to do this in the documentation? If you mean unparsing an AST (getting the Java code back) you will have to write something yourself. If you however mean printing the AST structure nicely indented, we have iprintln exactly for this purpose. Also, for large ASTs, the REPL might not like it that much, checkout our (as pf yet) undocumented Fast print functions in util::FastPrint . The fiprintln prints to the rascal output window, which is a lot faster. No I believe the