Skip to content

Comments

Add greedy parse support for table cells#45

Open
AryaHassanli wants to merge 1 commit intomainfrom
greedy-table-parse
Open

Add greedy parse support for table cells#45
AryaHassanli wants to merge 1 commit intomainfrom
greedy-table-parse

Conversation

@AryaHassanli
Copy link
Contributor

No description provided.

@AryaHassanli AryaHassanli requested a review from a team as a code owner February 20, 2026 19:28
@gemini-code-assist
Copy link

Summary of Changes

Hello @AryaHassanli, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the parser's ability to handle complex content within AsciiDoc table cells by introducing 'greedy' parsing logic. This allows for more robust and flexible interpretation of cell content, particularly for constructs like conditional preprocessor directives. The changes involve expanding the table grammar with dedicated rules for AsciiDoc-specific elements and updating existing cell parsing mechanisms to leverage these new capabilities. The addition of new test cases ensures the correct functioning of these parsing improvements.

Highlights

  • Greedy Parsing for AsciiDoc Table Cells: Implemented new parsing rules to allow for greedy parsing of content within AsciiDoc table cells, enabling more complex structures like conditional preprocessor directives (ifdef) to be correctly processed.
  • Extended Table Grammar: Introduced several new grammar rules in table.peg specifically for AsciiDoc inline table lines, multi-line cells, elements, delimiters, and formatting, enhancing the flexibility of table content parsing.
  • Updated Table Cell Rules: Modified the InitialInlineTableCell and AdditionalInlineTableCell rules to incorporate the new AsciiDoc-specific parsing paths, ensuring that both standard and AsciiDoc-style table cells are handled.
  • New Test Cases: Added a new AsciiDoc test file (table_cell_ifdef.adoc) and its corresponding Go test (table_cell_ifdef_test.go) to validate the greedy parsing of ifdef blocks within table cells.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • asciidoc/parse/grammar/table.peg
    • Modified InitialInlineTableCell and AdditionalInlineTableCell rules to include AsciiDoc-specific parsing paths.
    • Added new grammar rules for AsciiDocInlineTableLines, AsciiDocMultiLineTableCell, AsciiDocInlineTableCellLine, AsciiDocInlineTableCellLastLine, AsciiDocInlineTableElements, AsciiDocInlineTableElement.
    • Introduced new rules for AsciiDoc table cell delimiters and formats: AsciiDocInitialTableCellDelimiter, AsciiDocAdditionalTableCellFormat, AsciiDocAdditionalTableCellDelimiter, AsciiDocTableCellFormat, and AsciiDocNakedInlineTableCellText.
  • tests/table_cell_ifdef.adoc
    • Added a new AsciiDoc document demonstrating an ifdef block within a table cell.
  • tests/table_cell_ifdef_test.go
    • Added a new Go test file containing the expected Abstract Syntax Tree (AST) for the table_cell_ifdef.adoc file.
  • tests/tables_test.go
    • Updated the test suite to include the new table_cell_ifdef test case.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request introduces greedy parsing for table cells using the a (AsciiDoc) style. This is a valuable addition as it allows table cells to contain block-level elements like conditional macros (ifdef, ifndef), which were previously causing parsing issues. The implementation correctly leverages the existing parseBlockCell mechanism to re-parse the collected greedy content. I have identified one significant issue in a debug log that would cause a runtime panic due to an incorrect type assertion.

debugPosition(c, "TABLE LINES: asciidoc inline table lines (%d), content (%d): \"%s\"\n", len(lines.([]any)), len(content.([]asciidoc.Element)), string(c.text))
cellLines = flat(lines.([]any))
} else {
debugPosition(c, "TABLE CELL: asciidoc inline table lines (0), content (%d): \"%s\"\n", len(content.([]any)), string(c.text))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This type assertion will cause a runtime panic when this debug path is executed. content is the result of the AsciiDocInlineTableCellLastLine rule, which returns []asciidoc.Element. In Go, a slice of a specific interface type cannot be asserted to []any (which is []interface{}). You should use content.([]asciidoc.Element) instead, which is consistent with the correct assertion used just a few lines above in line 299.

        debugPosition(c, "TABLE CELL: asciidoc inline table lines (0), content (%d): \"%s\"\n", len(content.([]asciidoc.Element)), string(c.text))

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.

1 participant