commit 83c53863507492a17cf4080a743b1950959bb46d from: Sergey Bronnikov date: Tue Dec 22 09:56:13 2020 UTC Add mdoc grammar (incomplete) source: https://man.openbsd.org/mdoc.7 commit - d0eea8c498cfc710b95ac123f0a010da2e511503 commit + 83c53863507492a17cf4080a743b1950959bb46d blob - e271fbb825a8b7e3d34f6fc2cf6e6c7039703ad1 blob + 058f177ca337d42ca5a27ff0374f9d56ca096af7 --- README.md +++ README.md @@ -7,6 +7,7 @@ Grammars suitable for [lark](https://github.com/lark-p - [bc](https://man.openbsd.org/bc), an arbitrary precision calculator language (```bc.lark```) - [The GEDCOM Standard](http://user.it.uu.se/~andersa/gedcom/) (```gedcom.lark```) - [eqn](https://man.openbsd.org/eqn), language reference for mandoc (```eqn.lark```) +- [mdoc](https://man.openbsd.org/mdoc.7), semantic markup language for formatting manual pages (```mdoc.lark```) - MIME [Media Types](https://www.iana.org/assignments/media-types/media-types.xhtml) (```mime.lark```) - Lua 5.1 language grammar specification (```lua.lark```) - [TAP13](https://testanything.org/tap-version-13-specification.html) - The Test Anything Protocol v13 (```tap13.lark```) blob - /dev/null blob + bbe637f0c913116c19b14e614f741f4553193106 (mode 644) --- /dev/null +++ lark_grammars/grammars/mdoc.lark @@ -0,0 +1,28 @@ +start : mdoc + +mdoc : comment+ prologue comment+ name_section comment+ + +prologue : ".Dd $Mdocdate$" NEWLINE ".Dt" PROGNAME SECTION NEWLINE ".Os" NEWLINE + +name_section : ".Sh" PROGNAME NEWLINE ".Nm" PROGNAME NEWLINE ".Nd" TEXTLINE NEWLINE + +comment : ".\"" TEXTLINE NEWLINE + +DIGIT : "0".."9" +LCASE_LETTER : "a".."z" +UCASE_LETTER : "A".."Z" +ALPHA : UCASE_LETTER | LCASE_LETTER +ALPHANUM : ALPHA [ ALPHA | DIGIT ]* +SPACE : " " +TAB : SPACE+ + +NAME : ALPHANUM+ +WORD : ALPHANUM+ +NUMBER : DIGIT+ +WS : SPACE | TAB +STRING : WORD [ WS WORD+ ] + +NEWLINE : "\n" +PROGNAME : NAME +SECTION : NAME +TEXTLINE : WORD | WORD WS blob - 3459ddaa16087c6174885770a03ebf4475e8076c blob + 5278687883a81236eada5f31c335547d046038ff --- lark_grammars/grammars.py +++ lark_grammars/grammars.py @@ -23,6 +23,8 @@ grammar_files = {'bc': _build_path('bc.lark'), 'gedcom': _build_path('gedcom.lark'), 'eqn': _build_path('eqn.lark'), 'lua': _build_path('lua.lark'), + 'mdoc': _build_path('mdoc.lark'), + 'mime': _build_path('mime.lark'), 'palindrome': _build_path('palindrome.lark'), 'phone_number': _build_path('phone_number.lark'), 'pf': _build_path('pf.lark'),