abstract class Analyzer::Cfml::CfmlEngine

Overview

Shared CFML parsing layer.

See AGENTS.md ยง"Analyzer Layering": this owns file selection and the syntax handling every CFML adapter needs, so framework analyzers (Taffy, ColdBox, Wheels, FW/1) consume components and functions rather than re-implementing tag/script parsing.

The two syntaxes are the whole problem. CFML is written either as tags (<cffunction name="x" access="remote">) or as cfscript (remote string function x()), the two mix inside a single file, and everything is case-insensitive.

Direct Known Subclasses

Defined in:

analyzer/engines/cfml_engine.cr

Constant Summary

CFARGUMENT_TAG_RE = /<cfargument\b([\s\S]*?)>/i
CFCOMPONENT_TAG_RE = /<cfcomponent\b([\s\S]*?)>/i

Tags may span lines and pad their = for alignment, so attributes are matched with \s*=\s* and tag bodies with [\s\S]*?.

CFFUNCTION_TAG_RE = /<cffunction\b([\s\S]*?)>/i
HTTP_VERBS = Set {"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"}

Verbs a CFML framework can register. Route DSLs take verbs as free text, so a value outside this set is not turned into a method.

NAMED_ARGUMENT_RE = /\A([A-Za-z_]\w*)\s*[:=]\s*(.+)\z/m
SCRIPT_COMPONENT_HEADER_LIMIT = 2000

A component header is a handful of attributes; bound the scan so a file with no opening brace cannot walk the whole content.

SCRIPT_COMPONENT_RE = /(?<![\w.])component\b/i

component ... { header in script syntax, and a function declaration with its trailing attribute list up to the body brace.

SCRIPT_FUNCTION_RE = /(?<![\w.])function\s+(\w+)\s*\(/i
TAG_ATTR_RE = /([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/

Attribute names carry : and - in the wild (taffy:uri, data-required), and values use either quote style.

TEST_COMPONENT_RE = /.+(?:Test|Spec)\.cfc\z/i

TestBox names suites <Something>Test.cfc / <Something>Spec.cfc. The leading .+ is load-bearing: a component named exactly Test.cfc is a demo, not a suite (fw1 ships one that declares a real remote method), and an anchored ends_with? swallowed it.

Instance methods inherited from class Analyzer

analyze analyze, base_path : String base_path, base_paths : Array(String) base_paths, callees_needed? : Bool callees_needed?, http_header_name(name : String) : String | Nil http_header_name, line_number_for_index(content : String, char_index : Int32) : Int32 line_number_for_index, logger : NoirLogger logger, parallel_analyze(files : Array(String), &block : String -> Nil) parallel_analyze, read_file_content(path : String) : String read_file_content, result : Array(Endpoint) result, unique_params(params : Array(Param)) : Array(Param) unique_params, url : String url, web_root_path(path : String, markers : Array(String)) : String web_root_path

Constructor methods inherited from class Analyzer

new(options : Hash(String, YAML::Any)) new

Instance methods inherited from module FileHelper

all_files : Array(String) all_files, get_files_by_extension(extension : String) : Array(String) get_files_by_extension, get_files_by_extensions(extensions : Array(String)) : Array(String) get_files_by_extensions, get_files_by_prefix(prefix : String) : Array(String) get_files_by_prefix, get_files_by_prefix_and_extension(prefix : String, extension : String) : Array(String) get_files_by_prefix_and_extension, get_public_dir_files(base_path : String, folder : String) : Array(String) get_public_dir_files, get_public_files(base_path : String, anchors : Array(String) = ["shard.yml", "Gemfile"]) : Array(String) get_public_files