Advertisement
zenware

FuckGrammar

Jun 20th, 2012
3,076
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
BNF 2.09 KB | None | 0 0
  1. variable   ::=   lower{ lower | upper | digit }
  2.  
  3. lower      ::=   a | b | c | ... | z
  4. upper      ::=   A | B | C | ... | Z
  5. digit      ::=   0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
  6.  
  7. oper       ::=   symoper        ("normal", symbolic operators)
  8.                   |   ` variable `   (variable names in "back-ticks")
  9.  
  10. symoper    ::=   symbol { symbol }
  11.  
  12. symbol     ::=   ! | # | $ | % | & | * | + | . | / | <|=|> | ? | @  | \ | ^ | | | - | ~
  13.  
  14.  
  15. literal    ::=   boollit  |  intlit  |  floatlit  |  charlit  |  stringlit
  16.  
  17. boollit    ::=   True  |  False
  18.  
  19. intlit     ::=   digit { digit }
  20.  
  21. floatlit   ::=   [ + | - ] intlit . intlit [ e | E  [ + | - ] intlit ]
  22.  
  23. charlit    ::=   'nonapost '
  24. nonapost   ::=   (any character except apostrophe)
  25.  
  26. stringlit  ::=   " { nonqchar } "
  27. nonqchar   ::=   (any character except quote mark)
  28.  
  29.  
  30. atomic     ::=   literal        (a constant)
  31.             |   variable    (a variable)
  32.             |   ( expr )        (a parenthesized expression)
  33.             |   ( expr1 , ... , exprk ) (a tuple, for k>=2)
  34.             |   [ expr1 , ... , exprk ]     (a list)
  35.             |   [ expr1 [ , exp2 ] .. [ expr3 ] ] (an arithmetic sequence)
  36.             |   ( atomic oper )     (a left operator section)
  37.             |   ( oper atomic )     (a right operator section)
  38.             |   ( symoper )     (an operator by itself, not infix)
  39.  
  40. expr       ::=   atomic
  41.             |   expr atomic         (function application)
  42.             |   expr oper expr  (infix operator application)
  43.             |   - expr          (negative numbers)
  44.             |   let decls in expr  
  45.             |   expr where decls
  46.             |   if expr then expr else expr
  47.             |   \ { variable } -> expr  (lambda abstractions)
  48.  
  49.  
  50. decls      ::=   pattern = expr { ; decls }
  51.           |   variable { pattern } = expr { ; decls } (functions with parameters)
  52.  
  53.  
  54. pattern    ::=   literal        (a constant)
  55.             |   variable    (a variable)
  56.             |   ( pattern )     (a parenthesized pattern)
  57.             |   ( pattern1 , ... , patternk ) (a tuple pattern, for k>=2)
  58.             |   [ pattern1 , ... , patternk ]   (a list of patterns)
  59.             |   constr pattern          (constructor application)
  60.             |   pattern con-opr pattern (infix constructor application)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement