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

@@ -731,6 +731,9 @@ void IRGenModule::emitClassDecl(ClassDecl *D) {
case DeclKind::Protocol:
case DeclKind::OneOfElement:
case DeclKind::Extension:
case DeclKind::InfixOperator:
case DeclKind::PrefixOperator:
case DeclKind::PostfixOperator:
llvm_unreachable("decl not allowed in class!");
// We can have meaningful initializers for variables, but