k-legacy icon indicating copy to clipboard operation
k-legacy copied to clipboard

Parsing or pretty-printing error?

Open grosu opened this issue 9 years ago • 3 comments

You would expect the following to work:

D:\github\grosu\k\k-distribution\tutorial\2_languages\1_simple\2_typed\1_static>krun ..\programs\diverse\factorial.simple --pattern "<tasks> T </tasks>"
Search results:

Solution 1:
T:K -->
.TaskCellBag
D:\github\grosu\k\k-distribution\tutorial\2_languages\1_simple\2_typed\1_static>krun ..\programs\diverse\factorial.simple --pattern "<tasks> .TaskCellBag </tasks>"
[Error] Inner Parser: Parse error: unexpected character '<'.
        Source(<command line>)
        Location(1,22,1,23)

┆Issue is synchronized with this Asana task

grosu avatar Jan 18 '16 23:01 grosu

I tried it this way:

c:\work\k\k-distribution\tutorial\2_languages\1_simple\2_typed\1_static>krun ..\programs\diverse\factorial.simple --pattern "<tasks> .Bag </tasks>
Search results:

Solution 1:
Empty substitution

Clearly there is a misunderstanding between parsing and pretty printing, but I'm not sure which one is wrong.

radumereuta avatar Feb 08 '16 20:02 radumereuta

It seems that parsing is wrong. .TaskCellBag is generated by the configuration expander, so it should be visible during the parsing of patterns as well. I haven't seen any sub-sorting between .Bag and .TaskCellBag so it's curious it works that way. @xianzezhan, I suggest printing the module used for parsing the pattern and checking that is contains the production for .TaskCellBag.

cos avatar Dec 01 '16 16:12 cos

public Rule parsePatternIfAbsent(FileUtil files, KExceptionManager kem, String pattern, Source source) { return cachedParsedPatterns.computeIfAbsent(pattern, p -> new Kompile(kompileOptions, files, kem).parseRule(this, p, source)); }

result = parser.parseString(b.contents(), START_SYMBOL, Source.apply(source), startLine, startColumn); in performParse(DefinitionsParsing.java) this call triggers the error when b.contents()==" .TaskCellBag ".

By the way, could you tell me which module should I look for checking productions? When I try to use system.put.println() in ParseInModule, krun throws errors like [Error] Outer Parser: Encountered <ID_KLABEL>. Was expecting one of: ["("]

xianzezhan avatar Dec 01 '16 21:12 xianzezhan