Skip to content

New-line support for message constant field separator #752

@ii64

Description

@ii64

Currently the parser does not support new-line separation for message constant field due to that only check for:

self.tokenizer.next_symbol_if_in(&[',', ';'])?;

Additionally, extra separator without field definition will also give an error.

Test data:

option (blabla) = {
  foo: bar
  baz: bur
  boo: biz
};
option (blabla) = {
  foo: bar,
  baz: bur,
  boo: biz,
};

// Consume the comma or semicolon if present. Commas and semicolons
// between message fields are optional, all these are valid:
//
// {foo: 1,bar: 2,baz: 3,}
// {foo: 1;bar: 2;baz: 3;}
// {foo: 1 bar: 2 baz: 3}
// {foo: 1,bar: 2;baz: 3}
// {foo: 1,bar: 2 baz: 3}
//
self.tokenizer.next_symbol_if_in(&[',', ';'])?;

Error:

Caused by:
    0: error in `<stripped>.proto`: at <stripped>:3: While parsing message constant, expecting char `}`
    1: at <stripped>:3: While parsing message constant, expecting char `}`
    2: While parsing message constant, expecting char `}`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions