Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works
Code Observatory / Source
Pick a parser
Python uses the stdlib ast module, seven other languages use tree-sitter, and the rest fall back to line windows that are recorded as fallback.
PINNED SOURCE Copied from the repository at this commit. Source, not an execution.
PHAROS at 975a38dMIT license
parse_filebackend/app/codeintel/parsers/__init__.py, lines 65–89Open source
def parse_file(path: str, source: str) -> ParseResult | None: """Parse ``source`` (the content of repository-relative ``path``). Returns None for files that are not indexable source code. """ spec = detect_language(path) if spec is None: return None if spec.parser == "python-ast": result = parse_python(path, source) return result if result is not None else line_chunks(path, source, spec.name, "syntax_error") if spec.parser == "tree-sitter": try: result = parse_treesitter(path, source, spec.name, spec.grammar, _module_path(path)) except ImportError as exc: return line_chunks(path, source, spec.name, str(exc)) if len(result.symbols) <= 1 and result.partial: # Only the module symbol and the tree is broken: line chunks # retrieve better than one opaque whole-file chunk. return line_chunks(path, source, spec.name, "parse_error") return result return line_chunks(path, source, spec.name, "unsupported_language")Where this comes from
- Commit
975a38d5d17839c26ee219295a5be6ac66b6d910- File
backend/app/codeintel/parsers/__init__.py- Lines
- 65–89
- Git blob
02097151776f80e9d044e640b7d140f7f516c1d3- License
- MIT, © 2024–2026 Pharos Contributors. Notice
Read it on GitHub at this commit
Check it yourself
From a clone of the repository, the first command prints the blob above and the second prints these lines.
git rev-parse 975a38d:backend/app/codeintel/parsers/__init__.py
git show 975a38d:backend/app/codeintel/parsers/__init__.py | sed -n '65,89p'