parse/parse_c:
authorHolger Hans Peter Freyther <zecke@selfish.org>
Mon, 20 Mar 2006 00:26:22 +0000 (00:26 +0000)
committerHolger Hans Peter Freyther <zecke@selfish.org>
Mon, 20 Mar 2006 00:26:22 +0000 (00:26 +0000)
    -python_output will be called from the parser. Once we have
     each method implemented we have a working C++ parser
    -Add BBHandler. It will parse .bbclass, .inc and .bb files
     for us and calls into c (if speed critical we might remove
     that fascade)
    -make scanner get FILE* and PyObject* as input
    -make parser call python_output with lex_t
    -bitbakescanner.cc,bitbakeparser.cc update generated code

    -Parsing flow:
    parse -> handle -> parse_c.BBHandler -> parse_c.C -> lex
    -> (lemon *-> python_output) ... return

lib/bb/parse/parse_c/BBHandler.py [new file with mode: 0644]
lib/bb/parse/parse_c/__init__.py [new file with mode: 0644]
lib/bb/parse/parse_c/bitbakeparser.cc
lib/bb/parse/parse_c/bitbakeparser.y
lib/bb/parse/parse_c/bitbakescanner.cc
lib/bb/parse/parse_c/bitbakescanner.l
lib/bb/parse/parse_c/lexer.h
lib/bb/parse/parse_c/python_output.h [new file with mode: 0644]
lib/bb/parse/parse_c/token.h

diff --git a/lib/bb/parse/parse_c/BBHandler.py b/lib/bb/parse/parse_c/BBHandler.py
new file mode 100644 (file)
index 0000000..300871d
--- /dev/null
@@ -0,0 +1,65 @@
+# ex:ts=4:sw=4:sts=4:et
+# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
+#
+# Copyright (C) 2006 Holger Hans Peter Freyther
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+# THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+from bb import data
+from bb.parse import ParseError
+
+#
+# This is the Python Part of the Native Parser Implementation.
+# We will only parse .bbclass, .inc and .bb files but no
+# configuration files.
+# supports, init and handle are the public methods used by
+# parser module
+#
+# The rest of the methods are internal implementation details.
+
+
+
+#
+# internal
+#
+
+
+#
+# public
+#
+def supports(fn, data):
+    return fn[-3:] == ".bb" or fn[-8:] == ".bbclass" or fn[-4:] == ".inc"
+
+def init(fn, data):
+    print "Init"
+
+def handle(fn, data, include):
+    print ""
+    print "fn: %s" % fn
+    print "data: %s" % data
+    print "include: %s" % include
+
+    pass
+
+# Inform bitbake that we are a parser
+# We need to define all three
+from bb.parse import handlers
+handlers.append( {'supports' : supports, 'handle': handle, 'init' : init})
+del handlers
diff --git a/lib/bb/parse/parse_c/__init__.py b/lib/bb/parse/parse_c/__init__.py
new file mode 100644 (file)
index 0000000..bbb318e
--- /dev/null
@@ -0,0 +1,28 @@
+# ex:ts=4:sw=4:sts=4:et
+# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
+#
+# Copyright (C) 2006 Holger Hans Peter Freyther
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+# SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+# THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+__version__ = '0.1'
+__all__     = [ 'BBHandler' ]
+
+import BBHandler
index 8d4af34..3a3c53d 100644 (file)
@@ -8,7 +8,8 @@
 
 #include "token.h"
 #include "lexer.h"
-#line 13 "bitbakeparser.c"
+#include "python_output.h"
+#line 14 "bitbakeparser.c"
 /* Next is all token values, in a form suitable for use by makeheaders.
 ** This section will be null unless lemon is run with the -m switch.
 */
