Skip to content

ULL-ESIT-PL/idgrep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IDGrep

A command-line tool that searches for identifier patterns in JavaScript files using AST parsing.

Context

A "hello world" to familiarize the ULL PL students with AST-based code analysis. It introduces espree, estraverse, commander, regular expressions and typescript. See crguezl PL 24/25 course book, section"Introduction to Espree" for a JS version and more detailed introduction to espree and estraverse.

Setup

  1. Install nvm and node or open the repo in a GH codespace
  2. Install dependencies:
    npm install
  3. Build the project:
    npm run build
  4. Run the tool on the example file:
    npm start

Usage

node dist/idgrep.js -p "your_pattern" file1.js file2.js

Development

  • npm run build - Compile TypeScript to JavaScript
  • npm run dev - Watch mode for development (auto-recompile on changes)
  • npm start - Run the compiled version

Project Structure

  • src/ - TypeScript source files
    • [index.ts](src/index.ts) - Main CLI application
    • idgrep.ts - Search library
  • dist/- Output folder
  • dist/hacky.js - Input example
  • tsconfig.json - TypeScript configuration with strict type checking
  • package.json - Project dependencies and scripts

Exercise for students

Read in detail PL 24/25 course book, section"Introduction to Espree" for a JS version and more detailed introduction to espree and estraverse.

About

A "hello world" to familiarize the ULL PL students with AST-based code analysis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors