thrift-parser icon indicating copy to clipboard operation
thrift-parser copied to clipboard

empty BlockComment breaks parser

Open lucasterra opened this issue 5 years ago • 0 comments

If you have this IDL:

/* */
const string asdf = 'sdf'

The AST will return an empty document:

{
  "type": "ThriftDocument",
  "body": []
}

Another example:

/* */
some string
*/
const string test = 'asdf'

You get:

{
  "type": "ThriftDocument",
  "body": [
    {
      "type": "ConstDefinition",
      "name": {
        "type": "Identifier",
        "value": "test",
        "loc": {
          "start": {
            "line": 3,
            "column": 14,
            "index": 34
          },
          "end": {
            "line": 3,
            "column": 18,
            "index": 38
          }
        }
      },
      "fieldType": {
        "type": "StringKeyword",
        "loc": {
          "start": {
            "line": 3,
            "column": 7,
            "index": 27
          },
          "end": {
            "line": 3,
            "column": 13,
            "index": 33
          }
        }
      },
      "initializer": {
        "type": "StringLiteral",
        "value": "asdf",
        "loc": {
          "start": {
            "line": 3,
            "column": 21,
            "index": 41
          },
          "end": {
            "line": 3,
            "column": 27,
            "index": 47
          }
        }
      },
      "comments": [
        {
          "type": "CommentBlock",
          "value": [
            "some string"
          ],
          "loc": {
            "start": {
              "line": 1,
              "column": 1,
              "index": 0
            },
            "end": {
              "line": 2,
              "column": 15,
              "index": 20
            }
          }
        }
      ],
      "loc": {
        "start": {
          "line": 3,
          "column": 1,
          "index": 21
        },
        "end": {
          "line": 3,
          "column": 27,
          "index": 47
        }
      }
    }
  ]
}

lucasterra avatar Jan 27 '20 14:01 lucasterra