Skip to content

Conversation

@facontidavide
Copy link
Collaborator

@facontidavide facontidavide commented Feb 2, 2026

Summary

  • Remove vendored lexy library (~28k lines) and replace the lexy-based script grammar with a hand-written tokenizer + Pratt parser
  • Add src/script_tokenizer.cpp implementing BT::Scripting::tokenize() for all token types (identifiers with @ prefix, numbers, strings, operators)
  • Conditionally use std::from_chars for double/float when available (__cpp_lib_to_chars_fp_formatting)

Test plan

  • All 334 existing tests pass (verified locally)
  • Script parser tests cover: arithmetic, comparisons, assignments, string concat, ternary, bitwise ops, hex literals, exponents, chained comparisons, error cases
  • Blackboard tests with @-prefixed root variables pass

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Removed Features
    • Removed embedded parser combinator library and related build configuration files.

facontidavide and others added 3 commits February 2, 2026 22:14
Implement BT::Scripting::tokenize() to replace the lexy-based tokenizer
that was removed. Handles all token types: identifiers (with @ prefix for
root blackboard vars), numbers (int/hex/real/exponent), single-quoted
strings, two-char operators, and single-char operators/delimiters.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@coderabbitai
Copy link

coderabbitai bot commented Feb 2, 2026

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (3)
  • src/script_parser.cpp
  • src/script_tokenizer.cpp
  • tests/script_parser_test.cpp

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review
📝 Walkthrough

Walkthrough

The pull request removes the entire 3rdparty/lexy directory and related build configuration. This includes the lexy parser library's source code, build files, documentation, and all associated headers, along with two additions to .gitignore.

Changes

Cohort / File(s) Summary
Build & Configuration
.gitignore, 3rdparty/lexy/CMakeLists.txt, 3rdparty/lexy/cmake/lexyConfig.cmake.in
Deletion of CMake build configuration, license file, README documentation, and package configuration template. Addition of /.worktrees/ and TODO.md to .gitignore.
Core Library Infrastructure
3rdparty/lexy/include/lexy/_detail/{any_ref, assert, buffer_builder, code_point, config, detect, integer_sequence, invoke, iterator, lazy_init, memory_resource, nttp_string, stateless_lambda, std, string_view, swar, tuple, type_name, unicode_database}.hpp
Removal of fundamental internal utility headers providing type-erasing references, assertion macros, buffer management, code point handling, configuration flags, type detection, sequence utilities, invocation mechanics, iterator adapters, lazy initialization, memory resources, compile-time strings, standard library shims, and Unicode database.
Action & Validation System
3rdparty/lexy/include/lexy/action/{base, match, parse, parse_as_tree, scan, trace, validate}.hpp
Deletion of complete action execution framework including parsing, matching, validation, tracing, and tree construction logic.
Callback Framework
3rdparty/lexy/include/lexy/callback.hpp, 3rdparty/lexy/include/lexy/callback/{adapter, aggregate, base, bind, bit_cast, composition, constant, container, fold, forward, integer, noop, object, string}.hpp
Removal of callback aggregator header and all specialized callback implementations for adapters, aggregates, binding, composition, containers, folding, object construction, and string handling.
Core Public Types
3rdparty/lexy/include/lexy/{code_point, dsl}.hpp
Deletion of code point type system and primary DSL aggregation header.
DSL Base & Fundamental Rules
3rdparty/lexy/include/lexy/dsl/{any, base}.hpp
Removal of wildcard token matcher and foundational parser event structures and utilities.
DSL Character & Literal Matching
3rdparty/lexy/include/lexy/dsl/{ascii, bits, bom, brackets, byte, char_class, code_point, literal}.hpp
Deletion of character class DSL, ASCII utilities, bit-level parsing, BOM detection, bracket matching, byte-level parsing, and literal matching infrastructure.
DSL Control Flow & Branching
3rdparty/lexy/include/lexy/dsl/{branch, choice, error, expression, if, loop}.hpp
Removal of branch composition, choice operators, error handling, expression parsing (with operator precedence), conditional rules, and loop/while constructs.
DSL Context & State Management
3rdparty/lexy/include/lexy/dsl/{context_counter, context_flag, context_identifier}.hpp
Deletion of parse-context variable management for counters, flags, and identifier tracking.
DSL Delimited & Structured Content
3rdparty/lexy/include/lexy/dsl/{capture, case_folding, delimited, follow}.hpp
Removal of content capture, case folding, delimiter matching, and lookahead utilities.
DSL Numeric & Operator Parsing
3rdparty/lexy/include/lexy/dsl/{digit, integer, operator, sign}.hpp
Deletion of digit/radix parsing, integer parsing with bounds checking, operator literal parsing, and sign handling.
DSL Parsing Utilities & Modifiers
3rdparty/lexy/include/lexy/dsl/{effect, eof, identifier, member, newline, option, peek, position}.hpp
Removal of side effects, EOF detection, identifier/keyword parsing, member assignment, newline matching, optional values, lookahead/peek, and position tracking.
DSL Production & Sequence Composition
3rdparty/lexy/include/lexy/dsl/{production, sequence, subgrammar}.hpp
Deletion of production rules, sequence composition via operator overloads, and subgrammar integration.
DSL List & Repetition
3rdparty/lexy/include/lexy/dsl/{combination, list, repeat, separator, times}.hpp
Removal of list parsing, combination/permutation matching, repetition with separators, and N-times operators.
DSL Symbol Table & Termination
3rdparty/lexy/include/lexy/dsl/{parse_as, parse_tree_node, punctuator, recover, return, scan, symbol, terminator}.hpp
Deletion of symbol table matching, parse-tree nodes, punctuation literals, error recovery, early return, input scanning, and terminator handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

