summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2006-07-25 20:37:57 +0000
committerHolger Hans Peter Freyther <zecke@selfish.org>2006-07-25 20:37:57 +0000
commit2f4702ca15eb7a77a44e011e6e400b528bb7f85e (patch)
tree6e965a2329d622162d68f557cab41b49b39e28f8
parent6dca45af90bd838e138c8d9b18c9f5bf657903a3 (diff)
downloadbitbake-2f4702ca15eb7a77a44e011e6e400b528bb7f85e.tar.gz
r420@snorf: ich | 2006-07-25 21:29:45 +0200
Tabs -> Space r421@snorf: ich | 2006-07-25 21:45:00 +0200 lib/bb/parser/parse_c: Check if we parse a configuration file Check if we parse a configuration file and if we parse a config file and see illegal constructs like methods we will throw and parse error. r422@snorf: ich | 2006-07-25 21:48:05 +0200 lib/bb/parse/parse_c: Make sure to return 0 if we return -1 in some branch r423@snorf: ich | 2006-07-25 22:21:06 +0200 lib/bb/parse/parse_c: Modify BBPATH, handle inherits Add BBPATH to the dirname of the current fn. Handle INHERITS and include these files. r424@snorf: ich | 2006-07-25 22:22:50 +0200 lib/bb/parse/parse_c: Handle IOErrors on inheriting INHERITS
-rw-r--r--lib/bb/parse/parse_c/BBHandler.py107
-rw-r--r--lib/bb/parse/parse_c/bitbakec.pyx85
-rw-r--r--lib/bb/parse/parse_c/bitbakeparser.cc144
-rw-r--r--lib/bb/parse/parse_c/bitbakescanner.cc127
-rw-r--r--lib/bb/parse/parse_c/bitbakescanner.l3
-rw-r--r--lib/bb/parse/parse_c/lexer.h1
-rw-r--r--lib/bb/parse/parse_c/lexerc.h1
7 files changed, 286 insertions, 182 deletions
diff --git a/lib/bb/parse/parse_c/BBHandler.py b/lib/bb/parse/parse_c/BBHandler.py
index 984ba394c..b430e1f4e 100644
--- a/lib/bb/parse/parse_c/BBHandler.py
+++ b/lib/bb/parse/parse_c/BBHandler.py
@@ -5,30 +5,30 @@
Reads a .bb file and obtains its metadata (using a C++ parser)
Copyright (C) 2006 Tim Robert Ansell
- Copyright (C) 2006 Holger Hans Peter Freyther
-
+ Copyright (C) 2006 Holger Hans Peter Freyther
+
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
- 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.
+ 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.
"""
import os, sys
@@ -66,27 +66,52 @@ def init(fn, data):
if not bb.data.getVar('BBPATH', data):
bb.data.setVar('BBPATH', os.path.join(sys.prefix, 'share', 'bitbake'), data)
+def handle_inherit(d):
+ """
+ Handle inheriting of classes. This will load all default classes.
+ It could be faster, it could detect infinite loops but this is todo
+ Also this delayed loading of bb.parse could impose a penalty
+ """
+ from bb.parse import handle
+
+ files = (data.getVar('INHERIT', d, True) or "").split()
+ if not "base" in i:
+ files[0:0] = ["base"]
+
+ __inherit_cache = data.getVar('__inherit_cache', d) or []
+ for f in files:
+ file = data.expand(f, d)
+ if file[0] != "/" and file[-8:] != ".bbclass":
+ file = os.path.join('classes', '%s.bbclass' % file)
+
+ if not file in __inherit_cache:
+ debug(2, "BB %s:%d: inheriting %s" % (fn, lineno, file))
+ __inherit_cache.append( file )
+
+ try:
+ handle(file, d, True)
+ except IOError:
+ print "Failed to inherit %s" % file
+ data.setVar('__inherit_cache', __inherit_cache, d)
+
def handle(fn, d, include):
from bb import data, parse
- #print ""
- #print "fn: %s" % fn
- #print "data: %s" % d
- #print dir(d)
- #print d.getVar.__doc__
- #print "include: %s" % fn
+ (root, ext) = os.path.splitext(os.path.basename(fn))
+ base_name = "%s%s" % (root,ext)
# initialize with some data
init(fn,d)
# check if we include or are the beginning
+ oldfile = None
if include:
oldfile = d.getVar('FILE', False)
- else:
- if fn[-5:] == ".conf":
- data.inheritFromOS(d)
- oldfile = None
+ is_conf = False
+ elif ext == ".conf":
+ is_conf = True
+ data.inheritFromOS(d)
# find the file
if not os.path.isabs(fn):
@@ -102,13 +127,35 @@ def handle(fn, d, include):
if include:
parse.mark_dependency(d, abs_fn)
+ # manipulate the bbpath
+ if ext != ".bbclass" and ext != ".conf":
+ old_bb_path = data.getVar('BBPATH', d)
+ data.setVar('BBPATH', os.path.dirname(abs_fn) + (":%s" %old_bb_path) , d)
+
+ # handle INHERITS and base inherit
+ if ext != ".bbclass" and ext != ".conf":
+ data.setVar('FILE', fn, d)
+ handle_interit(d)
+
# now parse this file - by defering it to C++
- parsefile(abs_fn, d)
+ parsefile(abs_fn, d, is_conf)
+
+ # Finish it up
+ if include == 0:
+ data.expandKeys(d)
+ data.update_data(d)
+ #### !!! XXX Finish it up by executing the anonfunc
+
# restore the original FILE
if oldfile:
d.setVar('FILE', oldfile)
+ # restore bbpath
+ if ext != ".bbclass" and ext != ".conf":
+ data.setVar('BBPATH', old_bb_path, d )
+
+
return d
diff --git a/lib/bb/parse/parse_c/bitbakec.pyx b/lib/bb/parse/parse_c/bitbakec.pyx
index 1070e2731..c666e9b6b 100644
--- a/lib/bb/parse/parse_c/bitbakec.pyx
+++ b/lib/bb/parse/parse_c/bitbakec.pyx
@@ -15,14 +15,15 @@ cdef extern from "lexerc.h":
void* scanner
char* name
FILE* file
+ int config
void* data
int lineError
int errorParse
- cdef extern int parse(FILE*, char*, object)
+ cdef extern int parse(FILE*, char*, object, int)
-def parsefile(object file, object data):
+def parsefile(object file, object data, object config):
#print "parsefile: 1", file, data
# Open the file
@@ -34,7 +35,7 @@ def parsefile(object file, object data):
raise IOError("No such file %s." % file)
#print "parsefile: 3 parse"
- parse(f, file, data)
+ parse(f, file, data, config)
# Close the file
fclose(f)
@@ -104,7 +105,7 @@ cdef public void e_postcat(lex_t* c, char* key, char* what):
d = <object>c.data
d.setVar(key, (d.getVar(key,0) or "") + what)
-cdef public void e_addtask(lex_t* c, char* name, char* before, char* after):
+cdef public int e_addtask(lex_t* c, char* name, char* before, char* after) except -1:
#print "e_addtask", name
# func = m.group("func")
# before = m.group("before")
@@ -123,8 +124,13 @@ cdef public void e_addtask(lex_t* c, char* name, char* before, char* after):
# data.setVarFlag(var, "postdeps", before.split(), d)
# return
- do = "do_%s" % name
+ if c.config == 1:
+ from bb.parse import ParseError
+ raise ParseError("No tasks allowed in config files")
+ return -1
+
d = <object>c.data
+ do = "do_%s" % name
d.setVarFlag(do, "task", 1)
if before != NULL and strlen(before) > 0:
@@ -134,20 +140,38 @@ cdef public void e_addtask(lex_t* c, char* name, char* before, char* after):
#print "After", after
d.setVarFlag(do, "deps", ("%s" % after).split())
+ return 0
-cdef public void e_addhandler(lex_t* c, char* h):
+cdef public int e_addhandler(lex_t* c, char* h) except -1:
#print "e_addhandler", h
# data.setVarFlag(h, "handler", 1, d)
+ if c.config == 1:
+ from bb.parse import ParseError
+ raise ParseError("No handlers allowed in config files")
+ return -1
+
d = <object>c.data
d.setVarFlag(h, "handler", 1)
+ return 0
-cdef public void e_export_func(lex_t* c, char* function):
+cdef public int e_export_func(lex_t* c, char* function) except -1:
#print "e_export_func", function
- pass
+ if c.config == 1:
+ from bb.parse import ParseError
+ raise ParseError("No functions allowed in config files")
+ return -1
-cdef public void e_inherit(lex_t* c, char* file):
+ return 0
+
+cdef public int e_inherit(lex_t* c, char* file) except -1:
#print "e_inherit", file
- pass
+
+ if c.config == 1:
+ from bb.parse import ParseError
+ raise ParseError("No inherits allowed in config files")
+ return -1
+
+ return 0
cdef public void e_include(lex_t* c, char* file):
from bb.parse import handle
@@ -172,27 +196,52 @@ cdef public int e_require(lex_t* c, char* file) except -1:
raise ParseError("Could not include required file %s" % file)
return -1
-cdef public void e_proc(lex_t* c, char* key, char* what):
+ return 0
+
+cdef public int e_proc(lex_t* c, char* key, char* what) except -1:
#print "e_proc", key, what
- pass
+ if c.config == 1:
+ from bb.parse import ParseError
+ raise ParseError("No inherits allowed in config files")
+ return -1
-cdef public void e_proc_python(lex_t* c, char* key, char* what):
+ return 0
+
+cdef public int e_proc_python(lex_t* c, char* key, char* what) except -1:
#print "e_proc_python"
+ if c.config == 1:
+ from bb.parse import ParseError
+ raise ParseError("No pythin allowed in config files")
+ return -1
+
if key != NULL:
pass
#print "Key", key
if what != NULL:
pass
#print "What", what
- pass
-cdef public void e_proc_fakeroot(lex_t* c, char* key, char* what):
+ return 0
+
+cdef public int e_proc_fakeroot(lex_t* c, char* key, char* what) except -1:
#print "e_fakeroot", key, what
- pass
-cdef public void e_def(lex_t* c, char* a, char* b, char* d):
+ if c.config == 1:
+ from bb.parse import ParseError
+ raise ParseError("No fakeroot allowed in config files")
+ return -1
+
+ return 0
+
+cdef public int e_def(lex_t* c, char* a, char* b, char* d) except -1:
#print "e_def", a, b, d
- pass
+
+ if c.config == 1:
+ from bb.parse import ParseError
+ raise ParseError("No defs allowed in config files")
+ return -1
+
+ return 0
cdef public int e_parse_error(lex_t* c) except -1:
print "e_parse_error", c.name, "line:", lineError, "parse:", errorParse
diff --git a/lib/bb/parse/parse_c/bitbakeparser.cc b/lib/bb/parse/parse_c/bitbakeparser.cc
index ee9a901b7..9d9793f8d 100644
--- a/lib/bb/parse/parse_c/bitbakeparser.cc
+++ b/lib/bb/parse/parse_c/bitbakeparser.cc
@@ -128,51 +128,49 @@ typedef union {
*/
static const YYACTIONTYPE yy_action[] = {
/* 0 */ 82, 3, 7, 8, 38, 22, 39, 24, 26, 32,
- /* 10 */ 34, 28, 30, 128, 1, 40, 53, 70, 55, 5,
- /* 20 */ 60, 65, 67, 2, 21, 36, 69, 77, 9, 7,
- /* 30 */ 11, 6, 13, 15, 17, 19, 12, 52, 50, 4,
- /* 40 */ 74, 42, 46, 59, 57, 10, 64, 62, 38, 14,
- /* 50 */ 73, 16, 38, 38, 76, 81, 18, 20, 23, 25,
- /* 60 */ 27, 29, 31, 33, 35, 37, 56, 51, 90, 54,
- /* 70 */ 58, 71, 41, 43, 63, 45, 44, 47, 72, 48,
- /* 80 */ 75, 78, 80, 61, 90, 49, 66, 90, 90, 68,
- /* 90 */ 90, 90, 90, 90, 90, 79,
+ /* 10 */ 34, 28, 30, 2, 21, 40, 53, 70, 55, 44,
+ /* 20 */ 60, 65, 67, 128, 1, 36, 69, 77, 42, 46,
+ /* 30 */ 11, 66, 13, 15, 17, 19, 64, 62, 9, 7,
+ /* 40 */ 74, 38, 45, 81, 59, 57, 38, 38, 73, 76,
+ /* 50 */ 5, 68, 52, 50, 14, 31, 47, 71, 48, 10,
+ /* 60 */ 72, 33, 23, 49, 6, 41, 51, 78, 75, 16,
+ /* 70 */ 4, 54, 35, 25, 18, 80, 79, 56, 27, 37,
+ /* 80 */ 58, 12, 61, 29, 43, 63, 20,
};
static const YYCODETYPE yy_lookahead[] = {
/* 0 */ 0, 1, 2, 3, 23, 4, 25, 6, 7, 8,
- /* 10 */ 9, 10, 11, 31, 32, 15, 16, 1, 18, 42,
- /* 20 */ 20, 21, 22, 33, 34, 24, 26, 27, 1, 2,
- /* 30 */ 4, 28, 6, 7, 8, 9, 5, 35, 36, 29,
- /* 40 */ 24, 13, 14, 37, 38, 34, 39, 40, 23, 5,
- /* 50 */ 25, 5, 23, 23, 25, 25, 5, 5, 5, 5,
- /* 60 */ 5, 5, 5, 5, 5, 41, 17, 35, 43, 1,
- /* 70 */ 37, 24, 12, 12, 39, 12, 14, 12, 41, 13,
- /* 80 */ 41, 1, 41, 19, 43, 12, 19, 43, 43, 19,
- /* 90 */ 43, 43, 43, 43, 43, 24,
+ /* 10 */ 9, 10, 11, 33, 34, 15, 16, 1, 18, 14,
+ /* 20 */ 20, 21, 22, 31, 32, 24, 26, 27, 13, 14,
+ /* 30 */ 4, 19, 6, 7, 8, 9, 39, 40, 1, 2,
+ /* 40 */ 24, 23, 12, 25, 37, 38, 23, 23, 25, 25,
+ /* 50 */ 42, 19, 35, 36, 5, 5, 12, 24, 13, 34,
+ /* 60 */ 41, 5, 5, 12, 28, 12, 35, 1, 41, 5,
+ /* 70 */ 29, 1, 5, 5, 5, 41, 24, 17, 5, 41,
+ /* 80 */ 37, 5, 19, 5, 12, 39, 5,
};
#define YY_SHIFT_USE_DFLT (-20)
static const signed char yy_shift_ofst[] = {
- /* 0 */ -20, 0, -20, 10, -20, 3, -20, -20, 27, -20,
- /* 10 */ 26, 31, -20, 44, -20, 46, -20, 51, -20, 52,
- /* 20 */ -20, 1, 53, -20, 54, -20, 55, -20, 56, -20,
- /* 30 */ 57, -20, 58, -20, 59, -20, -20, -19, -20, -20,
- /* 40 */ 60, 28, 61, 62, 63, -20, 65, 66, 73, -20,
- /* 50 */ 60, -20, -20, 68, -20, 49, -20, 49, -20, -20,
- /* 60 */ 64, -20, 64, -20, -20, 67, -20, 70, -20, 16,
- /* 70 */ 47, -20, 25, -20, -20, 29, -20, 80, 71, -20,
- /* 80 */ 30, -20,
+ /* 0 */ -20, 0, -20, 41, -20, 36, -20, -20, 37, -20,
+ /* 10 */ 26, 76, -20, 49, -20, 64, -20, 69, -20, 81,
+ /* 20 */ -20, 1, 57, -20, 68, -20, 73, -20, 78, -20,
+ /* 30 */ 50, -20, 56, -20, 67, -20, -20, -19, -20, -20,
+ /* 40 */ 53, 15, 72, 5, 30, -20, 44, 45, 51, -20,
+ /* 50 */ 53, -20, -20, 70, -20, 60, -20, 60, -20, -20,
+ /* 60 */ 63, -20, 63, -20, -20, 12, -20, 32, -20, 16,
+ /* 70 */ 33, -20, 23, -20, -20, 24, -20, 66, 52, -20,
+ /* 80 */ 18, -20,
};
-#define YY_REDUCE_USE_DFLT (-24)
+#define YY_REDUCE_USE_DFLT (-21)
static const signed char yy_reduce_ofst[] = {
- /* 0 */ -18, -10, -24, -24, -23, -24, -24, -24, 11, -24,
- /* 10 */ -24, -24, -24, -24, -24, -24, -24, -24, -24, -24,
- /* 20 */ -24, -24, -24, -24, -24, -24, -24, -24, -24, -24,
- /* 30 */ -24, -24, -24, -24, -24, -24, 24, -24, -24, -24,
- /* 40 */ 2, -24, -24, -24, -24, -24, -24, -24, -24, -24,
- /* 50 */ 32, -24, -24, -24, -24, 6, -24, 33, -24, -24,
- /* 60 */ 7, -24, 35, -24, -24, -24, -24, -24, -24, -24,
- /* 70 */ -24, 37, -24, -24, 39, -24, -24, -24, -24, 41,
- /* 80 */ -24, -24,
+ /* 0 */ -8, -20, -21, -21, 8, -21, -21, -21, 25, -21,
+ /* 10 */ -21, -21, -21, -21, -21, -21, -21, -21, -21, -21,
+ /* 20 */ -21, -21, -21, -21, -21, -21, -21, -21, -21, -21,
+ /* 30 */ -21, -21, -21, -21, -21, -21, 38, -21, -21, -21,
+ /* 40 */ 17, -21, -21, -21, -21, -21, -21, -21, -21, -21,
+ /* 50 */ 31, -21, -21, -21, -21, 7, -21, 43, -21, -21,
+ /* 60 */ -3, -21, 46, -21, -21, -21, -21, -21, -21, -21,
+ /* 70 */ -21, 19, -21, -21, 27, -21, -21, -21, -21, 34,
+ /* 80 */ -21, -21,
};
static const YYACTIONTYPE yy_default[] = {
/* 0 */ 84, 127, 83, 85, 125, 126, 124, 86, 127, 85,
@@ -420,7 +418,7 @@ static void yy_destructor(YYCODETYPE yymajor, YYMINORTYPE *yypminor){
case 29:
#line 50 "bitbakeparser.y"
{ (yypminor->yy0).release_this (); }
-#line 425 "bitbakeparser.c"
+#line 423 "bitbakeparser.c"
break;
default: break; /* If no destructor action specified: do nothing */
}
@@ -694,7 +692,7 @@ static void yy_reduce(
{ yygotominor.yy0.assignString( (char*)yymsp[0].minor.yy0.string() );
yymsp[0].minor.yy0.assignString( 0 );
yymsp[0].minor.yy0.release_this(); }
-#line 699 "bitbakeparser.c"
+#line 697 "bitbakeparser.c"
break;
case 4:
#line 64 "bitbakeparser.y"
@@ -702,7 +700,7 @@ static void yy_reduce(
yygotominor.yy0.assignString( (char*)yymsp[0].minor.yy0.string() );
yymsp[0].minor.yy0.assignString( 0 );
yymsp[0].minor.yy0.release_this(); }
-#line 707 "bitbakeparser.c"
+#line 705 "bitbakeparser.c"
break;
case 5:
#line 70 "bitbakeparser.y"
@@ -711,7 +709,7 @@ static void yy_reduce(
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 716 "bitbakeparser.c"
+#line 714 "bitbakeparser.c"
break;
case 6:
#line 74 "bitbakeparser.y"
@@ -720,7 +718,7 @@ static void yy_reduce(
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 725 "bitbakeparser.c"
+#line 723 "bitbakeparser.c"
break;
case 7:
#line 78 "bitbakeparser.y"
@@ -729,7 +727,7 @@ static void yy_reduce(
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 734 "bitbakeparser.c"
+#line 732 "bitbakeparser.c"
break;
case 8:
#line 82 "bitbakeparser.y"
@@ -738,7 +736,7 @@ static void yy_reduce(
yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(3,&yymsp[-3].minor);
yy_destructor(8,&yymsp[-1].minor);
}
-#line 743 "bitbakeparser.c"
+#line 741 "bitbakeparser.c"
break;
case 9:
#line 86 "bitbakeparser.y"
@@ -746,56 +744,56 @@ static void yy_reduce(
yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(3,&yymsp[-3].minor);
yy_destructor(9,&yymsp[-1].minor);
}
-#line 751 "bitbakeparser.c"
+#line 749 "bitbakeparser.c"
break;
case 10:
#line 90 "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 758 "bitbakeparser.c"
+#line 756 "bitbakeparser.c"
break;
case 11:
#line 93 "bitbakeparser.y"
{ e_precat( 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 765 "bitbakeparser.c"
+#line 763 "bitbakeparser.c"
break;
case 12:
#line 96 "bitbakeparser.y"
{ e_postcat( 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 772 "bitbakeparser.c"
+#line 770 "bitbakeparser.c"
break;
case 13:
#line 99 "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(10,&yymsp[-1].minor);
}
-#line 779 "bitbakeparser.c"
+#line 777 "bitbakeparser.c"
break;
case 14:
#line 102 "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(11,&yymsp[-1].minor);
}
-#line 786 "bitbakeparser.c"
+#line 784 "bitbakeparser.c"
break;
case 15:
#line 105 "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(8,&yymsp[-1].minor);
}
-#line 793 "bitbakeparser.c"
+#line 791 "bitbakeparser.c"
break;
case 16:
#line 108 "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(9,&yymsp[-1].minor);
}
-#line 800 "bitbakeparser.c"
+#line 798 "bitbakeparser.c"
break;
case 17:
#line 112 "bitbakeparser.y"
@@ -803,7 +801,7 @@ static void yy_reduce(
yymsp[-4].minor.yy0.release_this(); yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(13,&yymsp[-3].minor);
yy_destructor(14,&yymsp[-1].minor);
}
-#line 808 "bitbakeparser.c"
+#line 806 "bitbakeparser.c"
break;
case 18:
#line 115 "bitbakeparser.y"
@@ -811,55 +809,55 @@ static void yy_reduce(
yymsp[-4].minor.yy0.release_this(); yymsp[-2].minor.yy0.release_this(); yymsp[0].minor.yy0.release_this(); yy_destructor(14,&yymsp[-3].minor);
yy_destructor(13,&yymsp[-1].minor);
}
-#line 816 "bitbakeparser.c"
+#line 814 "bitbakeparser.c"
break;
case 19:
#line 118 "bitbakeparser.y"
{ e_addtask( lex, yymsp[0].minor.yy0.string(), NULL, NULL);
yymsp[0].minor.yy0.release_this();}
-#line 822 "bitbakeparser.c"
+#line 820 "bitbakeparser.c"
break;
case 20:
#line 121 "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(13,&yymsp[-1].minor);
}
-#line 829 "bitbakeparser.c"
+#line 827 "bitbakeparser.c"
break;
case 21:
#line 124 "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(14,&yymsp[-1].minor);
}
-#line 836 "bitbakeparser.c"
+#line 834 "bitbakeparser.c"
break;
case 25:
#line 131 "bitbakeparser.y"
{ e_addhandler( lex, yymsp[0].minor.yy0.string()); yymsp[0].minor.yy0.release_this (); yy_destructor(16,&yymsp[-1].minor);
}
-#line 842 "bitbakeparser.c"
+#line 840 "bitbakeparser.c"
break;
case 26:
#line 133 "bitbakeparser.y"
{ e_export_func( lex, yymsp[0].minor.yy0.string()); yymsp[0].minor.yy0.release_this(); }
-#line 847 "bitbakeparser.c"
+#line 845 "bitbakeparser.c"
break;
case 30:
#line 138 "bitbakeparser.y"
{ e_inherit( lex, yymsp[0].minor.yy0.string() ); yymsp[0].minor.yy0.release_this (); }
-#line 852 "bitbakeparser.c"
+#line 850 "bitbakeparser.c"
break;
case 34:
#line 144 "bitbakeparser.y"
{ e_include( lex, yymsp[0].minor.yy0.string() ); yymsp[0].minor.yy0.release_this(); yy_destructor(21,&yymsp[-1].minor);
}
-#line 858 "bitbakeparser.c"
+#line 856 "bitbakeparser.c"
break;
case 35:
#line 147 "bitbakeparser.y"
{ e_require( lex, yymsp[0].minor.yy0.string() ); yymsp[0].minor.yy0.release_this(); yy_destructor(22,&yymsp[-1].minor);
}
-#line 864 "bitbakeparser.c"
+#line 862 "bitbakeparser.c"
break;
case 36:
#line 150 "bitbakeparser.y"
@@ -868,12 +866,12 @@ static void yy_reduce(
yymsp[-1].minor.yy0.release_this ();
yymsp[0].minor.yy0.release_this ();
}
-#line 873 "bitbakeparser.c"
+#line 871 "bitbakeparser.c"
break;
case 37:
#line 155 "bitbakeparser.y"
{ yygotominor.yy0.assignString(0); }
-#line 878 "bitbakeparser.c"
+#line 876 "bitbakeparser.c"
break;
case 38:
#line 157 "bitbakeparser.y"
@@ -881,7 +879,7 @@ static void yy_reduce(
yymsp[-3].minor.yy0.release_this(); yymsp[-1].minor.yy0.release_this(); yy_destructor(24,&yymsp[-2].minor);
yy_destructor(25,&yymsp[0].minor);
}
-#line 886 "bitbakeparser.c"
+#line 884 "bitbakeparser.c"
break;
case 39:
#line 160 "bitbakeparser.y"
@@ -890,7 +888,7 @@ static void yy_reduce(
yy_destructor(24,&yymsp[-2].minor);
yy_destructor(25,&yymsp[0].minor);
}
-#line 895 "bitbakeparser.c"
+#line 893 "bitbakeparser.c"
break;
case 40:
#line 163 "bitbakeparser.y"
@@ -899,7 +897,7 @@ static void yy_reduce(
yy_destructor(24,&yymsp[-2].minor);
yy_destructor(25,&yymsp[0].minor);
}
-#line 904 "bitbakeparser.c"
+#line 902 "bitbakeparser.c"
break;
case 41:
#line 167 "bitbakeparser.y"
@@ -908,7 +906,7 @@ static void yy_reduce(
yy_destructor(24,&yymsp[-2].minor);
yy_destructor(25,&yymsp[0].minor);
}
-#line 913 "bitbakeparser.c"
+#line 911 "bitbakeparser.c"
break;
case 42:
#line 171 "bitbakeparser.y"
@@ -916,18 +914,18 @@ static void yy_reduce(
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 921 "bitbakeparser.c"
+#line 919 "bitbakeparser.c"
break;
case 43:
#line 175 "bitbakeparser.y"
{ yygotominor.yy0.assignString( 0 ); }
-#line 926 "bitbakeparser.c"
+#line 924 "bitbakeparser.c"
break;
case 44:
#line 177 "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 932 "bitbakeparser.c"
+#line 930 "bitbakeparser.c"
break;
};
yygoto = yyRuleInfo[yyruleno].lhs;
@@ -986,7 +984,7 @@ static void yy_syntax_error(
#define TOKEN (yyminor.yy0)
#line 52 "bitbakeparser.y"
e_parse_error( lex );
-#line 992 "bitbakeparser.c"
+#line 990 "bitbakeparser.c"
bbparseARG_STORE; /* Suppress warning about unused %extra_argument variable */
}
@@ -1042,7 +1040,7 @@ void bbparse(
/* (re)initialize the parser, if necessary */
yypParser = (yyParser*)yyp;
if( yypParser->yyidx<0 ){
- /* if( yymajor==0 ) return; // not sure why this was here... */
+ if( yymajor==0 ) return;
yypParser->yyidx = 0;
yypParser->yyerrcnt = -1;
yypParser->yystack[0].stateno = 0;
diff --git a/lib/bb/parse/parse_c/bitbakescanner.cc b/lib/bb/parse/parse_c/bitbakescanner.cc
index b35015271..acc13f7c3 100644
--- a/lib/bb/parse/parse_c/bitbakescanner.cc
+++ b/lib/bb/parse/parse_c/bitbakescanner.cc
@@ -8,7 +8,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 31
+#define YY_FLEX_SUBMINOR_VERSION 33
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -30,7 +30,15 @@
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
-#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
+#if __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+
#include <inttypes.h>
typedef int8_t flex_int8_t;
typedef uint8_t flex_uint8_t;
@@ -153,6 +161,10 @@ int yylex_init (yyscan_t* scanner);
#define YY_BUF_SIZE 16384
#endif
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
@@ -1351,7 +1363,7 @@ static const char* fixup_escapes (const char* sz);
-#line 1355 "<stdout>"
+#line 1367 "<stdout>"
#define INITIAL 0
#define S_DEF 1
@@ -1587,11 +1599,11 @@ YY_DECL
#line 164 "bitbakescanner.l"
-#line 1591 "<stdout>"
+#line 1603 "<stdout>"
- if ( yyg->yy_init )
+ if ( !yyg->yy_init )
{
- yyg->yy_init = 0;
+ yyg->yy_init = 1;
#ifdef YY_USER_INIT
YY_USER_INIT;
@@ -1972,7 +1984,7 @@ YY_RULE_SETUP
#line 254 "bitbakescanner.l"
ECHO;
YY_BREAK
-#line 1976 "<stdout>"
+#line 1988 "<stdout>"
case YY_END_OF_BUFFER:
{
@@ -2274,7 +2286,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
{
register int yy_is_jam;
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
register char *yy_cp = yyg->yy_c_buf_p;
register YY_CHAR yy_c = 1;
@@ -2730,10 +2742,10 @@ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscann
* @note If you want to scan bytes that may contain NUL values, then use
* yy_scan_bytes() instead.
*/
-YY_BUFFER_STATE yy_scan_string (yyconst char * yy_str , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
{
- return yy_scan_bytes(yy_str,strlen(yy_str) ,yyscanner);
+ return yy_scan_bytes(yystr,strlen(yystr) ,yyscanner);
}
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
@@ -2743,7 +2755,7 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yy_str , yyscan_t yyscanner)
* @param yyscanner The scanner object.
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE yy_scan_bytes (yyconst char * bytes, int len , yyscan_t yyscanner)
+YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
{
YY_BUFFER_STATE b;
char *buf;
@@ -2751,15 +2763,15 @@ YY_BUFFER_STATE yy_scan_bytes (yyconst char * bytes, int len , yyscan_t yyscan
int i;
/* Get memory for full buffer, including space for trailing EOB's. */
- n = len + 2;
+ n = _yybytes_len + 2;
buf = (char *) yyalloc(n ,yyscanner );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
- for ( i = 0; i < len; ++i )
- buf[i] = bytes[i];
+ for ( i = 0; i < _yybytes_len; ++i )
+ buf[i] = yybytes[i];
- buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
b = yy_scan_buffer(buf,n ,yyscanner);
if ( ! b )
@@ -2987,21 +2999,51 @@ void yyset_debug (int bdebug , yyscan_t yyscanner)
/* Accessor methods for yylval and yylloc */
+/* User-visible API */
+
+/* yylex_init is special because it creates the scanner itself, so it is
+ * the ONLY reentrant function that doesn't take the scanner as the last argument.
+ * That's why we explicitly handle the declaration, instead of using our macros.
+ */
+
+int yylex_init(yyscan_t* ptr_yy_globals)
+
+{
+ if (ptr_yy_globals == NULL){
+ errno = EINVAL;
+ return 1;
+ }
+
+ *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
+
+ if (*ptr_yy_globals == NULL){
+ errno = ENOMEM;
+ return 1;
+ }
+
+ /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
+
+ return yy_init_globals ( *ptr_yy_globals );
+}
+
static int yy_init_globals (yyscan_t yyscanner)
{
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
/* Initialization is the same as for the non-reentrant scanner.
- This function is called once per scanner lifetime. */
+ * This function is called from yylex_destroy(), so don't allocate here.
+ */
yyg->yy_buffer_stack = 0;
yyg->yy_buffer_stack_top = 0;
yyg->yy_buffer_stack_max = 0;
yyg->yy_c_buf_p = (char *) 0;
- yyg->yy_init = 1;
+ yyg->yy_init = 0;
yyg->yy_start = 0;
+
yyg->yy_start_stack_ptr = 0;
yyg->yy_start_stack_depth = 0;
- yyg->yy_start_stack = (int *) 0;
+ yyg->yy_start_stack = NULL;
/* Defined in main.c */
#ifdef YY_STDINIT
@@ -3018,33 +3060,6 @@ static int yy_init_globals (yyscan_t yyscanner)
return 0;
}
-/* User-visible API */
-
-/* yylex_init is special because it creates the scanner itself, so it is
- * the ONLY reentrant function that doesn't take the scanner as the last argument.
- * That's why we explicitly handle the declaration, instead of using our macros.
- */
-
-int yylex_init(yyscan_t* ptr_yy_globals)
-
-{
- if (ptr_yy_globals == NULL){
- errno = EINVAL;
- return 1;
- }
-
- *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
-
- if (*ptr_yy_globals == NULL){
- errno = ENOMEM;
- return 1;
- }
-
- memset(*ptr_yy_globals,0,sizeof(struct yyguts_t));
-
- return yy_init_globals ( *ptr_yy_globals );
-}
-
/* yylex_destroy is for both reentrant and non-reentrant scanners. */
int yylex_destroy (yyscan_t yyscanner)
{
@@ -3065,8 +3080,13 @@ int yylex_destroy (yyscan_t yyscanner)
yyfree(yyg->yy_start_stack ,yyscanner );
yyg->yy_start_stack = NULL;
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
+ * yylex() is called, initialization will occur. */
+ yy_init_globals( yyscanner);
+
/* Destroy the main struct (reentrant only). */
yyfree ( yyscanner , yyscanner );
+ yyscanner = NULL;
return 0;
}
@@ -3078,7 +3098,6 @@ int yylex_destroy (yyscan_t yyscanner)
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
{
register int i;
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
}
@@ -3088,7 +3107,6 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yysca
static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
{
register int n;
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
for ( n = 0; s[n]; ++n )
;
@@ -3120,18 +3138,6 @@ void yyfree (void * ptr , yyscan_t yyscanner)
#define YYTABLES_NAME "yytables"
-#undef YY_NEW_FILE
-#undef YY_FLUSH_BUFFER
-#undef yy_set_bol
-#undef yy_new_buffer
-#undef yy_set_interactive
-#undef yytext_ptr
-#undef YY_DO_BEFORE_ACTION
-
-#ifdef YY_DECL_IS_OURS
-#undef YY_DECL_IS_OURS
-#undef YY_DECL
-#endif
#line 254 "bitbakescanner.l"
@@ -3162,7 +3168,7 @@ int lex_t::line ()const
extern "C" {
- void parse (FILE* file, char* name, PyObject* data)
+ void parse (FILE* file, char* name, PyObject* data, int config)
{
/* printf("parse bbparseAlloc\n"); */
void* parser = bbparseAlloc (malloc);
@@ -3177,6 +3183,7 @@ extern "C" {
lex.file = file;
lex.name = name;
lex.data = data;
+ lex.config = config;
lex.parse = bbparse;
/*printf("parse yyset_extra\n"); */
yyset_extra (&lex, scanner);
diff --git a/lib/bb/parse/parse_c/bitbakescanner.l b/lib/bb/parse/parse_c/bitbakescanner.l
index aadfb2ec3..b6592f28e 100644
--- a/lib/bb/parse/parse_c/bitbakescanner.l
+++ b/lib/bb/parse/parse_c/bitbakescanner.l
@@ -279,7 +279,7 @@ int lex_t::line ()const
extern "C" {
- void parse (FILE* file, char* name, PyObject* data)
+ void parse (FILE* file, char* name, PyObject* data, int config)
{
/* printf("parse bbparseAlloc\n"); */
void* parser = bbparseAlloc (malloc);
@@ -294,6 +294,7 @@ extern "C" {
lex.file = file;
lex.name = name;
lex.data = data;
+ lex.config = config;
lex.parse = bbparse;
/*printf("parse yyset_extra\n"); */
yyset_extra (&lex, scanner);
diff --git a/lib/bb/parse/parse_c/lexer.h b/lib/bb/parse/parse_c/lexer.h
index 91cd1c073..cb32be703 100644
--- a/lib/bb/parse/parse_c/lexer.h
+++ b/lib/bb/parse/parse_c/lexer.h
@@ -34,6 +34,7 @@ struct lex_t {
FILE* file;
char *name;
PyObject *data;
+ int config;
void* (*parse)(void*, int, token_t, lex_t*);
diff --git a/lib/bb/parse/parse_c/lexerc.h b/lib/bb/parse/parse_c/lexerc.h
index de91f5121..c8a19fb22 100644
--- a/lib/bb/parse/parse_c/lexerc.h
+++ b/lib/bb/parse/parse_c/lexerc.h
@@ -13,6 +13,7 @@ typedef struct {
FILE *file;
char *name;
PyObject *data;
+ int config;
} lex_t;
#endif