[m-dev.] Adding `.' as a module separator

Ralph Becket rafe at cs.mu.OZ.AU
Mon Dec 2 12:13:22 AEDT 2002


I've just been looking into adding `.' as a module separator.

Changing the lexer to allow `.' as an embedded character in names is
straightforward.

The next step seems to be to change prog_util__string_to_sym_name to
take a list of module separators rather than just one*.

However, this approach raises the problem of what to do with quoted
names like 'foo.__bar' and 'baz__.quux' or even 'spoo.__.fleem'.

As I see it we have the following options:

1. change the lexer to treat infix `.' as an operator and change the
parser to recognise `.'/2 terms as module qualified names (this will
cause merry Hell with backwards compatibility);

2. detect and report an error in these situations (although
this may make code elsewhere more complicated);

3. parse the strings using a rule like "first split at the '.'s, then
split the pieces at the '__'s, stragglers are deemed to be part of
the name" (rather like the way we currently interpret 'foo____bar',
namely as `qualified("foo", unqualified("__bar"))').  This still
wouldn't tell us what to do in cases like 'foo..bar', although we could
use the same rule as we currently do for '__'.

Hmm, looking more closely at string_to_sym_name, it seems we interpret
'foo____bar__baz' as `qualified("foo", unqualified("__bar__baz"))' which
is definitely confusing!

Approach no. 3 looks like the best bet to me.  Comments?

- Ralph

* Actually, it would probably be easier and more consistent to hard-code
in the module qualifiers.  The four uses of string_to_sym_name are

modules.m:		string_to_sym_name(FileName, ".", ModuleName)
prog_io.m:		string_to_sym_name(Name, "__", SymName)
prog_io_pragma.m:	string_to_sym_name(TypeNameStr, ".", TypeSymName)
source_file_map.m:	string_to_sym_name(ModuleStr, ":", ModuleName)

which all starts to look a little redundant.  Could we not simply make
all module separators equal?
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list