How to use the darglint.parse.grammar.Production function in darglint

To help you get started, we’ve selected a few darglint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github terrencepreilly / darglint / tests / test_cyk.py View on Github external
([], "number", "number-group", 40),
            (PN.NUMBER, 40),
            ([], "number-group", "french-number0", 40),
            ([ConfusionError], "number-group", "confusion-number1", 20),
            ([ConfusionError], "number-group", "confusion-number3", 20),
            ([], "number", "number-group", 20),
            (PN.NUMBER, 20)),
        P("american-number",
            ([], "number-group", "american-number0", 0),
            ([], "number", "number-group", 0),
            (PN.NUMBER, 0)),
        P("french-number",
            ([], "number-group", "french-number0", 0),
            ([], "number", "number-group", 0),
            (PN.NUMBER, 0)),
        P("confusion-number",
            ([ConfusionError], "number-group", "confusion-number1", 0),
            ([ConfusionError], "number-group", "confusion-number3", 0),
            ([], "number", "number-group", 0),
            (PN.NUMBER, 0)),
        P("number-group", ([], "number", "number-group", 0), (PN.NUMBER, 0)),
        P("number", (PN.NUMBER, 0)),
        P("dash", (PN.DASH, 0)),
        P("dot", (PN.DOT, 0)),
        P("american-number0", ([], "dash", "american-number", 0)),
        P("french-number0", ([], "dot", "french-number", 0)),
        P("confusion-number1", ([], "dot", "confusion-number", 0)),
        P("confusion-number3", ([], "dash", "confusion-number", 0)),
    ]
    start = "phone-number"
github terrencepreilly / darglint / tests / test_grammar.py View on Github external
def test_can_create_production(self):
        P('sentence', ('verb', 'noun'))
github terrencepreilly / darglint / tests / test_generated_grammar.py View on Github external
(GTT.intransitive_verb, 0),
            ([OutOfOrder], "noun_phrase", "intransitive_verb", 0)),
        P("trans_verb_phrase",
            ([], "transitive_verb", "noun_phrase", 0),
            (GTT.transitive_verb, 0)),
        P("noun_phrase",
            ([], "noun", "adjective", 0),
            ([], "noun", "noun", 0),
            ([], "noun", "noun_phrase0", 0),
            ([], "noun", "noun_phrase1", 0),
            (GTT.noun, 0)),
        P("intransitive_verb", (GTT.intransitive_verb, 0)),
        P("transitive_verb", (GTT.transitive_verb, 0)),
        P("noun", (GTT.noun, 0)),
        P("adjective", (GTT.adjective, 0)),
        P("noun_phrase0", ([], "adjective", "noun", 0)),
        P("noun_phrase1", ([], "noun", "adjective", 0)),
    ]
    start = "sentence"



