Parser: Parse operator decls.

At the top level, if 'operator' is followed by 'infix', 'prefix', or 'postfix', consider it a contextual keyword, and parse an operator decl following it that looks like:

  operator {infix|postfix|prefix} <+> {
    attributes…
  }

Prefix and postfix operator decls currently admit no attributes. Infix operators have 'associativity {left|right|none}' and 'precedence <int>' attributes.

This patch implements parsing for operator declarations but does not yet attach the declared attributes to func decls for the operators.

Swift SVN r4596
This commit is contained in:
Joe Groff
2013-04-03 23:30:50 +00:00
parent 965242a833
commit aeeda4ee12
17 changed files with 557 additions and 8 deletions

View File

@@ -345,6 +345,9 @@ bool ValueDecl::isDefinition() const {
case DeclKind::TopLevelCode:
case DeclKind::Constructor:
case DeclKind::Destructor:
case DeclKind::InfixOperator:
case DeclKind::PrefixOperator:
case DeclKind::PostfixOperator:
llvm_unreachable("non-value decls shouldn't get here");
case DeclKind::Func:
@@ -371,6 +374,9 @@ bool ValueDecl::isInstanceMember() const {
case DeclKind::Extension:
case DeclKind::PatternBinding:
case DeclKind::TopLevelCode:
case DeclKind::InfixOperator:
case DeclKind::PrefixOperator:
case DeclKind::PostfixOperator:
llvm_unreachable("Not a ValueDecl");
case DeclKind::Class: