From 28634677bf0a6199c624141136b5dfa78cd6e0d7 Mon Sep 17 00:00:00 2001 From: John Doty Date: Tue, 28 May 2024 05:56:44 -0700 Subject: [PATCH] A little more faster. --- harness.py | 4 ++-- parser.py | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/harness.py b/harness.py index 4a1b0a9..050c87a 100644 --- a/harness.py +++ b/harness.py @@ -89,8 +89,8 @@ def parse(table, tokens, trace=None): def harness(lexer_func, grammar_func, start_rule, source_path): - # generator = parser.GenerateLR1 - generator = parser.GenerateLALR + generator = parser.GenerateLR1 + # generator = parser.GenerateLALR table = grammar_func().build_table(start=start_rule, generator=generator) print(f"{len(table)} states") diff --git a/parser.py b/parser.py index 7b24c49..8ace978 100644 --- a/parser.py +++ b/parser.py @@ -207,11 +207,9 @@ class Configuration: def __hash__(self) -> int: return self._hash - def __eq__(self, value: object, /) -> bool: + def __eq__(self, value: typing.Any, /) -> bool: if value is self: return True - if not isinstance(value, Configuration): - return NotImplemented return ( value._hash == self._hash @@ -846,7 +844,7 @@ class GenerateLR0(object): return next - def gen_sets(self, config_set: typing.Tuple[Configuration, ...]) -> ConfigurationSetInfo: + def gen_sets(self, config_set: ConfigSet) -> ConfigurationSetInfo: """Generate all configuration sets starting from the provided set.""" result = ConfigurationSetInfo() @@ -1390,7 +1388,7 @@ class GenerateLALR(GenerateLR1): use a bunch of improvement, probably.) """ - def gen_sets(self, config_set: typing.Tuple[Configuration, ...]) -> ConfigurationSetInfo: + def gen_sets(self, config_set: ConfigSet) -> ConfigurationSetInfo: """Recursively generate all configuration sets starting from the provided set.