def _lex(sentence):
    lookup = {
        "Hegh": GTT.intransitive_verb,
        "quS": GTT.intransitive_verb,
        "HoH": GTT.transitive_verb,
        "qIp": GTT.transitive_verb,
        "Duj": GTT.noun,
        "loD": GTT.noun,
        "puq": GTT.noun,
        "bIQ": GTT.noun,
github terrencepreilly / darglint / darglint / parse / grammars / google.py View on Github external
P("exception", TokenType.WORD),
        P("block-indented", ([], "paragraph-indented", "block-indented0"), ([], "indented", "paragraph-indented0"), ([], "indented", "line")),
        P("block", ([], "paragraph", "block0"), ([], "line", "paragraph0"), ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),
        P("paragraph-indented-two", ([], "indented-two", "paragraph-indented-two0"), ([], "indented-two", "line")),
        P("paragraph-indented", ([], "indented", "paragraph-indented0"), ([], "indented", "line")),
        P("paragraph", ([], "line", "paragraph0"), ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),
        P("line", ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),
        P("indented-two", ([], "indent", "indented-two0")),
        P("indented", ([], "indent", "indents"), TokenType.INDENT),
        P("indents", ([], "indent", "indents"), TokenType.INDENT),
        P("split", ([], "newline", "split0")),
        P("newlines", ([], "newline", "newlines"), TokenType.NEWLINE),
        P("word", TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS),
        P("arguments", TokenType.ARGUMENTS),
        P("raises", TokenType.RAISES),
        P("returns", TokenType.RETURNS),
        P("yields", TokenType.YIELDS),
        P("colon", TokenType.COLON),
        P("indent", TokenType.INDENT),
        P("newline", TokenType.NEWLINE),
        P("sections0", ([], "long-description", "sections"), ([], "paragraph", "block0"), ([], "line", "paragraph0"), ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),
        P("sections1", ([], "returns-section", "sections"), ([], "returns", "returns-section0")),
        P("sections2", ([], "yields-section", "sections"), ([], "yields", "yields-section0")),
        P("sections3", ([], "raises-section", "sections"), ([], "raises", "raises-section0")),
        P("sections4", ([], "arguments-section", "sections"), ([], "arguments", "arguments-section0")),
        P("returns-section0", ([], "colon", "returns-section1")),
        P("returns-section1", ([], "newline", "block-indented")),
        P("yields-section0", ([], "colon", "yields-section1")),
        P("yields-section1", ([], "newline", "block-indented")),
        P("arguments-section0", ([], "colon", "arguments-section1")),
        P("arguments-section1", ([], "newline", "items-argument"), TokenType.NEWLINE),
        P("items-argument0", ([], "newline", "items-argument"), TokenType.NEWLINE),
github terrencepreilly / darglint / darglint / parse / grammars / google.py View on Github external
P("item-argument1", ([], "newline", "paragraph-indented-two")),
        P("head-argument0", ([], "argument", "colon")),
        P("raises-section0", ([], "colon", "raises-section1")),
        P("raises-section1", ([], "newline", "items-exception"), TokenType.NEWLINE),
        P("items-exception0", ([], "newline", "items-exception"), TokenType.NEWLINE),
        P("item-exception0", ([], "line", "item-exception1")),
        P("item-exception1", ([], "newline", "paragraph-indented-two")),
        P("head-exception0", ([], "exception", "colon")),
        P("block-indented0", ([], "split", "block-indented")),
        P("block0", ([], "split", "block")),
        P("paragraph-indented-two0", ([], "line", "paragraph-indented-two1")),
        P("paragraph-indented-two1", ([], "newline", "paragraph-indented-two")),
        P("paragraph-indented0", ([], "line", "paragraph-indented1")),
        P("paragraph-indented1", ([], "newline", "paragraph-indented")),
        P("paragraph0", ([], "newline", "paragraph")),
        P("indented-two0", ([], "indent", "indents"), TokenType.INDENT),
        P("split0", ([], "newline", "newlines"), TokenType.NEWLINE),
    ]

    start = "start"
github terrencepreilly / darglint / darglint / parse / grammars / google.py View on Github external
from darglint.parse.grammar import BaseGrammar
from darglint.parse.grammar import Production as P
from darglint.token import TokenType

