GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Cleanup Tokenizer · Issue #3 · PackageFactory/PackageFactory.ComponentEngine

This repository was archived by the owner on Aug 27, 2026. It is now read-only.
This repository was archived by the owner on Aug 27, 2026. It is now read-only.

Cleanup Tokenizer #3

Copy link
Copy link
Open
Open
Cleanup Tokenizer#3
Copy link
Assignees
grebaldi

Description

@mhsdesign
mhsdesign
opened on Nov 10, 2022
Issue body actions
No description provided.

Activity

  1. mhsdesign commented on Nov 10, 2022

    @mhsdesign
    mhsdesign
    on Nov 10, 2022
    ContributorAuthor
    More actions

    1

    i dislike those three methods:

    PackageFactory.ComponentEngine/src/Parser/Tokenizer/TokenType.php

    Lines 138 to 158 in f58db0a

    public static function tryBracketOpenFromFragment(Fragment $fragment): ?self
    {
    return match ($fragment->value) {
    '{' => self::BRACKET_CURLY_OPEN,
    '(' => self::BRACKET_ROUND_OPEN,
    '[' => self::BRACKET_SQUARE_OPEN,
    default => null
    };
    }
    public function closingBracket(): TokenType
    {
    return match ($this) {
    self::BRACKET_CURLY_OPEN => self::BRACKET_CURLY_CLOSE,
    self::BRACKET_ROUND_OPEN => self::BRACKET_ROUND_CLOSE,
    self::BRACKET_SQUARE_OPEN => self::BRACKET_SQUARE_CLOSE,
    default => throw new \Exception('@TODO: Not a bracket.')
    };
    }
    public function matchesString(string $string): bool
    they are hard to make sense out of...
    At first i didnt even understand what closingBracket was doing, i though it would return self::BRACKET_CURLY_OPEN => self::BRACKET_CURLY_OPEN, but it gives the closing bracket for the opening bracket - my eyes didnt catch that.

    so my take would be to have better method naming, or as those methods are only called at one place - inside

    PackageFactory.ComponentEngine/src/Parser/Tokenizer/Tokenizer.php

    Lines 56 to 71 in 62965ec

    $bracket = TokenType::tryBracketOpenFromFragment($fragments->current());
    $buffer = Buffer::empty();
    if ($bracket) {
    yield from $buffer->append($fragments->current())->flush($bracket);
    $fragments->next();
    }
    while ($fragments->valid()) {
    /** @var Fragment $fragment */
    $fragment = $fragments->current();
    if ($bracket) {
    $closingBracket = $bracket->closingBracket();
    if ($closingBracket->matchesString($fragment->value)) {
    put them inline or sth. They do feel like an anomaly ...

  2. grebaldi
    self-assigned this
    on Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @grebaldi
    grebaldi

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.