[m-dev.] for review: add code to read terms from strings

Mark Anthony BROWN dougl at cs.mu.OZ.AU
Fri May 15 14:05:20 AEST 1998


Hello,

> Index: io.m
> ===================================================================

...

> +% The type `posn' represents a position within a string.
> +:- type posn
> +	--->	posn(int, int, int).
> +		% line number, offset for start of line, current offset
> +		% (the first two are used only for the purposes of
> +		% computing term_contexts, for use e.g. in error messages).

"offset for start of line" is confusing.  Maybe s/for/of/ to
distinguish it from "offset from start of line".  Also, do the offsets
start from zero or one?


> Index: lexer.m
> ===================================================================

...

> +	%
> +	% A line number directive token is `#' followed by an integer
> +	% (specifying the line number) followed by a newline.
> +	% Such a token sets the source line number for the next
> +	% line, but it is otherwise ignored.  This means that line number
> +	% directives may appear anywhere that a token may appear, including
> +	% in the middle of terms.
> +	% (The source file name can be set with a `:- pragma source_file' 
> +	% declaration.)
> +	%

This comment seems to appear twice.


> @@ -860,6 +1651,28 @@
>  		)
>  	).
>  
> +:- pred lexer__string_get_hex_2(string, int, posn, token,
> +				string_token_context, posn, posn).
> +:- mode lexer__string_get_hex_2(in, in, in, out, out, in, out) is det.
> +
> +lexer__string_get_hex_2(String, Len, Posn0, Token, Context) -->
> +	( lexer__string_read_char(String, Len, Char) ->
> +		( { char__is_hex_digit(Char) } ->
> +			lexer__string_get_hex_2(String, Len, Posn0,
> +				Token, Context)
> +		;
> +			lexer__string_ungetchar(String),
> +			lexer__grab_string(String, Posn0, BinaryString),
> +			{ lexer__conv_string_to_int(BinaryString, 16, Token) },
> +			lexer__string_get_context(Posn0, Context)
> +		)
> +	;
> +		lexer__grab_string(String, Posn0, BinaryString),
> +		{ lexer__conv_string_to_int(BinaryString, 8, Token) },

s/8/16/

> +		lexer__string_get_context(Posn0, Context)
> +	).


> Index: parser.m
> ===================================================================

...

> +:- pred parser__read_term_from_string(string, string, int, posn, posn, read_term).

Line is too long.


Other than this, the changes to these files are ok.  I'll review the
rest of them soon.

Cheers,
Mark
-- 
Mark Brown  (dougl at cs.mu.oz.au)             |  Any technology that is
MEngSc student,                             |  distinguishable from magic
Dept of Computer Science, Melbourne Uni     |  is insufficiently advanced



More information about the developers mailing list