Closed xsawyerx closed 4 years ago
parses('open $fh, "<", "foo";'); # unambiguous: keyword parses('open($fh, "<", "foo");'); # ambiguous: keyword or subcall
Complete parse tree:
(Program (StatementSeq (Statement (NonBraceExprValueR (OpListKeywordExpr (OpKeywordOpenExpr 'open' (OpListKeywordArg (ExprValueR (Value (NonLiteral (ParenExpr (ExprComma (ExprValueL (Value (NonLiteral (Variable (VarScalar '$' (VarName (Ident 'fh')) (ElemSeq0)))))) ',' (ExprComma (ExprValueL (Value (Literal (NonBraceLiteral (InterpolString '"' '<' '"'))))) ',' (ExprValueR (Value (Literal (NonBraceLiteral (InterpolString '"' 'foo' '"')))))))) (ElemSeq0))))))))) ';')) (Program (StatementSeq (Statement (NonBraceExprValueR (NonBraceValue (NonLiteral (SubCall (NonQLikeIdent (NonQLikeFunctionName 'open')) (CallArgs (ParenExpr (ExprComma (ExprValueL (Value (NonLiteral (Variable (VarScalar '$' (VarName (Ident 'fh')) (ElemSeq0)))))) ',' (ExprComma (ExprValueL (Value (Literal (NonBraceLiteral (InterpolString '"' '<' '"'))))) ',' (ExprValueR (Value (Literal (NonBraceLiteral (InterpolString '"' 'foo' '"')))))))))))))) ';'))
This was resolved by reworking subroutine names as lexemes and using prioritizing keywords over them.
Complete parse tree: