there is a regular season

{B}*"namespace"{BN}*/[^a-z_A-Z0-9]

where {B} are indent characters like spaces or tabs, and {BN} are spaces for tabs and move to a new line.

I don’t understand what the character does / before [^a-z_A-Z0-9] .

  • Where do you use it? Perhaps there this symbol means something. And so, he usually means himself - Crantisz
  • @Crantisz I saw it in the source code for Flex (lexical analyzer generator) (C ++ language) and if it meant itself, it would be in double quotation marks "/". It definitely means something, but I don't know what. - Ilya Chizhanov
  • 3
    Have you tried this code? By the way, this is very similar to the "trailing context" , such an analogue of the positive preview block ahead. As a result, {B}*"namespace"{BN}* should return, followed by [^a-z_A-Z0-9] . - Wiktor Stribiżew

1 answer 1

user @Wiktor Stribiżew was right. This symbol is something like the terminating context symbol. You can read about it here . As a result, {B}*"namespace"{BN}* should return, followed by [^a-z_A-Z0-9]

To handle situations that require forward viewing, the / symbol is used (not to be confused with the symbol), which indicates that the sequence following it is the final context and should not be stored in yytext [], since it does not belong to the lexeme itself. The rule for DO recognition in FORTRAN can be written as:

 DO/[0-9 ]*[a-zA-Z0-9 ]+=[a-zA-Z0-9 ]+, printf("нашли DO"); 

That is, it is an analogue (?=...) in PCRE.

  • Correct, if you do not agree with my edits. - ReinRaus