[m-users.] A naming and access problem

Sean Charles (emacstheviking) objitsu at gmail.com
Tue May 18 18:00:12 AEST 2021


Hi, I have a token definition like this:

:- type location
           ---> pos(index::int, line::int, col::int).

% for ast detection later.
:- type token
           ---> tk(location, string)
           ; '('(location) ; ')'(location)
           ; '['(location) ; ']'(location)
           ; '{'(location) ; '}'(location)
           ; c1(location, string) ; cn(location, string)
           ; s1(location, string) ; s2(location, string)
           .

Given the above, I have now realised that I can’t easily (?) access the location part of any particulr instance of the token type because it doesn’t have a name and thus no field reader will be generated. As I understand it, I would have to give a unique name.

I tried:

    arg(Tok1, canonicalize, 0, Out),

and was rewarded with this message from the compiler,

repl.m:199: In clause for predicate `run_lex'/3:
repl.m:199: in argument 1 of call to predicate `lexer.on_string'/4:
repl.m:199: in argument 2 of functor `string.between/3’:
repl.m:199: in unification of argument
repl.m:199: and term `index(Out)’:
repl.m:199: type error in argument of functor `index'/1.
repl.m:199: Argument 1 (Out) has type `(some [ArgT] ArgT)’,
repl.m:199: expected type was `lexer.location’.

Which is fair enough but how do I do it? That message is currently above my pay grade.
Have I overlooked something blindingly obvious?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20210518/a3f6ef83/attachment.html>


More information about the users mailing list