teragrep / pth_03

Data Processing Language (DPL) parser
GNU Affero General Public License v3.0
0 stars 4 forks source link

Top command doesn't parse multiple fields #47

Open 51-code opened 1 month ago

51-code commented 1 month ago

Describe the bug

There is a test case for a query: | top 1 showperc=F countfield=zzz ddd, ddd

Which results in the following error:

line 46:37 mismatched input ',' expecting {PIPE, COMMA, GET_FIELD_SINGLE_QUOTED, GET_FIELD_DOUBLE_QUOTED, GET_FIELD_STRING, COMMAND_TOP_MODE_BY}

This means that it doesn't recognize the comma, even though it is expecting one. The parsing is stopped when reaching the comma.

Looking at the parse tree, the comma is parsed as , and the grammar rule is waiting for a "COMMA". The parser is probably in the wrong mode when it's parsing the comma.

A workaround is to not use the comma in between, as it is optional.

Expected behavior

Should parse with the comma in between fields as well.

How to reproduce

Test the query above.

Screenshots

Software version

6.1.0

Desktop (please complete the following information if relevant):

Additional context

There were two test payloads with multiple fields, one of which (top2.txt) has been changed to not use a comma in between the fields to see if that works.

topSyntaxParseTest in TopSyntaxTests.java has been disabled because of this issue in PR #52.