glayzzle / php-parser

:herb: NodeJS PHP Parser - extract AST or tokens
https://php-parser.glayzzle.com/
BSD 3-Clause "New" or "Revised" License
534 stars 71 forks source link

Attribute parsing with string concatenation #1076

Closed NorthBlue333 closed 1 year ago

NorthBlue333 commented 1 year ago

Hello, The following syntax is correct but I get:

Error: Bad terminal sequence "." at line 30 (offset 995)
     at Lexer.matchST_ATTRIBUTE (/srv/app/node_modules/php-parser/src/lexer/attribute.js:80:11)
     at Lexer.next (/srv/app/node_modules/php-parser/src/lexer.js:511:26)
     at Lexer.lex (/srv/app/node_modules/php-parser/src/lexer.js:413:20)
     at Lexer.lex (/srv/app/node_modules/php-parser/src/lexer.js:413:35)
     at Parser.lex (/srv/app/node_modules/php-parser/src/parser.js:702:29)
     at Parser.next (/srv/app/node_modules/php-parser/src/parser.js:611:8)
     at Parser.read_array (/srv/app/node_modules/php-parser/src/parser/array.js:29:14)
     at Parser.read_dereferencable_scalar (/srv/app/node_modules/php-parser/src/parser/scalar.js:193:23)
     at Parser.read_scalar (/srv/app/node_modules/php-parser/src/parser/scalar.js:284:23)
     at Parser.read_expr_item (/srv/app/node_modules/php-parser/src/parser/expr.js:540:19)
#[ApiFilter(
            SearchFilter::class,
            strategy: 'i' . SearchFilter::STRATEGY_PARTIAL
        ) ]

It seems to be fixed by adding a . to the switch case of lexer/attribute.js, line 46.

czosel commented 1 year ago

Hi @NorthBlue333, thanks for the bug report! Would you like to send a PR?

NorthBlue333 commented 1 year ago

Just did one!