@@ -401,9 +402,9 @@ static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){
     case 25:
     case 26:
     case 27:
-#line 49 "bitbakeparser.y"
+#line 50 "bitbakeparser.y"
 { (yypminor->yy0).release_this (); }
-#line 408 "bitbakeparser.c"
+#line 409 "bitbakeparser.c"
       break;
     default:  break;   /* If no destructor action specified: do nothing */
   }
@@ -667,212 +668,212 @@ static void yy_reduce(
   **     break;
   */
       case 3:
-#line 59 "bitbakeparser.y"
+#line 60 "bitbakeparser.y"
 { yygotominor.yy0.assignString( (char*)yymsp[0].minor.yy0.string() );
           yymsp[0].minor.yy0.assignString( 0 );
           yymsp[0].minor.yy0.release_this(); }
-#line 676 "bitbakeparser.c"
+#line 677 "bitbakeparser.c"
         break;
       case 4:
-#line 63 "bitbakeparser.y"
+#line 64 "bitbakeparser.y"
 {
           yygotominor.yy0.assignString( (char*)yymsp[0].minor.yy0.string() );
           yymsp[0].minor.yy0.assignString( 0 );
           yymsp[0].minor.yy0.release_this(); }
-#line 684 "bitbakeparser.c"
+#line 685 "bitbakeparser.c"
         break;
       case 5:
-#line 69 "bitbakeparser.y"
-{ e_assign( yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
-          e_export( yymsp[-2].minor.yy0.string() );
+#line 70 "bitbakeparser.y"
+{ e_assign( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
+          e_export( lex, yymsp[-2].minor.yy0.string() );
           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(3,&yymsp[-3].minor);
   yy_destructor(4,&yymsp[-1].minor);
 }
-#line 693 "bitbakeparser.c"
+#line 694 "bitbakeparser.c"
         break;
       case 6:
-#line 73 "bitbakeparser.y"
-{ e_immediate (yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
-          e_export( yymsp[-2].minor.yy0.string() );
+#line 74 "bitbakeparser.y"
+{ e_immediate ( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
+          e_export( lex, yymsp[-2].minor.yy0.string() );
           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(3,&yymsp[-3].minor);
   yy_destructor(6,&yymsp[-1].minor);
 }
-#line 702 "bitbakeparser.c"
+#line 703 "bitbakeparser.c"
         break;
       case 7:
-#line 77 "bitbakeparser.y"
-{ e_cond( yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
+#line 78 "bitbakeparser.y"
+{ e_cond( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(3,&yymsp[-3].minor);
   yy_destructor(7,&yymsp[-1].minor);
 }
-#line 710 "bitbakeparser.c"
+#line 711 "bitbakeparser.c"
         break;
       case 8:
-#line 81 "bitbakeparser.y"
-{ e_assign( yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
+#line 82 "bitbakeparser.y"
+{ e_assign( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(4,&yymsp[-1].minor);
 }
-#line 717 "bitbakeparser.c"
+#line 718 "bitbakeparser.c"
         break;
       case 9:
-#line 84 "bitbakeparser.y"
-{ e_prepend( yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
+#line 85 "bitbakeparser.y"
+{ e_prepend( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(8,&yymsp[-1].minor);
 }
-#line 724 "bitbakeparser.c"
+#line 725 "bitbakeparser.c"
         break;
       case 10:
-#line 87 "bitbakeparser.y"
-{ e_append( yymsp[-2].minor.yy0.string() , yymsp[0].minor.yy0.string() );
+#line 88 "bitbakeparser.y"
+{ e_append( lex, yymsp[-2].minor.yy0.string() , yymsp[0].minor.yy0.string() );
           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(9,&yymsp[-1].minor);
 }
-#line 731 "bitbakeparser.c"
+#line 732 "bitbakeparser.c"
         break;
       case 11:
-#line 90 "bitbakeparser.y"
-{ e_immediate( yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
+#line 91 "bitbakeparser.y"
+{ e_immediate( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(6,&yymsp[-1].minor);
 }
-#line 738 "bitbakeparser.c"
+#line 739 "bitbakeparser.c"
         break;
       case 12:
-#line 93 "bitbakeparser.y"
-{ e_cond( yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
+#line 94 "bitbakeparser.y"
+{ e_cond( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(7,&yymsp[-1].minor);
 }
-#line 745 "bitbakeparser.c"
+#line 746 "bitbakeparser.c"
         break;
       case 13:
-#line 97 "bitbakeparser.y"
-{ e_addtask( yymsp[-4].minor.yy0.string(), yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
+#line 98 "bitbakeparser.y"
+{ e_addtask( lex, yymsp[-4].minor.yy0.string(), yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string() );
           yymsp[-4].minor.yy0.release_this(); yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(11,&yymsp[-3].minor);
   yy_destructor(12,&yymsp[-1].minor);
 }
-#line 753 "bitbakeparser.c"
+#line 754 "bitbakeparser.c"
         break;
       case 14:
-#line 100 "bitbakeparser.y"
-{ e_addtask( yymsp[-4].minor.yy0.string(), yymsp[0].minor.yy0.string(), yymsp[-2].minor.yy0.string());
+#line 101 "bitbakeparser.y"
+{ e_addtask( lex, yymsp[-4].minor.yy0.string(), yymsp[0].minor.yy0.string(), yymsp[-2].minor.yy0.string());
           yymsp[-4].minor.yy0.release_this(); yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(12,&yymsp[-3].minor);
   yy_destructor(11,&yymsp[-1].minor);
 }
-#line 761 "bitbakeparser.c"
+#line 762 "bitbakeparser.c"
         break;
       case 15:
-#line 103 "bitbakeparser.y"
-{ e_addtask( yymsp[0].minor.yy0.string(), NULL, NULL);
+#line 104 "bitbakeparser.y"
+{ e_addtask( lex, yymsp[0].minor.yy0.string(), NULL, NULL);
           yymsp[0].minor.yy0.release_this();}
-#line 767 "bitbakeparser.c"
+#line 768 "bitbakeparser.c"
         break;
       case 16:
-#line 106 "bitbakeparser.y"
-{ e_addtask( yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string(), NULL);
+#line 107 "bitbakeparser.y"
+{ e_addtask( lex, yymsp[-2].minor.yy0.string(), yymsp[0].minor.yy0.string(), NULL);
           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(11,&yymsp[-1].minor);
 }
-#line 774 "bitbakeparser.c"
+#line 775 "bitbakeparser.c"
         break;
       case 17:
-#line 109 "bitbakeparser.y"
-{ e_addtask( yymsp[-2].minor.yy0.string(), NULL, yymsp[0].minor.yy0.string());
+#line 110 "bitbakeparser.y"
+{ e_addtask( lex, yymsp[-2].minor.yy0.string(), NULL, yymsp[0].minor.yy0.string());
           yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this();   yy_destructor(12,&yymsp[-1].minor);
 }
-#line 781 "bitbakeparser.c"
+#line 782 "bitbakeparser.c"
         break;
       case 21:
-#line 116 "bitbakeparser.y"
-{ e_addhandler( yymsp[0].minor.yy0.string()); yymsp[0].minor.yy0.release_this ();   yy_destructor(14,&yymsp[-1].minor);
+#line 117 "bitbakeparser.y"
+{ e_addhandler( lex, yymsp[0].minor.yy0.string()); yymsp[0].minor.yy0.release_this ();   yy_destructor(14,&yymsp[-1].minor);
 }
-#line 787 "bitbakeparser.c"
+#line 788 "bitbakeparser.c"
         break;
       case 22:
-#line 118 "bitbakeparser.y"
-{ e_export_func(yymsp[0].minor.yy0.string()); yymsp[0].minor.yy0.release_this(); }
-#line 792 "bitbakeparser.c"
+#line 119 "bitbakeparser.y"
+{ e_export_func( lex, yymsp[0].minor.yy0.string()); yymsp[0].minor.yy0.release_this(); }
+#line 793 "bitbakeparser.c"
         break;
       case 26:
-#line 123 "bitbakeparser.y"
-{ e_inherit(yymsp[0].minor.yy0.string() ); yymsp[0].minor.yy0.release_this (); }
-#line 797 "bitbakeparser.c"
+#line 124 "bitbakeparser.y"
+{ e_inherit( lex, yymsp[0].minor.yy0.string() ); yymsp[0].minor.yy0.release_this (); }
+#line 798 "bitbakeparser.c"
         break;
       case 30:
-#line 129 "bitbakeparser.y"
-{ e_include(yymsp[0].minor.yy0.string() ); yymsp[0].minor.yy0.release_this();   yy_destructor(19,&yymsp[-1].minor);
+#line 130 "bitbakeparser.y"
+{ e_include( lex, yymsp[0].minor.yy0.string() ); yymsp[0].minor.yy0.release_this();   yy_destructor(19,&yymsp[-1].minor);
 }
-#line 803 "bitbakeparser.c"
+#line 804 "bitbakeparser.c"
         break;
       case 31:
-#line 132 "bitbakeparser.y"
-{ e_require(yymsp[0].minor.yy0.string() ); yymsp[0].minor.yy0.release_this();   yy_destructor(20,&yymsp[-1].minor);
+#line 133 "bitbakeparser.y"
+{ e_require( lex, yymsp[0].minor.yy0.string() ); yymsp[0].minor.yy0.release_this();   yy_destructor(20,&yymsp[-1].minor);
 }
-#line 809 "bitbakeparser.c"
+#line 810 "bitbakeparser.c"
         break;
       case 32:
-#line 135 "bitbakeparser.y"
+#line 136 "bitbakeparser.y"
 { /* concatenate body lines */
           yygotominor.yy0.assignString( token_t::concatString(yymsp[-1].minor.yy0.string(), yymsp[0].minor.yy0.string()) );
           yymsp[-1].minor.yy0.release_this ();
           yymsp[0].minor.yy0.release_this ();
         }
-#line 818 "bitbakeparser.c"
+#line 819 "bitbakeparser.c"
         break;
       case 33:
-#line 140 "bitbakeparser.y"
+#line 141 "bitbakeparser.y"
 { yygotominor.yy0.assignString(0); }
-#line 823 "bitbakeparser.c"
+#line 824 "bitbakeparser.c"
         break;
       case 34:
-#line 142 "bitbakeparser.y"
-{ e_proc( yymsp[-3].minor.yy0.string(), yymsp[-1].minor.yy0.string() );
+#line 143 "bitbakeparser.y"
+{ e_proc( lex, yymsp[-3].minor.yy0.string(), yymsp[-1].minor.yy0.string() );
           yymsp[-3].minor.yy0.release_this(); yymsp[-1].minor.yy0.release_this();   yy_destructor(22,&yymsp[-2].minor);
   yy_destructor(23,&yymsp[0].minor);
 }
-#line 831 "bitbakeparser.c"
+#line 832 "bitbakeparser.c"
         break;
       case 35:
-#line 145 "bitbakeparser.y"
-{ e_proc_python (yymsp[-3].minor.yy0.string(), yymsp[-1].minor.yy0.string() );
+#line 146 "bitbakeparser.y"
+{ e_proc_python ( lex, yymsp[-3].minor.yy0.string(), yymsp[-1].minor.yy0.string() );
           yymsp[-3].minor.yy0.release_this(); yymsp[-1].minor.yy0.release_this();   yy_destructor(24,&yymsp[-4].minor);
   yy_destructor(22,&yymsp[-2].minor);
   yy_destructor(23,&yymsp[0].minor);
 }
-#line 840 "bitbakeparser.c"
+#line 841 "bitbakeparser.c"
         break;
       case 36:
-#line 148 "bitbakeparser.y"
-{ e_proc_python( NULL, yymsp[-1].minor.yy0.string());
+#line 149 "bitbakeparser.y"
+{ e_proc_python( lex, NULL, yymsp[-1].minor.yy0.string());
           yymsp[-1].minor.yy0.release_this ();   yy_destructor(24,&yymsp[-3].minor);
   yy_destructor(22,&yymsp[-2].minor);
   yy_destructor(23,&yymsp[0].minor);
 }
-#line 849 "bitbakeparser.c"
+#line 850 "bitbakeparser.c"
         break;
       case 37:
-#line 152 "bitbakeparser.y"
-{ e_proc_fakeroot(yymsp[-3].minor.yy0.string(), yymsp[-1].minor.yy0.string() );
+#line 153 "bitbakeparser.y"
+{ e_proc_fakeroot( lex, yymsp[-3].minor.yy0.string(), yymsp[-1].minor.yy0.string() );
           yymsp[-3].minor.yy0.release_this (); yymsp[-1].minor.yy0.release_this ();   yy_destructor(25,&yymsp[-4].minor);
   yy_destructor(22,&yymsp[-2].minor);
   yy_destructor(23,&yymsp[0].minor);
 }
-#line 858 "bitbakeparser.c"
+#line 859 "bitbakeparser.c"
         break;
       case 38:
-#line 156 "bitbakeparser.y"
+#line 157 "bitbakeparser.y"
 { /* concatenate body lines */
           yygotominor.yy0.assignString( token_t::concatString(yymsp[-1].minor.yy0.string(), yymsp[0].minor.yy0.string()) );
           yymsp[-1].minor.yy0.release_this (); yymsp[0].minor.yy0.release_this ();
         }
-#line 866 "bitbakeparser.c"
+#line 867 "bitbakeparser.c"
         break;
       case 39:
-#line 160 "bitbakeparser.y"
+#line 161 "bitbakeparser.y"
 { yygotominor.yy0.assignString( 0 ); }
-#line 871 "bitbakeparser.c"
+#line 872 "bitbakeparser.c"
         break;
       case 40:
-#line 162 "bitbakeparser.y"
-{ e_def( yymsp[-2].minor.yy0.string(), yymsp[-1].minor.yy0.string(), yymsp[0].minor.yy0.string());
+#line 163 "bitbakeparser.y"
+{ e_def( lex, yymsp[-2].minor.yy0.string(), yymsp[-1].minor.yy0.string(), yymsp[0].minor.yy0.string());
           yymsp[-2].minor.yy0.release_this(); yymsp[-1].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); }
-#line 877 "bitbakeparser.c"
+#line 878 "bitbakeparser.c"
         break;
   };
   yygoto = yyRuleInfo[yyruleno].lhs;
@@ -929,9 +930,9 @@ static void yy_syntax_error(
 ){
   bbparseARG_FETCH;
 #define TOKEN (yyminor.yy0)
-#line 51 "bitbakeparser.y"
- e_parse_error( lex->filename(), lex->line() ); 
-#line 937 "bitbakeparser.c"
+#line 52 "bitbakeparser.y"
+ e_parse_error( lex ); 
+#line 938 "bitbakeparser.c"
   bbparseARG_STORE; /* Suppress warning about unused %extra_argument variable */
 }
 
index 6bf7dc5..252d877 100644 (file)
 %include {
 #include "token.h"
 #include "lexer.h"
+#include "python_output.h"
 }
 
 
 %token_destructor { $$.release_this (); }
 
-%syntax_error     { e_parse_error( lex->filename(), lex->line() ); }
+%syntax_error     { e_parse_error( lex ); }
 
 program ::= statements.
 
@@ -66,70 +67,70 @@ variable(r) ::= VARIABLE(v).
           v.release_this(); }
 
 statement ::= EXPORT variable(s) OP_ASSIGN STRING(v).
-        { e_assign( s.string(), v.string() );
-          e_export( s.string() );
+        { e_assign( lex, s.string(), v.string() );
+          e_export( lex, s.string() );
           s.release_this(); v.release_this(); }
 statement ::= EXPORT variable(s) OP_IMMEDIATE STRING(v).
-        { e_immediate (s.string(), v.string() );
-          e_export( s.string() );
+        { e_immediate ( lex, s.string(), v.string() );
+          e_export( lex, s.string() );
           s.release_this(); v.release_this(); }
 statement ::= EXPORT variable(s) OP_COND STRING(v).
-        { e_cond( s.string(), v.string() );
+        { e_cond( lex, s.string(), v.string() );
           s.release_this(); v.release_this(); }
 
 statement ::= variable(s) OP_ASSIGN STRING(v).
-        { e_assign( s.string(), v.string() );
+        { e_assign( lex, s.string(), v.string() );
           s.release_this(); v.release_this(); }
 statement ::= variable(s) OP_PREPEND STRING(v).
-        { e_prepend( s.string(), v.string() );
+        { e_prepend( lex, s.string(), v.string() );
           s.release_this(); v.release_this(); }
 statement ::= variable(s) OP_APPEND STRING(v).
-        { e_append( s.string() , v.string() );
+        { e_append( lex, s.string() , v.string() );
           s.release_this(); v.release_this(); }
 statement ::= variable(s) OP_IMMEDIATE STRING(v).
-        { e_immediate( s.string(), v.string() );
+        { e_immediate( lex, s.string(), v.string() );
           s.release_this(); v.release_this(); }
 statement ::= variable(s) OP_COND STRING(v).
-        { e_cond( s.string(), v.string() );
+        { e_cond( lex, s.string(), v.string() );
           s.release_this(); v.release_this(); }
 
 task ::= TSYMBOL(t) BEFORE TSYMBOL(b) AFTER  TSYMBOL(a).
-        { e_addtask( t.string(), b.string(), a.string() );
+        { e_addtask( lex, t.string(), b.string(), a.string() );
           t.release_this(); b.release_this(); a.release_this(); }
 task ::= TSYMBOL(t) AFTER  TSYMBOL(a) BEFORE TSYMBOL(b).
-        { e_addtask( t.string(), b.string(), a.string());
+        { e_addtask( lex, t.string(), b.string(), a.string());
           t.release_this(); a.release_this(); b.release_this(); }
 task ::= TSYMBOL(t).
-        { e_addtask( t.string(), NULL, NULL);
+        { e_addtask( lex, t.string(), NULL, NULL);
           t.release_this();}
 task ::= TSYMBOL(t) BEFORE TSYMBOL(b).
-        { e_addtask( t.string(), b.string(), NULL);
+        { e_addtask( lex, t.string(), b.string(), NULL);
           t.release_this(); b.release_this(); }
 task ::= TSYMBOL(t) AFTER  TSYMBOL(a).
-        { e_addtask( t.string(), NULL, a.string());
+        { e_addtask( lex, t.string(), NULL, a.string());
           t.release_this(); a.release_this(); }
 tasks ::= tasks task.
 tasks ::= task.
 statement ::= ADDTASK tasks.
 
 statement ::= ADDHANDLER SYMBOL(s).
-        { e_addhandler( s.string()); s.release_this (); }
+        { e_addhandler( lex, s.string()); s.release_this (); }
 
-func ::= FSYMBOL(f). { e_export_func(f.string()); f.release_this(); }
+func ::= FSYMBOL(f). { e_export_func( lex, f.string()); f.release_this(); }
 funcs ::= funcs func.
 funcs ::= func.
 statement ::= EXPORT_FUNC funcs.
 
-inherit ::= ISYMBOL(i). { e_inherit(i.string() ); i.release_this (); }
+inherit ::= ISYMBOL(i). { e_inherit( lex, i.string() ); i.release_this (); }
 inherits ::= inherits inherit.
 inherits ::= inherit.
 statement ::= INHERIT inherits.
 
 statement ::= INCLUDE ISYMBOL(i).
-        { e_include(i.string() ); i.release_this(); }
+        { e_include( lex, i.string() ); i.release_this(); }
 
 statement ::= REQUIRE ISYMBOL(i).
-        { e_require(i.string() ); i.release_this(); }
+        { e_require( lex, i.string() ); i.release_this(); }
 
 proc_body(r) ::= proc_body(l) PROC_BODY(b).
         { /* concatenate body lines */
@@ -139,17 +140,17 @@ proc_body(r) ::= proc_body(l) PROC_BODY(b).
         }
 proc_body(b) ::= . { b.assignString(0); }
 statement ::= variable(p) PROC_OPEN proc_body(b) PROC_CLOSE.
-        { e_proc( p.string(), b.string() );
+        { e_proc( lex, p.string(), b.string() );
           p.release_this(); b.release_this(); }
 statement ::= PYTHON SYMBOL(p) PROC_OPEN proc_body(b) PROC_CLOSE.
-        { e_proc_python (p.string(), b.string() );
+        { e_proc_python ( lex, p.string(), b.string() );
           p.release_this(); b.release_this(); }
 statement ::= PYTHON PROC_OPEN proc_body(b) PROC_CLOSE.
-        { e_proc_python( NULL, b.string());
+        { e_proc_python( lex, NULL, b.string());
           b.release_this (); }
 
 statement ::= FAKEROOT SYMBOL(p) PROC_OPEN proc_body(b) PROC_CLOSE.
-        { e_proc_fakeroot(p.string(), b.string() );
+        { e_proc_fakeroot( lex, p.string(), b.string() );
           p.release_this (); b.release_this (); }
 
 def_body(r) ::= def_body(l) DEF_BODY(b).
@@ -159,6 +160,6 @@ def_body(r) ::= def_body(l) DEF_BODY(b).
         }
 def_body(b) ::= . { b.assignString( 0 ); }
 statement ::= SYMBOL(p) DEF_ARGS(a) def_body(b).
-        { e_def( p.string(), a.string(), b.string());
+        { e_def( lex, p.string(), a.string(), b.string());
           p.release_this(); a.release_this(); b.release_this(); }
 
index 88e5043..8e95fd9 100644 (file)
@@ -3096,12 +3096,7 @@ int lex_t::line ()const
     return yyget_lineno (scanner);
 }
 
-const char* lex_t::filename ()const
-{
-    return m_fileName;
-}
-
-void parse (MappedFile* mf)
+void parse (FILE* file, PyObject* data)
 {
     void* parser = bbparseAlloc (malloc);
     yyscan_t scanner;
@@ -3111,9 +3106,8 @@ void parse (MappedFile* mf)
 
     lex.parser = parser;
     lex.scanner = scanner;
-    lex.mf = mf;
-    lex.rgbInput = mf->m_rgb;
-    lex.cbInput = mf->m_cb;
+    lex.file = file;
+    lex.data = data;
     lex.parse = bbparse;
     yyset_extra (&lex, scanner);
 
@@ -3124,7 +3118,7 @@ void parse (MappedFile* mf)
     bbparseTrace (NULL, NULL);
 
     if (result != T_EOF)
-        WARNING ("premature end of file\n");
+        printf ("premature end of file\n");
 
     yylex_destroy (scanner);
     bbparseFree (parser, free);
index 3eec484..782bc57 100644 (file)
@@ -259,12 +259,7 @@ int lex_t::line ()const
     return yyget_lineno (scanner);
 }
 
-const char* lex_t::filename ()const
-{
-    return m_fileName;
-}
-
-void parse (MappedFile* mf)
+void parse (FILE* file, PyObject* data)
 {
     void* parser = bbparseAlloc (malloc);
     yyscan_t scanner;
@@ -274,9 +269,8 @@ void parse (MappedFile* mf)
 
     lex.parser = parser;
     lex.scanner = scanner;
-    lex.mf = mf;
-    lex.rgbInput = mf->m_rgb;
-    lex.cbInput = mf->m_cb;
+    lex.file = file;
+    lex.data = data;
     lex.parse = bbparse;
     yyset_extra (&lex, scanner);
 
@@ -287,7 +281,7 @@ void parse (MappedFile* mf)
     bbparseTrace (NULL, NULL);
 
     if (result != T_EOF)
-        WARNING ("premature end of file\n");
+        printf ("premature end of file\n");
 
     yylex_destroy (scanner);
     bbparseFree (parser, free);
index ef63352..0a985ed 100644 (file)
@@ -24,17 +24,29 @@ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #ifndef LEXER_H
 #define LEXER_H
 
+/*
+ * The PyObject Token. Likely to be
+ * a bb.data implementation
+ */
+struct PyObject;
+
+
+/**
+ * This is used by the Parser and Scanner
+ * of BitBake.
+ * The implementation and creation is done
+ * in the scanner.
+ */
 struct lex_t {
     void *parser;
     void *scanner;
+    FILE *file;
+    PyObject *data;
     void* (*parse)(void*, int, token_t, lex_t*);
 
     void accept(int token, const char* string = 0);
     void input(char *buf, int *result, int max_size);
     int  line()const;
-    const char* filename()const;
-private:
-    const char* m_fileName;
 };
 
 
diff --git a/lib/bb/parse/parse_c/python_output.h b/lib/bb/parse/parse_c/python_output.h
new file mode 100644 (file)
index 0000000..de7544c
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef PYTHON_OUTPUT_H
+#define PYTHON_OUTPUT_H
+/*
+Copyright (C) 2006 Holger Hans Peter Freyther
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
+SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+This is the glue:
+    It will be called from the lemon grammar and will call into
+    python to set certain things.
+
+*/
+
+struct lex_t;
+
+extern void e_assign(lex_t*, const char*, const char*);
+extern void e_export(lex_t*, const char*);
+extern void e_immediate(lex_t*, const char*, const char*);
+extern void e_cond(lex_t*, const char*, const char*);
+extern void e_assign(lex_t*, const char*, const char*);
+extern void e_prepend(lex_t*, const char*, const char*);
+extern void e_append(lex_t*, const char*, const char*);
+extern void e_addtask(lex_t*, const char*, const char*, const char*);
+extern void e_addhandler(lex_t*,const char*);
+extern void e_export_func(lex_t*, const char*);
+extern void e_inherit(lex_t*, const char*);
+extern void e_include(lex_t*, const char*);
+extern void e_require(lex_t*, const char*);
+extern void e_proc(lex_t*, const char*, const char*);
+extern void e_proc_python(lex_t*, const char*, const char*);
+extern void e_proc_fakeroot(lex_t*, const char*, const char*);
+extern void e_def(lex_t*, const char*, const char*, const char*);
+extern void e_parse_error(lex_t*);
+
+#endif // PYTHON_OUTPUT_H
index dc8e578..c624201 100644 (file)
@@ -61,16 +61,15 @@ inline const char* token_t::string()const
  */
 inline char* token_t::concatString(const char* l, const char* r)
 {
-#if 0
     size_t cb = (l ? strlen (l) : 0) + strlen (r) + 1;
-    r_sz = new char[cb];
+    char *r_sz = new char[cb];
     *r_sz = 0;
-    if (l) strcat (r_sz, l);
+
+    if (l)
+        strcat (r_sz, l);
     strcat (r_sz, r);
 
     return r_sz;
-#endif
-#warning "XXX fixme"
 }
 
 inline void token_t::assignString(char* str)