kframework / k-legacy

The K tools (deprecated, see README)
http://kframework.org
Other
146 stars 61 forks source link

krun should forward stderr from the external parser (to report ambiguities) #120

Open grosu opened 10 years ago

grosu commented 10 years ago

This is just great, I wasted 2 hours today until I finally localized and minimized it:

fslwork$ more tokens.k module TOKENS syntax ABCD ::= Token{[a]} syntax EFGH ::= Token{[a]} endmodule fslwork$ kompile tokens.k fslwork$ krun --parser "kast --parser ground -e" "isABCD(a)"

isABCD(a)

fslwork$ krun --parser "kast --parser ground -e" "isEFGH(b)"

isEFGH(b)

fslwork$ krun --parser "kast --parser ground -e" "isEFGH(a)"

true

fslwork$

grosu commented 10 years ago

Let me try again with with the quotes trick: ''' fslwork$ more tokens.k module TOKENS syntax ABCD ::= Token{[a]} syntax EFGH ::= Token{[a]} endmodule fslwork$ kompile tokens.k fslwork$ krun --parser "kast --parser ground -e" "isABCD(a)"

isABCD(a)

fslwork$ krun --parser "kast --parser ground -e" "isEFGH(b)"

isEFGH(b)

fslwork$ krun --parser "kast --parser ground -e" "isEFGH(a)"

true

fslwork$ '''

grosu commented 10 years ago

Hm, maybe backquotes (github wiki sucks):

fslwork$ more tokens.k
module TOKENS
  syntax ABCD ::= Token{[a]}
  syntax EFGH ::= Token{[a]}
endmodule
fslwork$ kompile tokens.k 
fslwork$ krun --parser "kast --parser ground -e" "isABCD(a)"
<k>
    isABCD(a)
</k>
fslwork$ krun --parser "kast --parser ground -e" "isEFGH(b)"
<k>
    isEFGH(b)
</k>
fslwork$ krun --parser "kast --parser ground -e" "isEFGH(a)"
<k>
    true
</k>
fslwork$ 
andreistefanescu commented 10 years ago

This is what I found out.

Sona:issue#120 andrei$ kast --parser ground -e "isABCD(a)" `()(isABCD, _(_`)(#token("EFGH", "a"), .KList)) [Warning] Parser: Parsing ambiguity. Arbitrarily choosing the first. 1: a 2: a 3: a File: Command line Location: (1,8,1,9) Compilation Phase: Ambiguity filter

radumereuta commented 9 years ago

I think krun should forward stderr from the external parser. This should avoid problems like above in the future. I will reopen and rename the issue.

radumereuta commented 9 years ago

@dwightguth, I think this should be trivial for you since you are most familiar with the krun code.