[m-users.] A naming and access problem

Volker Wysk post at volker-wysk.de
Tue May 18 21:36:17 AEST 2021


Am Dienstag, den 18.05.2021, 09:00 +0100 schrieb Sean Charles
(emacstheviking):
> 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?

Is that "arg(Tok1, canonicalize, 0, Out)" the line 199? There isn't any term
"index(Out)". What's the declaration of arg/4?

Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mercurylang.org/archives/users/attachments/20210518/96531ea1/attachment.sig>


More information about the users mailing list