1 # ex:ts=4:sw=4:sts=4:et
2 # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4 cdef extern from "stdio.h":
6 FILE *fopen(char*, char*)
9 cdef extern from "string.h":
12 cdef extern from "lexerc.h":
13 ctypedef struct lex_t:
22 cdef extern void parse(FILE*, object)
24 def parsefile(object file, object data):
25 #print "parsefile: 1", file, data
31 #print "parsefile: 2 opening file"
33 raise IOError("No such file %s." % file)
35 #print "parsefile: 3 parse"
39 #print "parsefile: 4 closing"
43 cdef public void e_assign(lex_t* container, char* key, char* what):
44 #print "e_assign", key, what
45 d = <object>container.data
48 cdef public void e_export(lex_t* c, char* what):
49 #print "e_export", what
51 # bb.data.setVarFlag(key, "export", 1, data)
53 d.setVarFlag(what, "export", 1)
55 cdef public void e_immediate(lex_t* c, char* key, char* what):
56 #print "e_immediate", key, what
58 # val = bb.data.expand(groupd["value"], data)
60 d.setVar(key, d.expand(what,None))
62 cdef public void e_cond(lex_t* c, char* key, char* what):
63 #print "e_cond", key, what
65 # val = bb.data.getVar(key, data)
67 # val = groupd["value"]
69 d.setVar(key, (d.getVar(key,0) or what))
71 cdef public void e_prepend(lex_t* c, char* key, char* what):
72 #print "e_prepend", key, what
74 # val = "%s %s" % (groupd["value"], (bb.data.getVar(key, data) or ""))
76 d.setVar(key, what + " " + (d.getVar(key,0) or ""))
78 cdef public void e_append(lex_t* c, char* key, char* what):
79 #print "e_append", key, what
81 # val = "%s %s" % ((bb.data.getVar(key, data) or ""), groupd["value"])
83 d.setVar(key, (d.getVar(key,0) or "") + " " + what)
85 cdef public void e_precat(lex_t* c, char* key, char* what):
86 #print "e_precat", key, what
88 # val = "%s%s" % (groupd["value"], (bb.data.getVar(key, data) or ""))
90 d.setVar(key, what + (d.getVar(key,0) or ""))
92 cdef public void e_postcat(lex_t* c, char* key, char* what):
93 #print "e_postcat", key, what
95 # val = "%s%s" % ((bb.data.getVar(key, data) or ""), groupd["value"])
97 d.setVar(key, (d.getVar(key,0) or "") + what)
99 cdef public void e_addtask(lex_t* c, char* name, char* before, char* after):
100 #print "e_addtask", name
101 # func = m.group("func")
102 # before = m.group("before")
103 # after = m.group("after")
108 # data.setVarFlag(var, "task", 1, d)
110 # if after is not None:
111 # # set up deps for function
112 # data.setVarFlag(var, "deps", after.split(), d)
113 # if before is not None:
114 # # set up things that depend on this func
115 # data.setVarFlag(var, "postdeps", before.split(), d)
120 d.setVarFlag(do, "task", 1)
122 if before != NULL and strlen(before) > 0:
123 #print "Before", before
124 d.setVarFlag(do, "postdeps", ("%s" % before).split())
125 if after != NULL and strlen(after) > 0:
126 #print "After", after
127 d.setVarFlag(do, "deps", ("%s" % after).split())
130 cdef public void e_addhandler(lex_t* c, char* h):
131 #print "e_addhandler", h
132 # data.setVarFlag(h, "handler", 1, d)
134 d.setVarFlag(h, "handler", 1)
136 cdef public void e_export_func(lex_t* c, char* function):
137 #print "e_export_func", function
140 cdef public void e_inherit(lex_t* c, char* file):
141 #print "e_inherit", file
144 cdef public void e_include(lex_t* c, char* file):
145 from bb.parse import handle
149 handle(d.expand(file,d), d, True)
151 print "Could not include file", file
154 cdef public void e_require(lex_t* c, char* file):
155 #print "e_require", file
156 from bb.parse import handle
160 handle(d.expand(file,d), d, True)
162 print "ParseError", file
163 from bb.parse import ParseError
164 raise ParseError("Could not include required file %s" % file)
166 cdef public void e_proc(lex_t* c, char* key, char* what):
167 #print "e_proc", key, what
170 cdef public void e_proc_python(lex_t* c, char* key, char* what):
171 #print "e_proc_python"
180 cdef public void e_proc_fakeroot(lex_t* c, char* key, char* what):
181 #print "e_fakeroot", key, what
184 cdef public void e_def(lex_t* c, char* a, char* b, char* d):
185 #print "e_def", a, b, d
188 cdef public void e_parse_error(lex_t* c):
189 print "e_parse_error", "line:", lineError, "parse:", errorParse
192 from bb.parse import ParseError
193 raise ParseError("There was an parse error, sorry unable to give more information at the current time.")