Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ protected int getEnd(final Source source, final int pos) {
if (!isInQuotes && !isInApos) {
if (x > 2 && text.subSequence(x - 3, x).equals("---")) {
// do nothing, this is a comment
} else if (isArrowOperator(text, x)) {
// do nothing, this '>' is the tail of => or -> inside an expression
} else {
return x + 1;
}
Expand All @@ -95,6 +97,25 @@ protected int getEnd(final Source source, final int pos) {
return endStartTagEnd;
}

/**
* True when the '>' at pos is the second character of an arrow operator, as in
* <code>&lt;cfset f = (x) =&gt; x + 1&gt;</code>. Without this the tag ends inside the operator
* and the expression is silently truncated to <code>f = (x) =</code>.
*
* A '-' is only an arrow when it does not follow another '-', so the decrement in
* <code>&lt;cfset a = i--&gt;</code> still ends the tag.
*/
private static boolean isArrowOperator(final ParseText text, final int pos) {
if (pos < 1) {
return false;
}
final char previous = text.charAt(pos - 1);
if (previous == '=') {
return true;
}
return previous == '-' && (pos < 2 || text.charAt(pos - 2) != '-');
}

protected ArrayList getAttributes(String inData) {
ArrayList attributes = new ArrayList();
Matcher matcher;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<cfoutput>prefix</cfoutput>
<cfset closure = t => t.b()>
<cfset lambda = t -> t.b()>
<cfset parenthesised = (x, y) => x + y>
<cfset nested = getURLs().map( target -> target.toString() )>
<!--- the '>' of a decrement still ends the tag --->
<cfset countdown = i-->
<cfset comparison = total gt 1>
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
START:cfoutput
=========TAG=================
<cfoutput>prefix</cfoutput>
END:cfoutput
START:cfset
=========TAG=================
<cfset closure = t => t.b()>
TAG
==========Tokens==============
IDENTIFIER <closure>
'=' <=>
IDENTIFIER <t>
'=>' <=>>
IDENTIFIER <t>
'.' <.>
IDENTIFIER <b>
'(' <(>
')' <)>
===========Tree================
(expression
(assignmentExpression
(startExpression
(baseExpression (unaryExpression (memberExpression (identifier closure))))
)
=
(startExpression
(baseExpression
(lambdaDeclaration
(identifier t)
=>
(startExpression
(baseExpression
(unaryExpression
(memberExpression
(identifier t)
.
(qualifiedFunctionCall (identifier b) ( argumentList ))
)
)
)
)
)
)
)
)
<EOF>
)
===========Expression===============
closure = (t) => t.b()
==================================
END:cfset
START:cfset
=========TAG=================
<cfset lambda = t -> t.b()>
TAG
==========Tokens==============
IDENTIFIER <lambda>
'=' <=>
IDENTIFIER <t>
'->' <->>
IDENTIFIER <t>
'.' <.>
IDENTIFIER <b>
'(' <(>
')' <)>
===========Tree================
(expression
(assignmentExpression
(startExpression
(baseExpression (unaryExpression (memberExpression (identifier lambda))))
)
=
(startExpression
(baseExpression
(lambdaDeclaration
(identifier t)
->
(startExpression
(baseExpression
(unaryExpression
(memberExpression
(identifier t)
.
(qualifiedFunctionCall (identifier b) ( argumentList ))
)
)
)
)
)
)
)
)
<EOF>
)
===========Expression===============
lambda = (t) -> t.b()
==================================
END:cfset
START:cfset
=========TAG=================
<cfset parenthesised = (x, y) => x + y>
TAG
==========Tokens==============
IDENTIFIER <parenthesised>
'=' <=>
'(' <(>
IDENTIFIER <x>
',' <,>
IDENTIFIER <y>
')' <)>
'=>' <=>>
IDENTIFIER <x>
'+' <+>
IDENTIFIER <y>
===========Tree================
(expression
(assignmentExpression
(startExpression
(baseExpression
(unaryExpression (memberExpression (identifier parenthesised)))
)
)
=
(startExpression
(baseExpression
(lambdaDeclaration
(
(parameterList (parameter (identifier x)) , (parameter (identifier y)))
)
=>
(startExpression
(baseExpression
(baseExpression (unaryExpression (memberExpression (identifier x))))
+
(baseExpression (unaryExpression (memberExpression (identifier y))))
)
)
)
)
)
)
<EOF>
)
===========Expression===============
parenthesised = (x, y) => x + y
==================================
END:cfset
START:cfset
=========TAG=================
<cfset nested = getURLs().map( target -> target.toString() )>
TAG
==========Tokens==============
IDENTIFIER <nested>
'=' <=>
IDENTIFIER <getURLs>
'(' <(>
')' <)>
'.' <.>
IDENTIFIER <map>
'(' <(>
IDENTIFIER <target>
'->' <->>
IDENTIFIER <target>
'.' <.>
IDENTIFIER <toString>
'(' <(>
')' <)>
')' <)>
===========Tree================
(expression
(assignmentExpression
(startExpression
(baseExpression (unaryExpression (memberExpression (identifier nested))))
)
=
(startExpression
(baseExpression
(unaryExpression
(memberExpression
(functionCall (identifier getURLs) ( argumentList ))
.
(qualifiedFunctionCall
(identifier map)
(
(argumentList
(argument
(lambdaDeclaration
(identifier target)
->
(startExpression
(baseExpression
(unaryExpression
(memberExpression
(identifier target)
.
(qualifiedFunctionCall (identifier toString) ( argumentList ))
)
)
)
)
)
)
)
)
)
)
)
)
)
)
<EOF>
)
===========Expression===============
nested = getURLs().map((target) -> target.toString())
==================================
END:cfset
START:!---
=========TAG=================
<!--- the '>' of a decrement still ends the tag --->
END:!---
START:cfset
=========TAG=================
<cfset countdown = i-->
TAG
==========Tokens==============
IDENTIFIER <countdown>
'=' <=>
IDENTIFIER <i>
'--' <-->
===========Tree================
(expression
(assignmentExpression
(startExpression
(baseExpression (unaryExpression (memberExpression (identifier countdown))))
)
=
(startExpression
(baseExpression
(unaryExpression (unaryExpression (memberExpression (identifier i))) --)
)
)
)
<EOF>
)
===========Expression===============
countdown = i--
==================================
END:cfset
START:cfset
=========TAG=================
<cfset comparison = total gt 1>
TAG
==========Tokens==============
IDENTIFIER <comparison>
'=' <=>
IDENTIFIER <total>
GT <gt>
INTEGER_LITERAL <1>
===========Tree================
(expression
(assignmentExpression
(startExpression
(baseExpression (unaryExpression (memberExpression (identifier comparison))))
)
=
(startExpression
(baseExpression
(baseExpression (unaryExpression (memberExpression (identifier total))))
(compareExpressionOperator gt)
(baseExpression (unaryExpression (primaryExpression (literalExpression 1))))
)
)
)
<EOF>
)
===========Expression===============
comparison = total gt 1
==================================
END:cfset
Loading