◆ __init__()
lalr_parsing.grammar.NonTerminal.__init__ |
( |
| self, |
|
|
| name, |
|
|
| productions ) |
2 def __init__(self, name, productions):
3
4
5
6
7
8
9
10
11
12
13 self.name = name
14 self.productions = [(x.split() if isinstance(x, str) else x) for x in productions]
15
◆ __repr__()
lalr_parsing.grammar.NonTerminal.__repr__ |
( |
| self | ) |
|
16 def __repr__(self):
17 return 'NonTerminal(' + repr(self.name) + ')'
18
◆ __str__()
lalr_parsing.grammar.NonTerminal.__str__ |
( |
| self | ) |
|
19 def __str__(self):
20 return self.name
21
◆ stringify()
lalr_parsing.grammar.NonTerminal.stringify |
( |
| self, |
|
|
| pretty = True ) |
22 def stringify(self, pretty=True):
23 title = '%s: ' % self.name
24
25 if pretty:
26 separator = '\n%s| ' % (' ' * len(self.name))
27 else:
28 separator = ' | '
29
30 def strprod(prod):
31 return ' '.join(str(sym) for sym in prod)
32
33 rules = separator.join(strprod(prod) for prod in self.productions)
34
35 return title + rules
36
37
◆ name
lalr_parsing.grammar.NonTerminal.name |
◆ productions
lalr_parsing.grammar.NonTerminal.productions |
The documentation for this class was generated from the following file:
- hyperdbg/script-engine/python/lalr_parsing/grammar.py