The Language GF BNF Converter % File generated by the BNF Converter. This document was automatically generated by the //BNF-Converter//. ==The lexical structure of GF== ===Literals=== Integer literals //Integer// are nonempty sequences of digits. Double-precision float literals //Double// have the structure indicated by the regular expression ``digit+ '.' digit+ ('e' ('-')? digit+)?`` i.e. two sequences of digits separated by a decimal point, optionally followed by an unsigned or negative exponent. Ident literals are recognized by the regular expression `````(lower | upper) (upper | lower | digit | '_' | ''')*````` LString literals are recognized by the regular expression `````(''') (char - ''')* (''')````` ===Reserved words and symbols=== The set of reserved words is the set of terminals appearing in the grammar. Those reserved words that consist of non-letter characters are called symbols, and they are treated in a different way from those that are similar to identifiers. The lexer follows rules familiar from languages like Haskell, C, and Java, including longest match and spacing conventions. The reserved words used in GF are the following: | ``Lin`` | ``PType`` | ``Str`` | ``Strs`` | ``Tok`` | ``Type`` | ``abstract`` | ``case`` | ``cat`` | ``concrete`` | ``data`` | ``def`` | ``flags`` | ``fn`` | ``fun`` | ``grammar`` | ``in`` | ``include`` | ``incomplete`` | ``instance`` | ``interface`` | ``let`` | ``lin`` | ``lincat`` | ``lindef`` | ``lintype`` | ``of`` | ``open`` | ``oper`` | ``out`` | ``package`` | ``param`` | ``pattern`` | ``pre`` | ``printname`` | ``resource`` | ``reuse`` | ``strs`` | ``table`` | ``tokenizer`` | ``transfer`` | ``union`` | ``var`` | ``variants`` | ``where`` | ``with`` | | The symbols used in GF the following: | ! | $ | % | ( | ) | * | ** | + | ++ | , | - | -> | . | / | : | ; | < | = | => | > | ? | @ | [ | \ | ] | _ | { | | | } | | | ===Comments=== Single-line comments begin with --. Multiple-line comments are enclosed with {- and -}. ==The syntactic structure of GF == Non-terminals are enclosed between < and >. The symbols **->** (production), **|** (union) and **eps** (empty rule) belong to the BNF notation. All other symbols are terminals. | //Altern// | -> | //Exp// ``/`` //Exp// | //Bind// | -> | //Ident// | | **|** | ``_`` | //Case// | -> | //[PattAlt]// ``=>`` //Exp// | //CatDef// | -> | ``[`` //Ident// //[DDecl]// ``]`` | | **|** | ``[`` //Ident// //[DDecl]// ``]`` ``{`` //Integer// ``}`` | | **|** | //Ident// //[DDecl]// | //ComplMod// | -> | **eps** | | **|** | ``incomplete`` | //ConcExp// | -> | //Ident// //[Transfer]// | //ConcSpec// | -> | //Ident// ``=`` //ConcExp// | //DDecl// | -> | ``(`` //[Bind]// ``:`` //Exp// ``)`` | | **|** | //Exp4// | //DataConstr// | -> | //Ident// | | **|** | //Ident// ``.`` //Ident// | //DataDef// | -> | //Ident// ``=`` //[DataConstr]// | //Decl// | -> | ``(`` //[Bind]// ``:`` //Exp// ``)`` | | **|** | //Exp2// | //Def// | -> | //[Name]// ``:`` //Exp// | | **|** | //[Name]// ``=`` //Exp// | | **|** | //[Name]// ``:`` //Exp// ``=`` //Exp// | | **|** | //Name// //[Patt]// ``=`` //Exp// | //Equation// | -> | //[Patt]// ``->`` //Exp// | //Exp// | -> | ``\`` //[Bind]// ``->`` //Exp// | | **|** | ``\`` ``\`` //[Bind]// ``=>`` //Exp// | | **|** | //Exp1// ``++`` //Exp// | | **|** | ``fn`` ``{`` //[Equation]// ``}`` | | **|** | //Exp1// ``+`` //Exp// | | **|** | ``let`` ``{`` //[LocDef]// ``}`` ``in`` //Exp// | | **|** | ``let`` //[LocDef]// ``in`` //Exp// | | **|** | //Decl// ``->`` //Exp// | | **|** | //Exp1// ``=>`` //Exp// | | **|** | //Exp1// ``where`` ``{`` //[LocDef]// ``}`` | | **|** | //Exp1// | //Exps// | -> | //Exp4// //Exps// | | **|** | **eps** | //Extend// | -> | //[Included]// ``**`` | | **|** | **eps** | //FileName// | -> | //Ident// //FileName// | | **|** | ``.`` //FileName// | | **|** | //Ident// | | **|** | ``-`` //FileName// | | **|** | ``/`` //FileName// | | **|** | //String// | //FlagDef// | -> | //Ident// ``=`` //Ident// | //FunDef// | -> | //[Ident]// ``:`` //Exp// | //Grammar// | -> | //[ModDef]// | //IncludeDecl// | -> | ``include`` //[FileName]// | | **|** | **eps** | //Included// | -> | //Ident// | | **|** | //Ident// ``-`` ``[`` //[Ident]// ``]`` | | **|** | //Ident// ``[`` //[Ident]// ``]`` | //Label// | -> | //Ident// | | **|** | ``$`` //Integer// | //LocDef// | -> | //[Ident]// ``:`` //Exp// | | **|** | //[Ident]// ``=`` //Exp// | | **|** | //[Ident]// ``:`` //Exp// ``=`` //Exp// | //ModBody// | -> | //Extend// //Opens// ``{`` //[TopDef]// ``}`` | | **|** | ``reuse`` //Ident// | | **|** | ``union`` //[Included]// | | **|** | //Ident// ``with`` //[OpenDecl]// | | **|** | //[Included]// ``**`` //Ident// ``with`` //[OpenDecl]// | //ModDef// | -> | ``grammar`` //Ident// ``=`` ``{`` ``abstract`` ``=`` //Ident// ``;`` //[ConcSpec]// ``}`` | | **|** | //ComplMod// //ModType// ``=`` //ModBody// | | **|** | //ModDef// ``;`` | //ModType// | -> | ``abstract`` //Ident// | | **|** | ``concrete`` //Ident// ``of`` //Ident// | | **|** | ``instance`` //Ident// ``of`` //Ident// | | **|** | ``interface`` //Ident// | | **|** | ``resource`` //Ident// | | **|** | ``transfer`` //Ident// ``:`` //OpenDecl// ``->`` //OpenDecl// | //Name// | -> | //Ident// | | **|** | ``[`` //Ident// ``]`` | //OldGrammar// | -> | //IncludeDecl// //[TopDef]// | //OpenDecl// | -> | //Ident// | | **|** | ``(`` //QualOpen// //Ident// ``=`` //Ident// ``)`` | | **|** | ``(`` //QualOpen// //Ident// ``)`` | //Opens// | -> | **eps** | | **|** | ``open`` //[OpenDecl]// ``in`` | //ParConstr// | -> | //Ident// //[DDecl]// | //ParDef// | -> | //Ident// | | **|** | //Ident// ``=`` //[ParConstr]// | | **|** | //Ident// ``=`` ``(`` ``in`` //Ident// ``)`` | //Patt// | -> | //Ident// //[Patt]// | | **|** | //Ident// ``.`` //Ident// //[Patt]// | | **|** | //Patt1// | //PattAlt// | -> | //Patt// | //PattAss// | -> | //[Ident]// ``=`` //Patt// | //PattTupleComp// | -> | //Patt// | //PrintDef// | -> | //[Name]// ``=`` //Exp// | //QualOpen// | -> | **eps** | | **|** | ``incomplete`` | | **|** | ``interface`` | //Sort// | -> | ``PType`` | | **|** | ``Str`` | | **|** | ``Strs`` | | **|** | ``Tok`` | | **|** | ``Type`` | //TopDef// | -> | ``cat`` //[CatDef]// | | **|** | ``data`` //[DataDef]// | | **|** | ``def`` //[Def]// | | **|** | ``flags`` //[FlagDef]// | | **|** | ``fun`` //[FunDef]// | | **|** | ``data`` //[FunDef]// | | **|** | ``lin`` //[Def]// | | **|** | ``lincat`` //[PrintDef]// | | **|** | ``lindef`` //[Def]// | | **|** | ``lintype`` //[Def]// | | **|** | ``oper`` //[Def]// | | **|** | ``package`` //Ident// ``=`` ``{`` //[TopDef]// ``}`` ``;`` | | **|** | ``param`` //[ParDef]// | | **|** | ``pattern`` //[Def]// | | **|** | ``printname`` ``cat`` //[PrintDef]// | | **|** | ``printname`` ``fun`` //[PrintDef]// | | **|** | ``printname`` //[PrintDef]// | | **|** | ``tokenizer`` //Ident// ``;`` | | **|** | ``transfer`` //[Def]// | | **|** | ``var`` //[Def]// | //Transfer// | -> | ``(`` ``transfer`` ``in`` //OpenDecl// ``)`` | | **|** | ``(`` ``transfer`` ``out`` //OpenDecl// ``)`` | //TupleComp// | -> | //Exp// | //[Ident]// | -> | //Ident// | | **|** | //Ident// ``,`` //[Ident]// | //[Altern]// | -> | **eps** | | **|** | //Altern// | | **|** | //Altern// ``;`` //[Altern]// | //[Bind]// | -> | **eps** | | **|** | //Bind// | | **|** | //Bind// ``,`` //[Bind]// | //[Case]// | -> | //Case// | | **|** | //Case// ``;`` //[Case]// | //[CatDef]// | -> | //CatDef// ``;`` | | **|** | //CatDef// ``;`` //[CatDef]// | //[ConcSpec]// | -> | **eps** | | **|** | //ConcSpec// | | **|** | //ConcSpec// ``;`` //[ConcSpec]// | //[DDecl]// | -> | **eps** | | **|** | //DDecl// //[DDecl]// | //[DataConstr]// | -> | **eps** | | **|** | //DataConstr// | | **|** | //DataConstr// ``|`` //[DataConstr]// | //[DataDef]// | -> | //DataDef// ``;`` | | **|** | //DataDef// ``;`` //[DataDef]// | //[Def]// | -> | //Def// ``;`` | | **|** | //Def// ``;`` //[Def]// | //[Equation]// | -> | **eps** | | **|** | //Equation// | | **|** | //Equation// ``;`` //[Equation]// | //[Exp]// | -> | **eps** | | **|** | //Exp// | | **|** | //Exp// ``;`` //[Exp]// | //[FileName]// | -> | //FileName// ``;`` | | **|** | //FileName// ``;`` //[FileName]// | //[FlagDef]// | -> | //FlagDef// ``;`` | | **|** | //FlagDef// ``;`` //[FlagDef]// | //[FunDef]// | -> | //FunDef// ``;`` | | **|** | //FunDef// ``;`` //[FunDef]// | //[Included]// | -> | **eps** | | **|** | //Included// | | **|** | //Included// ``,`` //[Included]// | //[LocDef]// | -> | **eps** | | **|** | //LocDef// | | **|** | //LocDef// ``;`` //[LocDef]// | //[ModDef]// | -> | **eps** | | **|** | //ModDef// //[ModDef]// | //[Name]// | -> | //Name// | | **|** | //Name// ``,`` //[Name]// | //[OpenDecl]// | -> | **eps** | | **|** | //OpenDecl// | | **|** | //OpenDecl// ``,`` //[OpenDecl]// | //[ParConstr]// | -> | **eps** | | **|** | //ParConstr// | | **|** | //ParConstr// ``|`` //[ParConstr]// | //[ParDef]// | -> | //ParDef// ``;`` | | **|** | //ParDef// ``;`` //[ParDef]// | //[Patt]// | -> | //Patt1// | | **|** | //Patt1// //[Patt]// | //[PattAlt]// | -> | //PattAlt// | | **|** | //PattAlt// ``|`` //[PattAlt]// | //[PattAss]// | -> | **eps** | | **|** | //PattAss// | | **|** | //PattAss// ``;`` //[PattAss]// | //[PattTupleComp]// | -> | **eps** | | **|** | //PattTupleComp// | | **|** | //PattTupleComp// ``,`` //[PattTupleComp]// | //[PrintDef]// | -> | //PrintDef// ``;`` | | **|** | //PrintDef// ``;`` //[PrintDef]// | //[TopDef]// | -> | **eps** | | **|** | //TopDef// //[TopDef]// | //[Transfer]// | -> | **eps** | | **|** | //Transfer// //[Transfer]// | //[TupleComp]// | -> | **eps** | | **|** | //TupleComp// | | **|** | //TupleComp// ``,`` //[TupleComp]// | //Exp1// | -> | //Exp1// ``**`` //Exp2// | | **|** | //Exp1// ``!`` //Exp2// | | **|** | //Exp1// ``*`` //Exp2// | | **|** | //Exp2// | //Exp2// | -> | //Exp2// //Exp3// | | **|** | ``case`` //Exp// ``of`` ``{`` //[Case]// ``}`` | | **|** | //Ident// ``@`` //Exp4// | | **|** | ``Lin`` //Ident// | | **|** | ``pre`` ``{`` //Exp// ``;`` //[Altern]// ``}`` | | **|** | ``strs`` ``{`` //[Exp]// ``}`` | | **|** | ``table`` //Exp4// ``{`` //[Case]// ``}`` | | **|** | ``table`` ``{`` //[Case]// ``}`` | | **|** | ``table`` //Exp4// ``[`` //[Exp]// ``]`` | | **|** | ``variants`` ``{`` //[Exp]// ``}`` | | **|** | //Exp3// | //Exp3// | -> | //Exp3// ``.`` //Label// | | **|** | ``%`` //Ident// ``.`` //Ident// | | **|** | ``{`` //Ident// ``.`` //Ident// ``}`` | | **|** | //Exp4// | //Exp4// | -> | ``%`` //Ident// ``%`` | | **|** | ``{`` //Ident// ``}`` | | **|** | ``data`` | | **|** | ``[`` ``]`` | | **|** | //Ident// | | **|** | ``(`` ``in`` //Ident// ``)`` | | **|** | //Integer// | | **|** | //LString// | | **|** | ``[`` //Ident// //Exps// ``]`` | | **|** | ``?`` | | **|** | ``{`` //[LocDef]// ``}`` | | **|** | //Sort// | | **|** | //String// | | **|** | ``[`` //String// ``]`` | | **|** | ``<`` //[TupleComp]// ``>`` | | **|** | ``<`` //Exp// ``:`` //Exp// ``>`` | | **|** | ``(`` //Exp// ``)`` | //Patt1// | -> | ``{`` //Ident// ``}`` | | **|** | //Integer// | | **|** | //Ident// ``.`` //Ident// | | **|** | ``{`` //[PattAss]// ``}`` | | **|** | //String// | | **|** | ``<`` //[PattTupleComp]// ``>`` | | **|** | //Ident// | | **|** | ``_`` | | **|** | ``(`` //Patt// ``)``