Advertisement
Kendev

F1: BNF Syntax

Oct 13th, 2012
1,615
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Query     ::= [ all | one | min | max ]
  2.               [ Var { , Var } ] [ in [ Ident | String ] ] Formula [ end ]
  3.          
  4. Prog      ::= { Typedecl | Constdecl } { Pred }
  5.          
  6. Formula   ::= Formula2 { "|" Formula2 }
  7. Formula2  ::= Formula3 { & Formula3 }
  8. Formula3  ::= If | Case | All | false | true | ~Formula3 |
  9.               Call | Term Oper Term  | ( Formula ) | Vdecl
  10.          
  11. Oper      ::= < | > | <= | >= | <> | = | := | in
  12.          
  13. Call      ::= Ident ( Term )
  14.          
  15. If        ::= if Formula then Formula
  16.               {elsif Formula then Formula} }
  17.               [ else Formula ]
  18.               end
  19.          
  20. Case      ::= case Term  of
  21.               Term { "|" Term } => Formula
  22.               { ; Term { "|" Term } => Formula } [ ; ]
  23.               [ else Formula ]
  24.               end
  25.  
  26. All       ::= all Var { , Var } in Var Formula end |
  27.               [ one | min | max ] Var { , Var } Formula end
  28.  
  29. Term      ::= Term1 [ ,Term ]
  30. Terml     ::= [ - ] Term2 {Addop Term2 }
  31. Addop     ::= + | -
  32. Term2     ::= Term3 { Multop Term3 }
  33. Multop    ::= * | / | mod
  34. Term3     ::= _ | Ident | Call | Number | String | Charconst |
  35.               Selection | ( Term ) | Array | Term3 : Type
  36. Selection ::= [ Var | Ident ] { . Var | ( Term ) }
  37. Array     ::= "[" [Term ] "]"
  38. Number    ::= DecimalDigit { DecimalDigit } | Radix RadixDigit {RadixDigit}
  39. Radix     ::= 0x | 0b | 0o | 0d
  40. String    ::= 'Char { Char }'
  41. Charconst ::= " Char "
  42.  
  43. Type      ::= Ptype [ Arrows Type ]
  44. Arrows    ::= -> | ->>
  45. Ptype     ::= ( Tuple ) | [ Ident ] "[" [ Term ]..[Term] "]" |
  46.               list Ptype | rel Ptype | file Ptype | Ident
  47. Tuple     ::= Named | Unnamed
  48. Named     ::= Var : Type { , Unnamed }
  49. Unnamed   ::= Type { , Unnamed }
  50.  
  51. Vdecl     ::= Var Mode Type
  52. Mode      ::= :< | :> | :. | ::
  53.  
  54. Typedecl  ::= [ local ] Ident = Td
  55. Td        ::= Tuple | Union
  56. Constdecl ::= [ local ] Ident :< Type = Term
  57. Union     ::= Unionelem "|" Unionelem { "|" Unionelem }
  58. Unionelem   = Ident | Ident ( Tuple )
  59.  
  60. Pred      ::= [ local ] Kind Ident ( Vdecl { , Vdecl } ) iff Body
  61. Kind      ::= pred | proc | subr
  62. Body      ::= Formula | Forwarded
  63. Forwarded ::= external [_cdecl | _stdcall] String : String
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement