|
1 |
| -import logging |
2 |
| -import os |
3 |
| -import sys |
4 | 1 | from enum import StrEnum, auto
|
5 | 2 | from typing import TypeAlias, NamedTuple, Union
|
6 | 3 |
|
7 |
| -from tree_sitter import Language, Parser |
8 |
| - |
| 4 | +from tree_sitter import Parser |
| 5 | +import cedarscript_grammar |
9 | 6 | from dataclasses import dataclass
|
10 | 7 |
|
11 | 8 | __all__ = ['CEDARScriptASTParser', 'ParseError', 'Command']
|
@@ -240,25 +237,10 @@ def _generate_suggestion(error_node, code_text) -> str:
|
240 | 237 |
|
241 | 238 | class _CEDARScriptASTParserBase:
|
242 | 239 | def __init__(self):
|
243 |
| - """Set up the logger, load the Cedar language, and initialize the parser. |
| 240 | + """Load the CEDARScript language, and initialize the parser. |
244 | 241 | """
|
245 |
| - |
246 |
| - self.logger = logging.getLogger(__name__) |
247 |
| - self.logger.setLevel("DEBUG") |
248 |
| - |
249 |
| - # Determine the appropriate library file based on the current architecture |
250 |
| - if sys.platform.startswith('darwin'): |
251 |
| - lib_name = 'libtree-sitter-cedar.dylib' |
252 |
| - elif sys.platform.startswith('linux'): |
253 |
| - lib_name = 'libtree-sitter-cedar.so' |
254 |
| - else: |
255 |
| - raise OSError(f"Unsupported platform: {sys.platform}") |
256 |
| - |
257 |
| - cedar_language_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..', 'vendor', lib_name)) |
258 | 242 | self.parser = Parser()
|
259 |
| - self.logger.warning(f"[{self.__class__}] Loading native CEDARScript parsing library from {cedar_language_path}") |
260 |
| - self.language = Language(cedar_language_path, 'CEDARScript') |
261 |
| - self.parser.set_language(self.language) |
| 243 | + self.parser.set_language(cedarscript_grammar.language()) |
262 | 244 |
|
263 | 245 |
|
264 | 246 | class CEDARScriptASTParser(_CEDARScriptASTParserBase):
|
|
0 commit comments