kframework / k-legacy

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

krun command line parsing error #194

Open grosu opened 11 years ago

grosu commented 11 years ago
module TRY
  syntax Exp  ::= Int
                | Exp Exp
                | Exp "-" Exp
                | "-" Exp

  syntax priority '__ > '-_
endmodule

fslwork$ krun --parser "kast -e" "- 7 3"
Error while parsing commandline:Unrecognized option: - 7 3
usage: krun [options] <file>
...

fslwork$ krun --parser "kast -e" " - 7 3"
<k>
    - (7 3)
</k>
fslwork$ kast -e "- 7 3"
_`(_`)('-_, _`(_`)('__, _`,`,_(_`(_`)(#_(7), .KList), _`(_`)(#_(3), .KList))))
osa1 commented 11 years ago

I'll check this but I don't understand how second case(correct one) works.

grosu commented 11 years ago

There is a space between " and - :)

andreiarusoaie commented 11 years ago

Hm... this might be related to issue #163 . It looks very similar.

osa1 commented 10 years ago

I found the problem but I'm not sure what to do about it. The problem is a double quote delimited string specifies exactly one program argument, and when a program argument starts with a dash(-), it's considered as named argument like -directory something by our command line argument parser library. I think this makes sense. We can't do something like "consider argument as unnamed argument if you can't parse name of the argument" because if we do this than it accepts all kinds of wrong arguments like -dirctory something (note the typo in name part) or -7 something (here 7 is name or the argument).

So it's like how it's working and not a bug. If an argument starts with -, then it's a named argument and it's name will be looked up in our named parameter list which is listed in --help message.

dwightguth commented 10 years ago

Blocked on #244.