alecthomas/chroma

Add a line protocol syntax lexer

jstirnaman opened this issue · 0 comments

Is there an existing issue for this?

  • I have searched the existing issues

What is the missing lexer?

Line protocol time series data syntax.

<?xml version="1.0" encoding="UTF-8"?>
<!-- The following draft is an untested lexer definition for the line protocol time series data structure syntax. -->
<!-- https://docs.influxdata.com/influxdb/cloud-dedicated/reference/syntax/line-protocol/ -->
<lexer name="line-protocol">
    <states>
        <state id="default">
            <!-- Comments (start with #) -->
            <rule regex="#[^\\n]*" scope="comment" />
            <!-- Measurement Name (alphanumeric) -->
            <rule regex="^[a-zA-Z_][a-zA-Z0-9_]*," scope="measurement" />
            <!-- Field Keys (alphanumeric) -->
            <rule regex="[a-zA-Z_][a-zA-Z0-9_]*=" scope="field-key" />
            <!-- Field Values (numbers, strings) -->
            <rule regex="[-+]?(\d+\.\d*|\.\d+|\d+)([eE][-+]?\d+)?" scope="field-value" />
            <rule regex="\"[^\"]*\"" scope="field-value" />
            <!-- Tags (key=value pairs) -->
            <rule regex="[a-zA-Z_][a-zA-Z0-9_]*=[a-zA-Z0-9_]+" scope="tag" />
            <!-- Timestamp (integer) -->
            <rule regex="\d{10}" scope="timestamp" />
            <!-- Delimiters -->
            <rule regex="[,\s]" />
        </state>
    </states>
</lexer>

Links to existing syntax definitions

The line protocol definition: https://docs.influxdata.com/influxdb/cloud-dedicated/reference/syntax/line-protocol/
An EBNF representation of line protocol: https://github.com/influxdata/line-protocol/blob/v2/line-protocol.ebnf