Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Latest commit

 

History

History
43 lines (25 loc) · 1.3 KB

PARSER.md

File metadata and controls

43 lines (25 loc) · 1.3 KB

banalize

Parser architecture

Class Parser

Bash basic parser defines following methods:

  • {Banalize::Parser#shebang} - first line of the script if it's in #! format or nil
  • {Banalize::Parser#comments} - all block comments of the file, excluding shebang line
  • {Banalize::Parser#code} - all non-comments of the script, excluding shebang line

All data returned by parser methods are instances of {Banalize::Numbered} class, i.e. they are lines of code with corresponing line number in the script file.

Class Numbered

Class {Banalize::Numbered} provides some helper methods to make searches simpler in the script files:

  • {Banalize::Numbered#grep}

    Find and return lines matching regular expresion.

  • {Banalize::Numbered#has?} Aliased to {Banalize::Numbered#have?}.

    Search for pattern in all lines, return true or false

  • {Banalize::Numbered#does_not_have?} Alias {Banalize::Numbered#dont_have?}

    Opposite for the above method. Return true if pattern in not found.

  • {Banalize::Numbered#search} - attribute accessor. It always contains result of the last grep search.

  • {Banalize::Numbered#lines}

  • {Banalize::Numbered#to_s} (alias: {Banalize::Numbered#inspect})

Additional parsers

Will be added in the future.