# Generated on 2019-05-27 11:33:01.949675
class Grammar(BaseGrammar):
    productions = [
        P("start", ([], "short-description", "sections"), ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),
        P("sections", ([], "split", "sections0"), ([], "split", "sections1"), ([], "split", "sections2"), ([], "split", "sections3"), ([], "split", "sections4"), ([], "newline", "newlines"), TokenType.NEWLINE),
        P("short-description", ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),
        P("long-description", ([], "paragraph", "block0"), ([], "line", "paragraph0"), ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),
        P("returns-section", ([], "returns", "returns-section0")),
        P("yields-section", ([], "yields", "yields-section0")),
        P("arguments-section", ([], "arguments", "arguments-section0")),
        P("items-argument", ([], "item-argument", "items-argument0")),
        P("item-argument", ([], "head-argument", "item-argument0"), ([], "head-argument", "line")),
        P("head-argument", ([], "indent", "head-argument0")),
        P("argument", TokenType.WORD),
        P("raises-section", ([], "raises", "raises-section0")),
        P("items-exception", ([], "item-exception", "items-exception0")),
        P("item-exception", ([], "head-exception", "item-exception0"), ([], "head-exception", "line")),
        P("head-exception", ([], "indent", "head-exception0")),
        P("exception", TokenType.WORD),
        P("block-indented", ([], "paragraph-indented", "block-indented0"), ([], "indented", "paragraph-indented0"), ([], "indented", "line")),
        P("block", ([], "paragraph", "block0"), ([], "line", "paragraph0"), ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),
        P("paragraph-indented-two", ([], "indented-two", "paragraph-indented-two0"), ([], "indented-two", "line")),
        P("paragraph-indented", ([], "indented", "paragraph-indented0"), ([], "indented", "line")),
        P("paragraph", ([], "line", "paragraph0"), ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),
        P("line", ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),
        P("indented-two", ([], "indent", "indented-two0")),
        P("indented", ([], "indent", "indents"), TokenType.INDENT),
github terrencepreilly / darglint / darglint / parse / grammars / google.py View on Github external
P("returns", TokenType.RETURNS),
        P("yields", TokenType.YIELDS),
        P("colon", TokenType.COLON),
        P("indent", TokenType.INDENT),
        P("newline", TokenType.NEWLINE),
        P("sections0", ([], "long-description", "sections"), ([], "paragraph", "block0"), ([], "line", "paragraph0"), ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),
        P("sections1", ([], "returns-section", "sections"), ([], "returns", "returns-section0")),
        P("sections2", ([], "yields-section", "sections"), ([], "yields", "yields-section0")),
        P("sections3", ([], "raises-section", "sections"), ([], "raises", "raises-section0")),
        P("sections4", ([], "arguments-section", "sections"), ([], "arguments", "arguments-section0")),
        P("returns-section0", ([], "colon", "returns-section1")),
        P("returns-section1", ([], "newline", "block-indented")),
        P("yields-section0", ([], "colon", "yields-section1")),
        P("yields-section1", ([], "newline", "block-indented")),
        P("arguments-section0", ([], "colon", "arguments-section1")),
        P("arguments-section1", ([], "newline", "items-argument"), TokenType.NEWLINE),
        P("items-argument0", ([], "newline", "items-argument"), TokenType.NEWLINE),
        P("item-argument0", ([], "line", "item-argument1")),
        P("item-argument1", ([], "newline", "paragraph-indented-two")),
        P("head-argument0", ([], "argument", "colon")),
        P("raises-section0", ([], "colon", "raises-section1")),
        P("raises-section1", ([], "newline", "items-exception"), TokenType.NEWLINE),
        P("items-exception0", ([], "newline", "items-exception"), TokenType.NEWLINE),
        P("item-exception0", ([], "line", "item-exception1")),
        P("item-exception1", ([], "newline", "paragraph-indented-two")),
        P("head-exception0", ([], "exception", "colon")),
        P("block-indented0", ([], "split", "block-indented")),
        P("block0", ([], "split", "block")),
        P("paragraph-indented-two0", ([], "line", "paragraph-indented-two1")),
        P("paragraph-indented-two1", ([], "newline", "paragraph-indented-two")),
        P("paragraph-indented0", ([], "line", "paragraph-indented1")),
        P("paragraph-indented1", ([], "newline", "paragraph-indented")),
github terrencepreilly / darglint / darglint / parse / grammars / google.py View on Github external
P("indent", TokenType.INDENT),
        P("newline", TokenType.NEWLINE),
        P("sections0", ([], "long-description", "sections"), ([], "paragraph", "block0"), ([], "line", "paragraph0"), ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),
        P("sections1", ([], "returns-section", "sections"), ([], "returns", "returns-section0")),
        P("sections2", ([], "yields-section", "sections"), ([], "yields", "yields-section0")),
        P("sections3", ([], "raises-section", "sections"), ([], "raises", "raises-section0")),
        P("sections4", ([], "arguments-section", "sections"), ([], "arguments", "arguments-section0")),
        P("returns-section0", ([], "colon", "returns-section1")),
        P("returns-section1", ([], "newline", "block-indented")),
        P("yields-section0", ([], "colon", "yields-section1")),
        P("yields-section1", ([], "newline", "block-indented")),
        P("arguments-section0", ([], "colon", "arguments-section1")),
        P("arguments-section1", ([], "newline", "items-argument"), TokenType.NEWLINE),
        P("items-argument0", ([], "newline", "items-argument"), TokenType.NEWLINE),
        P("item-argument0", ([], "line", "item-argument1")),
        P("item-argument1", ([], "newline", "paragraph-indented-two")),
        P("head-argument0", ([], "argument", "colon")),
        P("raises-section0", ([], "colon", "raises-section1")),
        P("raises-section1", ([], "newline", "items-exception"), TokenType.NEWLINE),
        P("items-exception0", ([], "newline", "items-exception"), TokenType.NEWLINE),
        P("item-exception0", ([], "line", "item-exception1")),
        P("item-exception1", ([], "newline", "paragraph-indented-two")),
        P("head-exception0", ([], "exception", "colon")),
        P("block-indented0", ([], "split", "block-indented")),
        P("block0", ([], "split", "block")),
        P("paragraph-indented-two0", ([], "line", "paragraph-indented-two1")),
        P("paragraph-indented-two1", ([], "newline", "paragraph-indented-two")),
        P("paragraph-indented0", ([], "line", "paragraph-indented1")),
        P("paragraph-indented1", ([], "newline", "paragraph-indented")),
        P("paragraph0", ([], "newline", "paragraph")),
        P("indented-two0", ([], "indent", "indents"), TokenType.INDENT),
        P("split0", ([], "newline", "newlines"), TokenType.NEWLINE),
github terrencepreilly / darglint / darglint / parse / grammars / google.py View on Github external
from darglint.parse.grammar import BaseGrammar
from darglint.parse.grammar import Production as P
from darglint.token import TokenType

# Generated on 2019-05-27 11:33:01.949675
class Grammar(BaseGrammar):
    productions = [
        P("start", ([], "short-description", "sections"), ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),
        P("sections", ([], "split", "sections0"), ([], "split", "sections1"), ([], "split", "sections2"), ([], "split", "sections3"), ([], "split", "sections4"), ([], "newline", "newlines"), TokenType.NEWLINE),
        P("short-description", ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),
        P("long-description", ([], "paragraph", "block0"), ([], "line", "paragraph0"), ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),
        P("returns-section", ([], "returns", "returns-section0")),
        P("yields-section", ([], "yields", "yields-section0")),
        P("arguments-section", ([], "arguments", "arguments-section0")),
        P("items-argument", ([], "item-argument", "items-argument0")),
        P("item-argument", ([], "head-argument", "item-argument0"), ([], "head-argument", "line")),
        P("head-argument", ([], "indent", "head-argument0")),
        P("argument", TokenType.WORD),
        P("raises-section", ([], "raises", "raises-section0")),
        P("items-exception", ([], "item-exception", "items-exception0")),
        P("item-exception", ([], "head-exception", "item-exception0"), ([], "head-exception", "line")),
        P("head-exception", ([], "indent", "head-exception0")),
        P("exception", TokenType.WORD),
        P("block-indented", ([], "paragraph-indented", "block-indented0"), ([], "indented", "paragraph-indented0"), ([], "indented", "line")),
        P("block", ([], "paragraph", "block0"), ([], "line", "paragraph0"), ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),
        P("paragraph-indented-two", ([], "indented-two", "paragraph-indented-two0"), ([], "indented-two", "line")),
        P("paragraph-indented", ([], "indented", "paragraph-indented0"), ([], "indented", "line")),
        P("paragraph", ([], "line", "paragraph0"), ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),
        P("line", ([], "word", "line"), TokenType.WORD, TokenType.RETURNS, TokenType.COLON, TokenType.LPAREN, TokenType.RPAREN, TokenType.RAISES, TokenType.ARGUMENTS, TokenType.INDENT),