Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
php-src/sapi/phpdbg/phpdbg_parser.y at master · cebe/php-src · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
cebe
/
php-src
Public
forked from
php/php-src
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Files
Expand file tree
master
Breadcrumbs
php-src
/
sapi
/
phpdbg
/
phpdbg_parser.y
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
185 lines (162 loc) · 3.95 KB
master
Breadcrumbs
php-src
/
sapi
/
phpdbg
/
phpdbg_parser.y
Copy path
Top
File metadata and controls
Code
Blame
185 lines (162 loc) · 3.95 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
%{
/*
* phpdbg_parser.y
* (from php-src root)
* flex sapi/phpdbg/dev/phpdbg_lexer.l
* bison sapi/phpdbg/dev/phpdbg_parser.y
*/
#
include
"
phpdbg.h
"
#
include
"
phpdbg_cmd.h
"
#
include
"
phpdbg_utils.h
"
#
include
"
phpdbg_cmd.h
"
#
include
"
phpdbg_prompt.h
"
#
define
YYSTYPE
phpdbg_param_t
#
include
"
phpdbg_parser.h
"
#
include
"
phpdbg_lexer.h
"
#
undef
yyerror
static
int
yyerror
(
const
char
*msg);
ZEND_EXTERN_MODULE_GLOBALS
(phpdbg);
%}
%pure-parser
%error-verbose
%code
requires
{
#
include
"
phpdbg.h
"
#
ifndef
YY_TYPEDEF_YY_SCANNER_T
#
define
YY_TYPEDEF_YY_SCANNER_T
typedef
void
*
yyscan_t
;
#
endif
}
%output
"
sapi/phpdbg/phpdbg_parser.c
"
%defines
"sapi/phpdbg/phpdbg_parser.h"
%token
T_EVAL
"
eval
"
%token
T_RUN
"
run
"
%token
T_SHELL
"
shell
"
%token
T_IF
"
if (condition)
"
%token
T_TRUTHY
"
truthy (true, on, yes or enabled)
"
%token
T_FALSY
"
falsy (false, off, no or disabled)
"
%token
T_STRING
"
string (some input, perhaps)
"
%token
T_COLON
"
: (colon)
"
%token
T_DCOLON
"
:: (double colon)
"
%token
T_POUND
"
# (pound sign)
"
%token
T_PROTO
"
protocol (file://)
"
%token
T_DIGITS
"
digits (numbers)
"
%token
T_LITERAL
"
literal (string)
"
%token
T_ADDR
"
address
"
%token
T_OPCODE
"
opcode
"
%token
T_ID
"
identifier (command or function name)
"
%token
T_INPUT
"
input (input string or data)
"
%token
T_UNEXPECTED
"
input
"
%token
T_REQ_ID
"
request id (-r %d)
"
%%
/*
Rules
*/
input
: parameters
| full_expression { phpdbg_stack_push(PHPDBG_G(parser_stack), &$1); }
|
/*
nothing
*/
;
parameters
: parameter { phpdbg_stack_push(PHPDBG_G(parser_stack), &$1); }
| parameters parameter { phpdbg_stack_push(PHPDBG_G(parser_stack), &$2); }
| parameters req_id { $$ = $1; }
;
parameter
: T_ID T_COLON T_DIGITS {
$$.type = FILE_PARAM;
$$.file.name = $2.str;
$$.file.line = $3.num;
}
| T_ID T_COLON T_POUND T_DIGITS {
$$.type = NUMERIC_FILE_PARAM;
$$.file.name = $1.str;
$$.file.line = $4.num;
}
| T_PROTO T_ID T_COLON T_DIGITS {
$$.type = FILE_PARAM;
$$.file.name = malloc($1.len + $2.len + 1);
if ($$.file.name) {
memcpy(&$$.file.name[0], $1.str, $1.len);
memcpy(&$$.file.name[$1.len], $2.str, $2.len);
$$.file.name[$1.len + $2.len] = '\0';
}
$$.file.line = $4.num;
}
| T_PROTO T_ID T_COLON T_POUND T_DIGITS {
$$.type = NUMERIC_FILE_PARAM;
$$.file.name = malloc($1.len + $2.len + 1);
if ($$.file.name) {
memcpy(&$$.file.name[0], $1.str, $1.len);
memcpy(&$$.file.name[$1.len], $2.str, $2.len);
$$.file.name[$1.len + $2.len] = '\0';
}
$$.file.line = $5.num;
}
| T_ID T_DCOLON T_ID {
$$.type = METHOD_PARAM;
$$.method.class = $1.str;
$$.method.name = $3.str;
}
| T_ID T_DCOLON T_ID T_POUND T_DIGITS {
$$.type = NUMERIC_METHOD_PARAM;
$$.method.class = $1.str;
$$.method.name = $3.str;
$$.num = $5.num;
}
| T_ID T_POUND T_DIGITS {
$$.type = NUMERIC_FUNCTION_PARAM;
$$.str = $1.str;
$$.len = $1.len;
$$.num = $3.num;
}
| T_IF T_INPUT {
$$.type = COND_PARAM;
$$.str = $2.str;
$$.len = $2.len;
}
| T_OPCODE { $$ = $1; }
| T_ADDR { $$ = $1; }
| T_LITERAL { $$ = $1; }
| T_TRUTHY { $$ = $1; }
| T_FALSY { $$ = $1; }
| T_DIGITS { $$ = $1; }
| T_ID { $$ = $1; }
;
req_id
: T_REQ_ID { PHPDBG_G(req_id) = $1.num; }
|
/*
empty
*/
;
full_expression
: T_EVAL req_id T_INPUT {
$$.type = EVAL_PARAM;
$$.str = $3.str;
$$.len = $3.len;
}
| T_SHELL req_id T_INPUT {
$$.type = SHELL_PARAM;
$$.str = $3.str;
$$.len = $3.len;
}
| T_RUN req_id {
$$.type = RUN_PARAM;
$$.len = 0;
}
| T_RUN req_id T_INPUT {
$$.type = RUN_PARAM;
$$.str = $3.str;
$$.len = $3.len;
}
;
%%
static
int
yyerror
(
const
char
*msg) {
phpdbg_error
(
"
command
"
,
"
type=
\"
parseerror
\"
msg=
\"
%s
\"
"
,
"
Parse Error: %s
"
, msg);
{
const
phpdbg_param_t
*top =
PHPDBG_G
(parser_stack);
while
(top) {
phpdbg_param_debug
(top,
"
-->
"
);
top = top->
next
;
}
}
return
0
;
}
int
phpdbg_do_parse
(
phpdbg_param_t
*stack,
char
*input) {
phpdbg_init_lexer
(stack, input);
return
yyparse
();
}
You can’t perform that action at this time.