efficios / ctf

Common Trace Format requirements and specifications
8 stars 4 forks source link

TSDL Grammar - keyword in primary-expression #5

Closed fafok29 closed 11 months ago

fafok29 commented 1 year ago

Consider this TSDL snippet from the specification

stream {
    event.header := struct {
        uint64_ccnt_t timestamp;
    };
    packet.context := struct packet_context;
};

The second line ("event.header" ) would be parsed in the following sequence(simplified):

ctf-assignment-expression:
    unary-expression type-assignment-operator type-specifier

unary-expression:
    postfix-expression

postfix-expression:
    primary-expression

primary-expression:
    identifier
    constant
    string-literal
    ( unary-expression )

But "event" is a keyword, and primary-expression doesn't mention that keywords are allowed. So the question is should event and other keywords(all of them? some of them?) be considered as identifiers in this context, or am I missing something?

compudj commented 1 year ago

Looking at parser.y from babeltrace:

ctf_assignment_expression: unary_expression CTF_EQUAL unary_expression [...]

where: unary_expression:
postfix_expression [...]

where:

postfix_expression: IDENTIFIER [...] | ID_TYPE [...] | keywords [...]

So indeed, it appears that keywords should be considered at least as postfix expressions, and probably as primary expressions within this grammar.

But please don't put too much effort on TSDL and CTF 1.8, as the active work is happening on CTF 2 (https://diamon.org/ctf/files/CTF2-SPECRC-8.1rA.html), which replaces TSDL by JSON-seq. It will remove the need for a custom grammar altogether.

fafok29 commented 1 year ago

So indeed, it appears that keywords should be considered at least as postfix expressions, and probably as primary expressions within this grammar.

Good to know, thank you, could you please point me to parser.y, maybe I can use it as a reference instead.

But please don't put too much effort on TSDL and CTF 1.8, as the active work is happening on CTF 2 (https://diamon.org/ctf/files/CTF2-SPECRC-8.1rA.html), which replaces TSDL by JSON-seq. It will remove the need for a custom grammar altogether.

This is something I'm doing in my free time so it is not a big deal, but I'd like to use it for traces produced with certain DPDK LTS version and I doubt the LTS version will be updated with the new format, so it is fine for now.

Also, what is the planned release date of CTF2? if there is any defined?