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

Parsing failed

Open Liang2580 opened this issue 1 year ago • 2 comments

PHP Version

5.6

data:=`<?php assert($_GET[1]);/*`

Parsing failed:

syntax error: unexpected '/' at line 1

Liang2580 avatar Jun 21 '23 06:06 Liang2580

	data:=`<?php assert($_GET[1]);/*`
	VerionInfo := version.Version{Major: 5, Minor: 6}
	var parserErrors []*errors.Error
	errorHandler := func(e *errors.Error) {
		parserErrors = append(parserErrors, e)
	}


	rootNode, err := parser.Parse([]byte(data), conf.Config{
		Version:&VerionInfo         ,
		ErrorHandlerFunc: errorHandler,
	})
	if err != nil {
		return
	}
	if len(parserErrors) > 0 {
		fmt.Println(parserErrors)
		
		return
	}
	
	o := bytes.NewBufferString("")
	goDumper := dumper.NewDumper(o).WithTokens().WithPositions()
	rootNode.Accept(goDumper)

It was found that an error occurred when parsing this code. Such format codes are supported in php5-php7

Liang2580 avatar Jun 21 '23 08:06 Liang2580

[root@localhost com]# cat 2.php 
<?php @eval($_GET[1]);/*
[root@localhost com]# 
[root@localhost com]# 
[root@localhost com]# php56 -l 2.php 
PHP Warning:  Unterminated comment starting line 1 in 2.php on line 1
Warning: Unterminated comment starting line 1 in 2.php on line 1
No syntax errors detected in 2.php

When using PHP - l, it can be found that it is OK Please support this grammar

Liang2580 avatar Jun 21 '23 08:06 Liang2580