Pattern matching in Pharo - Archive ouverte HAL
Communication Dans Un Congrès Année : 2023

Pattern matching in Pharo

Résumé

Pattern matching is a computational technique used to identify and analyse recurring structures or patterns within data and enable the extraction of meaningful information from the data.In the field of software engineering, pattern matching is often used in applications such as compilers and linters, where the ability to recognise and understand structural patterns in source code is essential for tasks such as optimisation, error detection, and code refactoring, but pattern matching also finds its use for querying deeply recursive structures.Pharo already offers RBParseTreeSearcher, a powerful Domain Specific Language (DSL) defining its own textual syntax with a focus on matching the Pharo Abstract Syntax Tree (AST).This tool is the base of the Pharo Refactoring Framework.However, RBParseTreeSearcher is dedicated to Pharo AST matching only and cannot perform on other kinds of structures or ASTs.In this paper, we introduce MoTion, a new pattern matcher that works on Pharo objects in the large and that focuses on flexibility and expressiveness, and then we present the syntax of both matcher tools.Finally, we compare the execution speed and the expressiveness of both pattern matchers in the context of AST matching against each other as well as against a pure Pharo request on the AST.MoTion offers a powerful base for dedicated pattern matchers and matches any kind of Pharo objects, but its genericity implies lower performances than a dedicated solution tailored for a unique usage as RBParseTreeSearcher.
Fichier principal
Vignette du fichier
IWST_2023_paper_5-2.pdf (760.36 Ko) Télécharger le fichier
Origine Fichiers produits par l'(les) auteur(s)

Dates et versions

hal-04217930 , version 1 (27-09-2023)

Licence

Identifiants

  • HAL Id : hal-04217930 , version 1

Citer

Aless Hosry, Vincent Aranega, Nicolas Anquetil, Stéphane Ducasse. Pattern matching in Pharo. IWST 2023 - International Workshop on Smalltalk Technologies, Aug 2023, Lyon, France. ⟨hal-04217930⟩
218 Consultations
159 Téléchargements

Partager

More