Syntax questions

# David Teller (18 years ago)

I'm currently exploring the code, as a preliminary to writing a static analysis tool. At the moment, I'm stuck in the lexer, where I have two questions.

Firstly, embedded comments seem to be forbidden. That is, a block such as /* bla /* more bla / even more bla/ will be passed to the parser as even more bla */ Is that normal ? Is that desired ?

Secondly, regular expressions. From what I gather, a regular expression containing a "x" anywhere can be multiline. Is that it ? It sounds too strange to be true.

Thanks,

# Lars T Hansen (18 years ago)

On 7/30/07, David Teller <David.Teller at univ-orleans.fr> wrote:

    Hi,

I'm currently exploring the code, as a preliminary to writing a static analysis tool. At the moment, I'm stuck in the lexer, where I have two questions.

Firstly, embedded comments seem to be forbidden. That is, a block such as /* bla /* more bla / even more bla/ will be passed to the parser as even more bla */ Is that normal ?

Yes.

Is that desired ?

It's Traditional, at least. Most languages don't seem to care about nested comments. Standard ML and Modula-3 are the only ones that come to mind right now.

Secondly, regular expressions. From what I gather, a regular expression containing a "x" anywhere can be multiline. Is that it ? It sounds too strange to be true.

No, a regular expression that is trailed by an 'x' flag can be multiline, eg

/ab cd/x

This introduces an interesting problem for the lexer because it can't know whether the x flag is present until it's lexed the regular expression. The rule is that it must assume the x flag is present, and, coming to the end and finding it not there after all, must throw a syntax error.