{- FM New Extraction: Language definition Copyright (C) 2007 Author: Markus Forberg Some parts of the grammar is a modified version of the BNFC grammar. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -} -- A Grammar is a sequence of definitions Grammar . Grammar ::= [Def] ; terminator Def ";" ; -- Top level definitions Paradigm . Def ::= "paradigm" Ident Env "=" Head "{" Logic "}" ; RParadigm . Def ::= "rule" Ident Env "=" Head "{" Logic "}" ; Regdef . Def ::= "regexp" Ident "=" Reg ; Cxtdef . Def ::= "context" Ident "=" CLogic ; -- Variable bindings (variable-regexp) in paradigm definitions. Env . Env ::= "[" [Binding] "]" ; Empty . Env ::= ; Assoc . Binding ::= Ident ":" Reg ; separator Binding "," ; -- A pattern is either a word, a word associated with a constraint. -- or a constraint atom. -- CWord (Var id) NoCons = constraint identifier. CWord . Pattern ::= [Item] Constraint; StrC . Item ::= String ; Var . Item ::= Ident ; PWild . Patt1 ::= "_" ; PId . Patt1 ::= Ident ; PC . Patt ::= Ident [Patt1] ; coercions Patt 1; separator nonempty Patt1 "" ; Head . Head ::= [Pattern] ; separator nonempty Pattern "" ; separator nonempty Item "+" ; Cons . Constraint ::= "[" CLogic "]" ; ConsId . Constraint ::= "[" Ident "]" ; NoCons . Constraint ::= ; CConj . CLogic ::= CLogic "&" CLogic1 ; CDisj . CLogic ::= CLogic "|" CLogic1 ; CNeg . CLogic1 ::= "~" CLogic1 ; CLWild . CLogic1 ::= "_" ; CAtom . CLogic1 ::= "(" Position "," Reg "," Unique Patt ")" ; coercions CLogic 1; U . Unique ::= "!" ; NU . Unique ::= ; -- Position WPos . Position ::= "_" ; Pos . Position ::= Pos ; VPos . Position ::= Ident "@" Pos ; RVPos . Position ::= Ident "@" Ident Pos ; Rel . Position ::= Ident Pos ; P . Pos ::= Integer ; PP . Pos ::= "+" Integer ; NP . Pos ::= "-" Integer ; PStar . Pos ::= "+" Integer "*" ; NPStar . Pos ::= "-" Integer "*" ; Star . Pos ::= "*" ; -- Logic Conj . Logic ::= Logic "&" Logic1 ; Disj . Logic ::= Logic "|" Logic1 ; Neg . Logic1 ::= "~" Logic1 ; LWild . Logic1 ::= "_" ; Atom . Logic1 ::= Pattern ; coercions Logic 1; -- regular expressions (from the BNFC grammar) RAlt. Reg ::= Reg "|" Reg1 ; RMinus. Reg ::= Reg1 "-" Reg1 ; RSeq. Reg1 ::= Reg1 Reg2 ; RStar. Reg2 ::= Reg2 "*" ; RPlus. Reg2 ::= Reg2 "+" ; ROpt. Reg2 ::= Reg2 "?" ; REps. Reg2 ::= "eps" ; RChar. Reg2 ::= Char ; -- single character RAlts. Reg2 ::= "[" String "]" ; -- list of alternative characters RDigit. Reg2 ::= "digit" ; RLetter. Reg2 ::= "letter" ; RUpper. Reg2 ::= "upper" ; RLower. Reg2 ::= "lower" ; RAny. Reg2 ::= "char" ; Wild . Reg2 ::= "_" ; RStr . Reg2 ::= String ; RegVar . Reg2 ::= Ident ; coercions Reg 2; -- comments in FM extractions comment "--" ; comment "{-" "-}" ;