php-parser
Search…
Introduction
Overview
Demo
Changelog
Getting Started
Todo
Guides
Options
API
Parser
AST
Lexer
Powered By
GitBook
Options
When you call the parser you can pass options as following :
1
var
reader
=
require
(
'php-parser'
);
2
reader
.
parseCode
(
'<?php echo true;'
,
{
3
parser
:
{
4
debug
:
false
,
5
locations
:
false
,
6
extractDoc
:
false
,
7
suppressErrors
:
false
8
},
9
ast
:
{
10
withPositions
:
true
,
11
withSource
:
true
12
},
13
lexer
:
{
14
all_tokens
:
false
,
15
comment_tokens
:
false
,
16
mode_eval
:
false
,
17
asp_tags
:
false
,
18
short_tags
:
false
19
}
20
});
Copied!
Parser
debug : enables debug output, useful for handling parsing errors when extending the library.
locations : attach location nodes to AST -
see more details
extractDoc : extracting comments blocks -
see more details
suppressErrors: graceful parsing mode, when an error is raised it's ignored
see more details
Lexer
all_tokens : extract all tokens (same output as
token_get_all
function in PHP)
comment_tokens: extract also comments tokens (used when all_tokens is false)
mode_eval: ignoring open or close tags, the input is directly a PHP script
asp_tags: handles ASP like tags
<%
and
%>
short_tags : handle short opening tag
<?
Getting Started - Previous
Todo
Next - API
Parser
Last modified
3yr ago
Copy link
Contents
Parser
Lexer