The diff involves large-scale deletion of an entire third-party library (lexy) spanning hundreds of files and thousands of lines. While the changes are homogeneous in nature (consistent pattern of complete file removal), the sheer scope requires careful verification that all lexy references are cleanly removed from the rest of the codebase and that no external dependencies are broken by this removal.

Poem

🐰 Off hops the lexy library, with DSLs and parsers so grand,
A thousand headers removed from the land,
The codebase grows lighter, the repo more clean,
The simplest refactor this rabbit has seen! 🌿

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: removing the lexy library dependency and replacing it with a hand-written tokenizer and Pratt parser.
Description check ✅ Passed The description provides a summary of the changes, includes test plans with checkboxes, and mentions generated tool attribution, covering the key modifications and validation approach.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/remove-lexy

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- Add explicit != 0 for implicit int->bool conversions from ctype
  functions (readability-implicit-bool-conversion)
- Value-initialize op variables in switch statements
  (cppcoreguidelines-init-variables)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@codacy-production
Copy link

codacy-production bot commented Feb 2, 2026

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+2.19% (target: -1.00%) 95.34%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (2c71b41) 5395 3755 69.60%
Head commit (847f502) 5782 (+387) 4151 (+396) 71.79% (+2.19%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#1099) 451 430 95.34%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

facontidavide and others added 2 commits February 3, 2026 00:18
Tokenizer:
- Extract scanHexNumber(), scanDecimalNumber(), matchTwoCharOp(),
  matchSingleCharOp() to reduce cognitive complexity of tokenize()
- Use init-statement in if for identifier text variable (S6004)

Parser:
- Replace std::runtime_error with RuntimeError (S112)
- Remove redundant lambda return type (S3574)
- Catch RuntimeError instead of std::exception (S1181)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
New test cases:
- TokenizerEdgeCases: unterminated strings, hex errors (0x, 0xG),
  exponent errors (3e, 3e+), DotDot with numbers, empty/whitespace scripts
- ChainedComparisons: 1<2<3, 3>2>1, mixed chains, chained equality
- OperatorPrecedence: bitwise vs logical, parenthesized subexpressions
- UnaryOperators: !, !!, ~, unary minus in expressions
- TernaryExpressions: basic, with subexpressions, comparison conditions
- MultipleStatements: extra semicolons, return value of last expression

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 2, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants