Re: is lex useful?

trd@lister.cs.mu.OZ.AU (Tyson Richard DOWD)
5 Jul 1996 11:48:25 -0400

          From comp.compilers

Related articles
[22 earlier articles]
Re: is lex useful? WStreett@shell.monmouth.com (1996-06-30)
Re: is lex useful? dmr@bell-labs.com (1996-06-30)
Re: is lex useful? clark@quarry.zk3.dec.com (1996-07-01)
Re: is lex useful? bromage@cs.mu.OZ.AU (1996-07-02)
Re: is lex useful? kanze@lts.sel.alcatel.de (1996-07-02)
Re: is lex useful? colas@aye.inria.fr (1996-07-04)
Re: is lex useful? trd@lister.cs.mu.OZ.AU (1996-07-05)
| List of all articles for this month |
From: trd@lister.cs.mu.OZ.AU (Tyson Richard DOWD)
Newsgroups: comp.compilers
Date: 5 Jul 1996 11:48:25 -0400
Organization: Comp Sci, University of Melbourne
References: 96-06-101 96-06-118 96-06-123 96-06-141
Keywords: lex

>[For the double underscore thing, whether in C or lex, I'd recognize
>identifiers as a string of letters, digits, and underscores, then look for
>a double underscore and if I found one, produce a helpful "this language
>doesn't permit double underscores in your identifiers" message rather than
>a generic and mysterious "syntax error". -John]


This is a good idea, although I think in this case it is not likely to
be a syntax error, but have a different meaning altogether such as a
scope qualifier or something (its pretty arbitrary to say 'oh, we just don't
support __ because the people writing the parser wanted a challenge').


So there would be another pattern that matches on identifiers with __
and uses that for something else (or just an identifier + __ + identifer
in the parser, not the lexer). If you were doing it in C, you'd see the
second _, and know that you had seen the end of one token and the __ token
follows (so do a ungetc or something -- depends how you've buffered input).


That's just a guess anyway, what was the reason why '__' wasn't allowed in
identifiers anyway?


--
              Tyson Dowd


    trd@mundil.cs.mu.oz.au
http://www.cs.mu.oz.au/~trd
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.