next up previous contents
Next: 4 Fixity and Name Up: Elf Users Guide Previous: 2 Lexical Conventions

3 Grammar

Here is the syntax for Elf in abbreviated form. Terms form the join of the three levels in the LF calculus, which are not distinguished syntactically. The comment approximates the meaning in LF.

sigentry ::= id : term.
query    ::= term.

term ::= type                % Type
       | term1 -> term2      % A -> B
       | term1 <- term2      % B -> A
       | {id : term1} term2  % \Pi x:A. K  or  \Pi x:A. B
       | [id : term1] term2  % \lambda x:A. B  or  \lambda x:A. M
       | term1 term2         % A M  or  M N
       | term : term         % explicit cast
       | _                   % hole, to be filled by term reconstruction
       | {id} term           % same as {id:_} term
       | [id] term           % same as [id:_] term

In the order of binding strength we disambiguate as follows:

  1. Juxtaposition (application) is left-associative and binds the strongest.
  2. -> is right associative.
  3. <- is left associative.
  4. : is left associative.
  5. {} and [] are weak prefix operators.

For example, the following are parsed identically:

   d : a <- b <- {x} c x -> p x.
   d : ({x} c x -> p x) -> b -> a.
   d : ((a <- b) <- ({x:_} ((c x) -> (p x)))).



fp@cs