[m-rev.] diff: avoid error message for empty browser commands
Zoltan Somogyi
zs at cs.mu.OZ.AU
Wed Jul 3 18:12:35 AEST 2002
browser/browse.m:
browser/parse.m:
Add a new browser "command", empty, to represent command lines without
tokens. This allows us to avoid giving an error message if the user
just hits return at a browser prompt.
Use a better variable name.
Zoltan.
cvs diff: Diffing .
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
Index: browser/browse.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/browse.m,v
retrieving revision 1.28
diff -u -b -r1.28 browse.m
--- browser/browse.m 2002/04/16 13:54:29 1.28
+++ browser/browse.m 2002/07/03 08:01:07
@@ -335,7 +335,10 @@
% XXX The commands `set', `ls' and `print' should allow the format
% to be specified by an option. In each case we instead pass `no' to
% the respective handler.
- ( { Command = unknown },
+ ( { Command = empty },
+ { Quit = no },
+ { Info = Info0 }
+ ; { Command = unknown },
write_string_debugger(Debugger,
"Error: unknown command or syntax error.\n"),
write_string_debugger(Debugger, "Type \"help\" for help.\n"),
Index: browser/parse.m
===================================================================
RCS file: /home/mercury1/repository/mercury/browser/parse.m,v
retrieving revision 1.13
diff -u -b -r1.13 parse.m
--- browser/parse.m 2001/12/19 06:44:47 1.13
+++ browser/parse.m 2002/07/03 08:04:50
@@ -83,14 +83,13 @@
; print
; display
; write
- ; unknown
- .
+ ; empty
+ ; unknown.
:- type path
---> root_rel(list(dir))
; dot_rel(list(dir)).
-
% If the term browser is called from the external debugger, the term browser
% commands are send through the socket via terms of type external_request.
:- type external_request
@@ -121,30 +120,30 @@
; unknown(char)
.
-parse__read_command(Prompt, Comm) -->
+parse__read_command(Prompt, Command) -->
util__trace_get_command(Prompt, Line),
{ string__to_char_list(Line, Cs) },
{ lexer(Cs, Tokens) },
- ( { parse(Tokens, Comm2) } ->
- { Comm = Comm2 }
+ ( { parse(Tokens, Command2) } ->
+ { Command = Command2 }
;
- { Comm = unknown }
+ { Command = unknown }
).
-parse__read_command_external(Comm) -->
+parse__read_command_external(Command) -->
io__read(Result),
( { Result = ok(external_request(StringToParse)) } ->
{ string__to_char_list(StringToParse, Cs) },
{ lexer(Cs, Tokens) },
- ( { parse(Tokens, Comm2) } ->
- { Comm = Comm2 }
+ ( { parse(Tokens, Command2) } ->
+ { Command = Command2 }
;
- { Comm = unknown }
+ { Command = unknown }
)
; { Result = eof } ->
- { Comm = quit }
+ { Command = quit }
;
- { Comm = unknown }
+ { Command = unknown }
).
:- pred lexer(list(char), list(token)).
@@ -227,62 +226,66 @@
:- pred parse(list(token), command).
:- mode parse(in, out) is semidet.
-parse(Toks, Comm) :-
- start(Toks, Comm).
+parse(Toks, Command) :-
+ ( Toks = [] ->
+ Command = empty
+ ;
+ start(Toks, Command)
+ ).
:- pred start(list(token), command).
:- mode start(in, out) is semidet.
-start([Tok | Toks], Comm) :-
+start([Tok | Toks], Command) :-
( (Tok = name("help") ; Tok = (?) ; Tok = name("h")) ->
Toks = [],
- Comm = help
+ Command = help
; (Tok = name("cd") ; Tok = (^)) ->
( Toks = [] ->
- Comm = cd
+ Command = cd
;
parse_path(Toks, Path),
- Comm = cd(Path)
+ Command = cd(Path)
)
; Tok = name("pwd") ->
Toks = [],
- Comm = pwd
+ Command = pwd
; Tok = name("ls") ->
( Toks = [] ->
- Comm = ls
+ Command = ls
;
parse_path(Toks, Path),
- Comm = ls(Path)
+ Command = ls(Path)
)
; Tok = name("mark") ->
( Toks = [] ->
- Comm = mark
+ Command = mark
;
parse_path(Toks, Path),
- Comm = mark(Path)
+ Command = mark(Path)
)
; Tok = name("set") ->
( Toks = [] ->
- Comm = set
+ Command = set
;
parse_setting(Toks, Setting),
- Comm = set(Setting)
+ Command = set(Setting)
)
; Tok = name("quit") ->
Toks = [],
- Comm = quit
+ Command = quit
; (Tok = name("display") ; Tok = name("d")) ->
Toks = [],
- Comm = display
+ Command = display
; (Tok = name("write") ; Tok = name("w")) ->
Toks = [],
- Comm = write
+ Command = write
; (Tok = name("print") ; Tok = name("p")) ->
Toks = [],
- Comm = print
+ Command = print
;
Tok = (<),
Toks = [num(Depth)],
- Comm = set(depth(Depth))
+ Command = set(depth(Depth))
).
:- pred parse_path(list(token), path).
@@ -397,6 +400,8 @@
io__write_string("display\n").
show_command(write) -->
io__write_string("write\n").
+show_command(empty) -->
+ io__write_string("empty\n").
show_command(unknown) -->
io__write_string("unknown\n").
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list