Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102739965
PhutilPHPCodeSnippetContextFreeGrammar.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Feb 23, 16:59
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Feb 25, 16:59 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24410276
Attached To
rPHU libphutil
PhutilPHPCodeSnippetContextFreeGrammar.php
View Options
<?php
final
class
PhutilPHPCodeSnippetContextFreeGrammar
extends
PhutilCLikeCodeSnippetContextFreeGrammar
{
protected
function
buildRuleSet
()
{
return
array_merge
(
parent
::
buildRuleSet
(),
$this
->
getClassRuleSets
());
}
protected
function
getStartGrammarSet
()
{
$start_grammar
=
parent
::
getStartGrammarSet
();
$start_grammar
[
'start'
][]
=
'[classdecl]'
;
$start_grammar
[
'start'
][]
=
'[classdecl]'
;
return
$start_grammar
;
}
protected
function
getExprGrammarSet
()
{
$expr
=
parent
::
getExprGrammarSet
();
$expr
[
'expr'
][]
=
'new [classname]([funccallparam])'
;
$expr
[
'expr'
][]
=
'[classname]::[funccall]'
;
return
$expr
;
}
protected
function
getVarNameGrammarSet
()
{
$varnames
=
parent
::
getVarNameGrammarSet
();
foreach
(
$varnames
as
$vn_key
=>
$vn_val
)
{
foreach
(
$vn_val
as
$vv_key
=>
$vv_value
)
{
$varnames
[
$vn_key
][
$vv_key
]
=
'$'
.
$vv_value
;
}
}
return
$varnames
;
}
protected
function
getFuncNameGrammarSet
()
{
return
$this
->
buildGrammarSet
(
'funcname'
,
array_mergev
(
get_defined_functions
()));
}
protected
function
getMethodCallGrammarSet
()
{
return
$this
->
buildGrammarSet
(
'methodcall'
,
array
(
'$this->[funccall]'
,
'self::[funccall]'
,
'static::[funccall]'
,
'[varname]->[funccall]'
,
'[classname]::[funccall]'
,
));
}
}
Event Timeline
Log In to Comment