class PythonParser

Overview

Python source-file parser used by the Flask analyzer to resolve routing-relevant globals (Blueprint / Namespace / Api instances) across files. Originally a hand-rolled token consumer paired with minilexers/python.cr; rewritten to walk the vendored tree-sitter Python grammar so we shed the legacy lexer (now deleted) and get accurate handling of multi-line strings, fstrings, parenthesised imports, and similar shapes that the regex/token approach couldn't express cleanly.

The public surface kept stable for Flask:

ImportModel stays in tree but isn't populated by this rewrite — nothing reads parser.@import_statements. We keep the class for any external referrers that might construct one for logging.

Defined in:

miniparsers/python.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(path : String, content : String, parsers : Hash(String, PythonParser), visited : Array(String) = Array(String).new, depth : Int32 = 0) #

[View source]

Instance Method Detail

def parse(content : String) #

[View source]
def path : String #

[View source]
def path=(path : String) #

[View source]