Search code examples
flex-lexerlexer

what does Exclamation mark mean?


I am reading some flex file for a dialect of datalog, the original file is ol_lexer.lex there is a code snippet in the action part:

<INITIAL>%%.*           ; // Ignore %% comments
<INITIAL>^#!.*          ; // Ignore '#' directives

I know the second line for matching the preprocessing directives such as

#define PI 3.14

but I don't know what's meaning of the mark "!" here, or why the second pattern needs the exclamation mark ?


Solution

  • The second line ignores lines that start with #! (so it would not match #define ... as that doesn't have a ! after the #). The ! doesn't have any special meaning here - it just matches an exclamation mark.

    I assume the purpose of this rule is to allow shebang line (such as #!/usr/bin/env myinterpreter).