aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tools/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2016-03-01 06:23:36 +0100
committerBjörn Gustavsson <[email protected]>2016-03-01 13:59:22 +0100
commit205405f0bf1d2fa37d4c8170c11689a2937f5d9c (patch)
treea55b2a94a43ecf521db5c06a41be2af0a0eda44b /lib/tools/src
parent156aea75186fe9de64b87c2c6919db9abf4a0d60 (diff)
downloadotp-205405f0bf1d2fa37d4c8170c11689a2937f5d9c.tar.gz
otp-205405f0bf1d2fa37d4c8170c11689a2937f5d9c.tar.bz2
otp-205405f0bf1d2fa37d4c8170c11689a2937f5d9c.zip
Generalize bit string comprehensions
The expression in a bit string comprehension is limited to a literal bit string expression. That is, the following code is legal: << <<X>> || X <- List >> but not this code: << foo(X) || X <- List >> The limitation is annoying. For one thing, tools that transform the abstract format must be careful not to produce code such as: << begin %% Some instrumentation code. <<X>> end || X <- List >> One reason for the limitation could be that we'll get reduce/reduce conflicts if we try to allow an arbitrary expression in a bit string comprehension: binary_comprehension -> '<<' expr '||' lc_exprs '>>' : {bc,?anno('$1'),'$2','$4'}. Unfortunately, there does not seem to be an easy way to work around that problem. The best we can do is to allow 'expr_max' expressions (as in the binary syntax): binary_comprehension -> '<<' expr_max '||' lc_exprs '>>' : {bc,?anno('$1'),'$2','$4'}. That will work, but functions calls must be enclosed in parentheses: << (foo(X)) || X <- List >>
Diffstat (limited to 'lib/tools/src')
-rw-r--r--lib/tools/src/cover.erl4
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/tools/src/cover.erl b/lib/tools/src/cover.erl
index 3732b0fc85..87de31919f 100644
--- a/lib/tools/src/cover.erl
+++ b/lib/tools/src/cover.erl
@@ -2002,9 +2002,7 @@ munge_expr({lc,Line,Expr,Qs}, Vars) ->
{MungedQs, Vars3} = munge_qualifiers(Qs, Vars2),
{{lc,Line,MungedExpr,MungedQs}, Vars3};
munge_expr({bc,Line,Expr,Qs}, Vars) ->
- {bin,BLine,[{bin_element,EL,Val,Sz,TSL}|Es]} = Expr,
- Expr2 = {bin,BLine,[{bin_element,EL,Val,Sz,TSL}|Es]},
- {MungedExpr,Vars2} = munge_expr(Expr2, Vars),
+ {MungedExpr,Vars2} = munge_expr(?BLOCK1(Expr), Vars),
{MungedQs, Vars3} = munge_qualifiers(Qs, Vars2),
{{bc,Line,MungedExpr,MungedQs}, Vars3};
munge_expr({block,Line,Body}, Vars) ->