• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

renatahodovan / grammarinator / 4083580084

pending completion
4083580084

push

github

Renata Hodovan
Add API and CLI documentation

6 of 6 new or added lines in 2 files covered. (100.0%)

3470 of 4815 relevant lines covered (72.07%)

0.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

45.45
/grammarinator/runtime/dispatching_model.py
1
# Copyright (c) 2020-2023 Renata Hodovan, Akos Kiss.
2
#
3
# Licensed under the BSD 3-Clause License
4
# <LICENSE.rst or https://opensource.org/licenses/BSD-3-Clause>.
5
# This file may not be copied, modified, or distributed except
6
# according to those terms.
7

8
from .default_model import DefaultModel
1✔
9

10

11
class DispatchingModel(DefaultModel):
1✔
12
    """
13
    Base class of custom modules that aim to override the decisions in
14
    specific rules. To override a decision point, the subclass must
15
    define methods in the form of ``choice_{rule_name}``, ``quantify_{rule_name}``
16
    or ``charset_{rule_name}`` - with the same signature as their counterparts
17
    in :class:`grammarinator.runtime.DefaultModel` - in case of overriding an
18
    alternation, quantifier or charset decision, respectively.
19
    """
20

21
    def choice(self, node, idx, weights):
1✔
22
        """
23
        Trampoline method to call the underlaying model's ``choice_{node.name}`` method if any.
24
        Otherwise, it calls its anchestor's ``choice`` implementation.
25
        """
26
        name = 'choice_' + node.name
×
27
        return (getattr(self, name) if hasattr(self, name) else super().choice)(node, idx, weights)
×
28

29
    def quantify(self, node, idx, min, max):
1✔
30
        """
31
        Trampoline method to call the underlaying model's ``quantify_{node.name}`` method if any.
32
        Otherwise, it calls its anchestor's ``quantify`` implementation.
33
        """
34
        name = 'quantify_' + node.name
×
35
        yield from (getattr(self, name) if hasattr(self, name) else super().quantify)(node, idx, min, max)
×
36

37
    def charset(self, node, idx, chars):
1✔
38
        """
39
        Trampoline method to call the underlaying model's ``charset_{node.name}`` method if any.
40
        Otherwise, it calls its anchestor's ``charset`` implementation.
41
        """
42
        name = 'charset_' + node.name
×
43
        return (getattr(self, name) if hasattr(self, name) else super().charset)(node, idx, chars)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc