/**
"If an operator has whitespace on the right side only, it is treated as a
postfix unary operator. As an example, the ++ operator in a++ b is treated
as a postfix unary operator."
"If an operator has no whitespace on the left but is followed immediately
by a dot (.), it is treated as a postfix unary operator. As an example,
the ++ operator in a++.b is treated as a postfix unary operator (a++ .b
rather than a ++ .b)."
*/
public static boolean isPostfixOp(TokenStream tokens) {
int stop = getLastOpTokenIndex(tokens);
if ( stop==-1 ) return false;
int start = tokens.index();
Token prevToken = tokens.get(start-1); // includes hidden-channel tokens
Token nextToken = tokens.get(stop+1);
boolean prevIsWS = isLeftOperatorWS(prevToken);
boolean nextIsWS = isRightOperatorWS(nextToken);
boolean result =
!prevIsWS && nextIsWS ||
!prevIsWS && nextToken.getType()==SwiftParser.DOT;
String text = tokens.getText(Interval.of(start, stop));
//System.out.println("isPostfixOp: '"+prevToken+"','"+text+"','"+nextToken+"' is "+result);
return result;
}
SwiftSupport.java 文件源码
java
阅读 18
收藏 0
点赞 0
评论 0
项目:ts-swift-transpiler
作者:
评论列表
文章目录