Factor out common sub-expression from multi-line-comment regular expression.
authorCarl Worth <cworth@cworth.org>
Wed, 2 Jun 2010 19:54:15 +0000 (12:54 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 2 Jun 2010 19:54:15 +0000 (12:54 -0700)
In two places we look for an (optional) sequence of characters other
than "*" followed by a sequence of on or more "*". Using a name for
this (NON_STARS_THEN_STARS) seems to make it a bit easier to
understand.

glcpp-lex.l

index 2aec46a2ed1177ce19632d96b0c662ef88a2d2a4..0d9a75415a3e62f981823e179bfc86c0e05319d3 100644 (file)
@@ -45,6 +45,8 @@ DECIMAL_INTEGER               [1-9][0-9]*[uU]?
 OCTAL_INTEGER          0[0-7]*[uU]?
 HEXADECIMAL_INTEGER    0[xX][0-9a-fA-F]+[uU]?
 
+NON_STARS_THEN_STARS   [^*]*[*]+
+
 %%
 
        /* Single-line comments */
@@ -53,7 +55,7 @@ HEXADECIMAL_INTEGER   0[xX][0-9a-fA-F]+[uU]?
 }
 
        /* Multi-line comments */
-"/*"([^*]*[*]+[^*/])*[^*]*[*]+"/" {
+"/*"({NON_STARS_THEN_STARS}[^*/])*{NON_STARS_THEN_STARS}"/" {
        if (yyextra->space_tokens)
                return SPACE;
 }