summaryrefslogtreecommitdiff
path: root/numpy/f2py/lib/parser/utils.py
diff options
context:
space:
mode:
authorPearu Peterson <pearu.peterson@gmail.com>2006-10-20 06:43:31 +0000
committerPearu Peterson <pearu.peterson@gmail.com>2006-10-20 06:43:31 +0000
commitb489d3b282fd7e2ebebbf316d31b2c66a5e62389 (patch)
tree1e00703a784d7dd5a172f5b80a8fb103f547aa13 /numpy/f2py/lib/parser/utils.py
parentd4b47b7573c6d3d21cac7e97a0aee306d15b8d1b (diff)
downloadnumpy-b489d3b282fd7e2ebebbf316d31b2c66a5e62389.tar.gz
F2PY G3: started impl array support and expression parser.
Diffstat (limited to 'numpy/f2py/lib/parser/utils.py')
-rw-r--r--numpy/f2py/lib/parser/utils.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/numpy/f2py/lib/parser/utils.py b/numpy/f2py/lib/parser/utils.py
index fbb5219f6..ac2cfce8e 100644
--- a/numpy/f2py/lib/parser/utils.py
+++ b/numpy/f2py/lib/parser/utils.py
@@ -13,7 +13,7 @@ Created: May 2006
__all__ = ['split_comma', 'specs_split_comma',
'ParseError','AnalyzeError',
- 'get_module_file','parse_bind','parse_result','is_name',
+ 'get_module_file','parse_bind','parse_result','is_name','parse_array_spec',
'CHAR_BIT','str2stmt']
import re
@@ -30,22 +30,28 @@ name_re = re.compile(r'[a-z_]\w*',re.I).match
is_entity_decl = re.compile(r'^[a-z_]\w*',re.I).match
is_int_literal_constant = re.compile(r'^\d+(_\w+|)$').match
-def split_comma(line, item = None, comma=','):
+def split_comma(line, item = None, comma=',', keep_empty=False):
items = []
if item is None:
for s in line.split(comma):
s = s.strip()
- if not s: continue
+ if not s and not keep_empty: continue
items.append(s)
return items
newitem = item.copy(line, True)
apply_map = newitem.apply_map
for s in newitem.get_line().split(comma):
s = apply_map(s).strip()
- if not s: continue
+ if not s and not keep_empty: continue
items.append(s)
return items
+def parse_array_spec(line, item = None):
+ items = []
+ for spec in split_comma(line, item):
+ items.append(tuple(split_comma(spec, item, comma=':', keep_empty=True)))
+ return items
+
def specs_split_comma(line, item = None, upper=False):
specs0 = split_comma(line, item)
specs = []