aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Parborg <darkdefende@gmail.com>2011-06-19 19:10:51 +0200
committerSebastian Parborg <darkdefende@gmail.com>2011-06-19 19:10:51 +0200
commit73a7d44e9a17daa0ab6cca1e25d7540e3d9db78a (patch)
treef71d01aec993ba6ae9f2e2b98e896f5a87335c5a
parentWorked some more (diff)
downloadebuildgen-73a7d44e9a17daa0ab6cca1e25d7540e3d9db78a.tar.gz
ebuildgen-73a7d44e9a17daa0ab6cca1e25d7540e3d9db78a.tar.bz2
ebuildgen-73a7d44e9a17daa0ab6cca1e25d7540e3d9db78a.zip
Added a stub to function inside "$()"
-rw-r--r--filetypes/makefilecom.py47
-rw-r--r--filetypes/makefiles.py21
2 files changed, 56 insertions, 12 deletions
diff --git a/filetypes/makefilecom.py b/filetypes/makefilecom.py
index 83e00bf..e83930f 100644
--- a/filetypes/makefilecom.py
+++ b/filetypes/makefilecom.py
@@ -102,6 +102,7 @@ def com_interp(string,variables):
def p_comp(p):
"""
complst : BEGINCOM newstr ENDCOM
+ | func
"""
if len(p) == 4:
p[0] = p[2]
@@ -109,8 +110,14 @@ def com_interp(string,variables):
p[0] = p[1]
def p_complst(p):
- "complst : BEGINCOM textstr ENDCOM"
- p[0] = expand(variables[p[2]],variables)
+ """
+ complst : complst BEGINCOM textstr ENDCOM
+ | BEGINCOM textstr ENDCOM
+ """
+ if len(p) == 4:
+ p[0] = expand(variables[p[2]],variables)
+ else:
+ p[0] = [p[1][0] + expand(variables[p[3]],variables)[0]]
def p_tonewstr(p):
"""
@@ -194,6 +201,38 @@ def com_interp(string,variables):
p[0] = newtextlst
+ def p_func(p):
+ """
+ func : BEGINCOM textstr SPACE funcinput
+ """
+ result = "This calls a function"
+ #result = funcexe(p[2],p[4])
+ p[0] = result
+
+ def p_funcinput(p):
+ """
+ funcinput : funcinput inputstr COMMA
+ | funcinput inputstr ENDCOM
+ | inputstr COMMA
+ | inputstr ENDCOM
+ """
+ if len(p) == 4:
+ p[0] = p[1].append(p[2])
+ else:
+ p[0] = [p[1]]
+
+ def p_inputstr(p):
+ """
+ inputstr : inputstr spacestr
+ | inputstr textstr
+ | spacestr
+ | textstr
+ """
+ if len(p) == 3:
+ p[0] = p[1] + p[2]
+ else:
+ p[0] = p[1]
+
def p_command(p):
"""
textstr : textstr COMMAND
@@ -214,7 +253,7 @@ def com_interp(string,variables):
else:
p[0] = p[1]
- def p_spacelst(p):
+ def p_spacestr(p):
"""
spacestr : spacestr SPACE
| SPACE
@@ -236,4 +275,4 @@ def com_interp(string,variables):
return retlst
-print(com_interp("($($(x)))",{"x":["y"], "y":["z"], "z":["u"],"yz":["u","v"]}))
+#print(com_interp("(y$(y))",{"x":["y"], "y":["z"], "z":["u"],"yz":["u","v"]}))
diff --git a/filetypes/makefiles.py b/filetypes/makefiles.py
index 07381d3..be0009f 100644
--- a/filetypes/makefiles.py
+++ b/filetypes/makefiles.py
@@ -155,10 +155,9 @@ def scanmakefile(makefile):
lexer = lex.lex()
- lexer.input(makefile)
- for tok in lexer:
- print(tok)
-
+ #lexer.input(makefile)
+ #for tok in lexer:
+ # print(tok)
#YACC begins here
@@ -239,13 +238,19 @@ def scanmakefile(makefile):
p[0] = p[1]
def p_command(p):
- "command : COMMAND"
- p[0] = [p[1]] #commands are lists within the testlst
+ """
+ command : command COMMAND
+ | COMMAND
+ """
+ if len(p) == 2:
+ p[0] = [p[1]] #commands are lists within the testlst
+ else:
+ p[0] = [p[1][0] + p[2]]
def p_end(p):
"""
end : end END
- | spacestr END
+ | end spacestr END
| END
"""
@@ -261,7 +266,7 @@ def scanmakefile(makefile):
def p_error(p):
- print("syntax error at '%s'" % p.type,p.lexpos)
+ print("syntax error at '%s'" % p.type,p.lineno)
pass
yacc.yacc()