Skip to content

Group error: Error: illegal token '{', ';' expected #568

Closed
@delijati

Description

@delijati

protobuf.js version: protobufjs@6.2.1

Parsing error

'use strict';

var protobuf = require('protobufjs');

protobuf.load('test.proto', function(err, root) {
    if (err) throw err;
    console.log(root);
});

Proto file:

message BookDetails {
    optional string publisher = 4;
    optional string publicationDate = 5;
    optional string isbn = 6;
    optional int32 numberOfPages = 7;
    optional string subtitle = 8;
    optional string readerUrl = 10;
    optional string downloadEpubUrl = 11;
    optional string downloadPdfUrl = 12;
    optional string acsEpubTokenUrl = 13;
    optional string acsPdfTokenUrl = 14;
    optional bool epubAvailable = 15;
    optional bool pdfAvailable = 16;
    optional string aboutTheAuthor = 17;
    repeated group Identifier = 18 {
        optional int32 type = 19;
        optional string identifier = 20;
    }
    optional bool fixedLayoutContent = 21;
    optional bool audioVideoContent = 22;
    optional bool isAgencyBook = 23;
}

Error:

% node test.js  
/opt/foo/test.js:6
    if (err) throw err;
             ^

Error: illegal token '{', ';' expected (line 15)
    at illegal (/opt/foo/node_modules/protobufjs/src/tokenize.js:57:16)
    at skip (/opt/foo/node_modules/protobufjs/src/tokenize.js:191:19)
    at parseInlineOptions (/opt/foo/node_modules/protobufjs/src/parse.js:411:9)
    at parseField (/opt/foo/node_modules/protobufjs/src/parse.js:284:21)
    at parseType (/opt/foo/node_modules/protobufjs/src/parse.js:248:25)
    at parseCommon (/opt/foo/node_modules/protobufjs/src/parse.js:213:17)
    at parse (/opt/foo/node_modules/protobufjs/src/parse.js:539:21)
    at process (/opt/foo/node_modules/protobufjs/src/root.js:97:48)
    at /opt/foo/node_modules/protobufjs/src/root.js:167:17
    at fetchReadFileCallback (/opt/foo/node_modules/@protobufjs/fetch/index.js:30:19)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions