Skip to content

C-language code-block lexing error with specific comment syntax "//@" #9548

@srikumarks

Description

@srikumarks

Describe the bug

The following code block causes a C-language "lexing error" to be reported and highlighting skipped.

.. code-block :: c

    int div(int x, int y)
    //@requires y >= 0;
    {
        return x / y;
    }

On the other hand, if I just remove the trailing semicolon on the comment line, the error goes away. i.e. the below version lexes fine.

.. code-block :: c

    int div(int x, int y)
    //@requires y >= 0
    {
        return x / y;
    }

.. and the following lexes fine too -

.. code-block :: c

    int div(int x, int y)
    // requires y >= 0;
    {
         return x / y;
    }

Since the line in question is a comment line, what characters feature within the comment line should not be of any consequence for lexing the block as "C".

How to Reproduce

Include the example code blocks shown in any rat documentation processed by Sphinx.

Expected behavior

All the indicated C-language code blocks should lex fine since the line in question is a comment line.

Your project

not required as examples given in doc

Screenshots

No response

OS

MacOS

Python version

3.8.8

Sphinx version

4.0.1

Sphinx extensions

none

Extra tools

none

Additional context

Tested using project created by sphinx-quickstart

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions