Fix for Bug#144987

Andreas Pakulat apaku at gmx.de
Thu May 3 20:33:49 UTC 2007


On 03.05.07 21:44:43, Andreas Pakulat wrote:
> Hi,
> 
> I'd like to apply the attached patch to the QMake parser, it fixes the
> bug number 144987. It allows the parser to parse QMake Variable
> assignments with EOF instead of newline at the end of the assignment.
> 
> Ok to commit?

Here's a small updated. Two more fixes, 

a) Parsing of 1-character-long variable value (i.e. ".")
b) Parsing of
foo = \
bar

The second failed unless a whitespace is added before bar.

With this 144377 will be fixed too. (And QMake bugfree again :)

Andreas

-- 
You will feel hungry again in another hour.
-------------- next part --------------
Index: qmake.yy
===================================================================
--- qmake.yy	(Revision 660336)
+++ qmake.yy	(Arbeitskopie)
@@ -137,6 +137,7 @@ Don't forget to uncomment "yydebug = 1" 
 %token QUOTED_VARIABLE_VALUE
 %token VARIABLE_VALUE
 %token LIST_WS
+%token ENDOFFILE
 %%
 
 project :
@@ -188,6 +189,16 @@ variable_assignment : ID_SIMPLE operator
             node->indent = $<indent>3;
             $<node>$ = node;
         }
+    | ID_SIMPLE operator multiline_values listws ENDOFFILE
+        {
+            AssignmentAST *node = new AssignmentAST();
+            node->scopedID = $<value>1;
+            node->op = $<value>2;
+            node->values = $<values>3 ;
+            node->values.append( $<value>4 );
+            node->indent = $<indent>3;
+            $<node>$ = node;
+        }
     | ID_SIMPLE operator multiline_values listws CONT
         {
             AssignmentAST *node = new AssignmentAST();
@@ -219,6 +230,14 @@ variable_assignment : ID_SIMPLE operator
             node->values.append( $<value>4 );
             $<node>$ = node;
         }
+    | ID_SIMPLE operator listws ENDOFFILE
+        {
+            AssignmentAST *node = new AssignmentAST();
+            node->scopedID = $<value>1;
+            node->op = $<value>2;
+            node->values.append( $<value>3 );
+            $<node>$ = node;
+        }
     | ID_SIMPLE operator listws COMMENT
         {
             AssignmentAST *node = new AssignmentAST();
@@ -276,6 +295,14 @@ multiline_values : multiline_values LIST
             $<values>$.append( $<value>1 );
             $<values>$.append( $<value>2 );
         }
+    | listws CONT listws variable_value
+        {
+            $<values>$ = QStringList();
+            $<values>$.append( $<value>1 );
+            $<values>$.append( $<value>2 );
+            $<values>$.append( $<value>3 );
+            $<values>$.append( $<value>4 );
+        }
     | listws COMMENT_CONT
         {
             $<values>$ = QStringList();
Index: qmake.ll
===================================================================
--- qmake.ll	(Revision 660336)
+++ qmake.ll	(Arbeitskopie)
@@ -62,7 +62,7 @@ delim             [ \t]
 ws                {delim}+
 newline           (\n|\r|\r\n)
 quote             "\""
-var_value         [^#\r\n\t ]+[^\r\n\t \\]
+var_value         [^#\r\n\t ]*[^\r\n\t \\]
 quoted_var_value  {quote}({var_value}|[\t ])({var_value}|[\t ])*{quote}
 letter            [A-Za-z]
 digit             [0-9]
@@ -74,10 +74,11 @@ comment_cont      \\{ws}*#[^\r\n]*{newli
 cont              \\{ws}*{newline}
 
 %%
-<INITIAL>{ws} {
-    mylval->value = QString::fromLocal8Bit( YYText(), YYLeng() );
-    return Parser::token::token::WS;
+<vallist><<EOF>> {
+    BEGIN(INITIAL);
+    return Parser::token::token::ENDOFFILE;
 }
+<INITIAL>{ws} {}
 
 <vallist>{ws} {
     mylval->value = QString::fromLocal8Bit( YYText(), YYLeng() );


More information about the KDevelop-devel mailing list