tree-sitter-java icon indicating copy to clipboard operation
tree-sitter-java copied to clipboard

Fail to parse expression

Open mingodad opened this issue 1 year ago • 4 comments

Problem description

Testing a fresh build of this repository I found that it fails to parse a piece of code that the current online playground parse fine (as pointed out elsewhere the online playground is outdated).

public void character(int c, String name, String category, int upper, int lower, int title) {
	assertTrue(c > prevsym);
	prevsym++;
	while (prevsym < c) {
		yield(prevsym++, "cn");
	}
	yield(c, category);

}

Expected parse tree output (optional)

Online playground:

[translation_unit](https://tree-sitter.github.io/tree-sitter/playground#) [0, 0] - [6, 0]
  [function_definition](https://tree-sitter.github.io/tree-sitter/playground#) [0, 0] - [5, 1]
    type: [type_identifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 0] - [0, 6]
    [ERROR](https://tree-sitter.github.io/tree-sitter/playground#) [0, 7] - [0, 11]
      [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 7] - [0, 11]
    declarator: [function_declarator](https://tree-sitter.github.io/tree-sitter/playground#) [0, 12] - [0, 41]
      declarator: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 12] - [0, 21]
      parameters: [parameter_list](https://tree-sitter.github.io/tree-sitter/playground#) [0, 21] - [0, 41]
        [parameter_declaration](https://tree-sitter.github.io/tree-sitter/playground#) [0, 22] - [0, 27]
          type: [primitive_type](https://tree-sitter.github.io/tree-sitter/playground#) [0, 22] - [0, 25]
          declarator: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 26] - [0, 27]
        [parameter_declaration](https://tree-sitter.github.io/tree-sitter/playground#) [0, 29] - [0, 40]
          type: [primitive_type](https://tree-sitter.github.io/tree-sitter/playground#) [0, 29] - [0, 32]
          declarator: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [0, 33] - [0, 40]
    body: [compound_statement](https://tree-sitter.github.io/tree-sitter/playground#) [0, 42] - [5, 1]
      [expression_statement](https://tree-sitter.github.io/tree-sitter/playground#) [1, 1] - [1, 11]
        [update_expression](https://tree-sitter.github.io/tree-sitter/playground#) [1, 1] - [1, 10]
          argument: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [1, 1] - [1, 8]
      [while_statement](https://tree-sitter.github.io/tree-sitter/playground#) [2, 1] - [4, 2]
        condition: [parenthesized_expression](https://tree-sitter.github.io/tree-sitter/playground#) [2, 7] - [2, 20]
          [binary_expression](https://tree-sitter.github.io/tree-sitter/playground#) [2, 8] - [2, 19]
            left: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [2, 8] - [2, 15]
            right: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [2, 18] - [2, 19]
        body: [compound_statement](https://tree-sitter.github.io/tree-sitter/playground#) [2, 21] - [4, 2]
          [expression_statement](https://tree-sitter.github.io/tree-sitter/playground#) [3, 2] - [3, 25]
            [call_expression](https://tree-sitter.github.io/tree-sitter/playground#) [3, 2] - [3, 24]
              function: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [3, 2] - [3, 7]
              arguments: [argument_list](https://tree-sitter.github.io/tree-sitter/playground#) [3, 7] - [3, 24]
                [update_expression](https://tree-sitter.github.io/tree-sitter/playground#) [3, 8] - [3, 17]
                  argument: [identifier](https://tree-sitter.github.io/tree-sitter/playground#) [3, 8] - [3, 15]
                [string_literal](https://tree-sitter.github.io/tree-sitter/playground#) [3, 19] - [3, 23]

Actual parse tree output (optional)

Local fresh build playground:

[program](http://127.0.0.1:8001/#) [0, 0] - [6, 0]
  [method_declaration](http://127.0.0.1:8001/#) [0, 0] - [5, 1]
    [modifiers](http://127.0.0.1:8001/#) [0, 0] - [0, 6]
    type: [void_type](http://127.0.0.1:8001/#) [0, 7] - [0, 11]
    name: [identifier](http://127.0.0.1:8001/#) [0, 12] - [0, 21]
    parameters: [formal_parameters](http://127.0.0.1:8001/#) [0, 21] - [0, 41]
      [formal_parameter](http://127.0.0.1:8001/#) [0, 22] - [0, 27]
        type: [integral_type](http://127.0.0.1:8001/#) [0, 22] - [0, 25]
        name: [identifier](http://127.0.0.1:8001/#) [0, 26] - [0, 27]
      [formal_parameter](http://127.0.0.1:8001/#) [0, 29] - [0, 40]
        type: [integral_type](http://127.0.0.1:8001/#) [0, 29] - [0, 32]
        name: [identifier](http://127.0.0.1:8001/#) [0, 33] - [0, 40]
    body: [block](http://127.0.0.1:8001/#) [0, 42] - [5, 1]
      [expression_statement](http://127.0.0.1:8001/#) [1, 1] - [1, 11]
        [update_expression](http://127.0.0.1:8001/#) [1, 1] - [1, 10]
          [identifier](http://127.0.0.1:8001/#) [1, 1] - [1, 8]
      [while_statement](http://127.0.0.1:8001/#) [2, 1] - [4, 2]
        condition: [condition](http://127.0.0.1:8001/#) [2, 7] - [2, 20]
          [binary_expression](http://127.0.0.1:8001/#) [2, 8] - [2, 19]
            left: [identifier](http://127.0.0.1:8001/#) [2, 8] - [2, 15]
            right: [identifier](http://127.0.0.1:8001/#) [2, 18] - [2, 19]
        body: [block](http://127.0.0.1:8001/#) [2, 21] - [4, 2]
          [yield_statement](http://127.0.0.1:8001/#) [3, 2] - [3, 25]
            [parenthesized_expression](http://127.0.0.1:8001/#) [3, 7] - [3, 24]
              [ERROR](http://127.0.0.1:8001/#) [3, 8] - [3, 18]
                [update_expression](http://127.0.0.1:8001/#) [3, 8] - [3, 17]
                  [identifier](http://127.0.0.1:8001/#) [3, 8] - [3, 15]
              [string_literal](http://127.0.0.1:8001/#) [3, 19] - [3, 23]
                [string_fragment](http://127.0.0.1:8001/#) [3, 20] - [3, 22]

mingodad avatar Feb 11 '24 16:02 mingodad