[antlr-interest] Re: CLI with ANTLR - best practice

idontwantanidwith2000init idontwantanidwith2000init at yahoo.com
Fri Apr 9 12:43:08 PDT 2004


I use (command NEWLINE)+ for looping

I dont see any point in external looping

It works as long as the user is commited to the language 
specification.

Handling errors and ambiguity are my main concerns

Does your CLI language accept a two line command ?

Consider the following:
suppose you have a command rule such as: "createIssue" STRING 
SEVIRITY

now suppose the user typed: "createIssue" "problem in air supply" \n

he forgot sevirity or misspeled it: hgh instead of high

you'll probobly give an error message but:
Do you let him type it allover again?

You can retype for him the part of the line that the parser 
recognized and let him edit it.

Or you can lead him through each step in correcting the command, for 
example:
1. print the part of the command the parser mannaged to parse.
   ask the user if he'd like to edit it. (the answer may be abort)
2. in the last example you can print somthing like:
#you have chosen createIssue command
#Do you want to edit it[y|n|a]?
n
#Now you have to enter the description of the issue double qouted:
"ho now I understand what I have to enter hear and how :)"
#Now you have to enter one of the sevirities {HIGH, MEDIUM, LOW}:
HIGH
#that's it you can go on with you're work :)


--- In antlr-interest at yahoogroups.com, "thierryj8" <thierryj8 at y...> 
wrote:
> I assume you have a main with a loop, then the .g file with parser 
and
> lexer.
> 
> For NEWLINE('\r' '\n' | '\r' | '\n'), do you apply
> $setType(Token.EOF_TYPE); so that all carriage return makes the 
line a
> full file
> 
> Do you loop in your main? Do you apply a (command)+ for looping.
> 
> To answer your question: I set defaultErrorHandler = false; in the 
lexer.



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list