Skip to content

Commit 60f859c

Browse files
committed
fixing typos; missing references; adding new entry point class
1 parent d01e407 commit 60f859c

File tree

4 files changed

+1237
-714
lines changed

4 files changed

+1237
-714
lines changed

resources/files/parser.php

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ public function getOutput(): array
132132
const PHQL_WHERE = 51;
133133
const PHQL_WITH = 50;
134134
const YYERRORSYMBOL = 80;
135-
const YYNOCODE = 135;
135+
const YYNOCODE = 135;
136+
const YYWILDCARD = 135; /* No %wildcard in this grammar; use YYNOCODE so the wildcard path never matches */
136137
const YYNRULE = 162;
137138
const YYNSTATE = 295;
138139
const YYSTACKDEPTH = 100;
@@ -1027,8 +1028,8 @@ public function getOutput(): array
10271028
'argument_list_or_null',
10281029
'argument_item',
10291030
];
1030-
var $yyTraceFILE = null;
1031-
var $yyTracePrompt = null;
1031+
public mixed $yyTraceFILE = null;
1032+
public string $yyTracePrompt = '';
10321033
static $yy_action = [
10331034
/* 0 */
10341035
50,
@@ -3393,17 +3394,15 @@ public function getOutput(): array
33933394
** Outputs:
33943395
** None.
33953396
*/
3396-
var /* int */
3397-
$yyerrcnt;
3397+
public int $yyerrcnt = -1;
33983398

33993399
/* For tracing shifts, the names of all terminals and nonterminals
34003400
** are required. The following table supplies these names */
3401-
var /* int */
3402-
$yyidx = -1;
3401+
public int $yyidx = -1;
34033402

34043403
/* For tracing reduce actions, the names of all rules are required.
34053404
*/
3406-
var $yystack = [];
3405+
public array $yystack = [];
34073406

34083407
/*
34093408
** This function returns the symbolic name associated with a token
@@ -3448,15 +3447,13 @@ public function phql_(
34483447
$this->YY_ACCEPT_ACTION = self::YYNSTATE + self::YYNRULE + 1;
34493448
$this->YY_ERROR_ACTION = self::YYNSTATE + self::YYNRULE;
34503449
}
3451-
$yytos = $this->yystack[$this->yyidx];
34523450

34533451
if ($this->yyTraceFILE) {
3454-
fprintf(
3455-
$this->yyTraceFILE,
3452+
fwrite($this->yyTraceFILE, sprintf(
34563453
"%sInput %s\n",
34573454
$this->yyTracePrompt,
3458-
self::$yyTokenName[$yytos->major]
3459-
);
3455+
self::$yyTokenName[$yymajor]
3456+
));
34603457
}
34613458

34623459
do {
@@ -3475,7 +3472,7 @@ public function phql_(
34753472
} else {
34763473
if ($yyact == $this->YY_ERROR_ACTION) {
34773474
if ($this->yyTraceFILE) {
3478-
fprintf($this->yyTraceFILE, "%sSyntax Error!\n", $this->yyTracePrompt);
3475+
fwrite($this->yyTraceFILE, sprintf("%sSyntax Error!\n", $this->yyTracePrompt));
34793476
}
34803477
if (self::YYERRORSYMBOL) {
34813478
/**
@@ -3504,12 +3501,11 @@ public function phql_(
35043501
$yymx = $this->yystack[$this->yyidx]->major;
35053502
if ($yymx == self::YYERRORSYMBOL || $yyerrorhit) {
35063503
if ($this->yyTraceFILE) {
3507-
fprintf(
3508-
$this->yyTraceFILE,
3504+
fwrite($this->yyTraceFILE, sprintf(
35093505
"%sDiscard input token %s\n",
35103506
$this->yyTracePrompt,
35113507
self::$yyTokenName[$yymajor]
3512-
);
3508+
));
35133509
}
35143510
$this->yy_destructor($yymajor, $yyminor);
35153511
$yymajor = self::YYNOCODE;
@@ -3619,7 +3615,7 @@ function phql_Trace($TraceFILE, $zTracePrompt = ''): void
36193615
private function yy_accept()
36203616
{
36213617
if ($this->yyTraceFILE) {
3622-
fprintf($this->yyTraceFILE, "%sAccept!\n", $this->yyTracePrompt);
3618+
fwrite($this->yyTraceFILE, sprintf("%sAccept!\n", $this->yyTracePrompt));
36233619
}
36243620
while ($this->yyidx >= 0) {
36253621
$this->yy_pop_parser_stack();
@@ -3826,16 +3822,29 @@ private function yy_find_shift_action($iLookAhead)
38263822
($iFallback = self::$yyFallback[$iLookAhead]) != 0
38273823
) {
38283824
if ($this->yyTraceFILE) {
3829-
fprintf(
3830-
$this->yyTraceFILE,
3825+
fwrite($this->yyTraceFILE, sprintf(
38313826
"%sFALLBACK %s => %s\n",
38323827
$this->yyTracePrompt,
38333828
self::$yyTokenName[$iLookAhead],
38343829
self::$yyTokenName[$iFallback]
3835-
);
3830+
));
38363831
}
38373832
return $this->yy_find_shift_action($iFallback);
38383833
}
3834+
{
3835+
$j = $i - $iLookAhead + self::YYWILDCARD;
3836+
if ($j >= 0 && $j < count(self::$yy_action) && self::$yy_lookahead[$j] == self::YYWILDCARD) {
3837+
if ($this->yyTraceFILE) {
3838+
fwrite($this->yyTraceFILE, sprintf(
3839+
"%sWILDCARD %s => %s\n",
3840+
$this->yyTracePrompt,
3841+
self::$yyTokenName[$iLookAhead],
3842+
self::$yyTokenName[self::YYWILDCARD]
3843+
));
3844+
}
3845+
return self::$yy_action[$j];
3846+
}
3847+
}
38393848
}
38403849
return self::$yy_default[$stateno];
38413850
}
@@ -3846,7 +3855,7 @@ private function yy_find_shift_action($iLookAhead)
38463855
private function yy_parse_failed(): void
38473856
{
38483857
if ($this->yyTraceFILE) {
3849-
fprintf($this->yyTraceFILE, "%sFail!\n", $this->yyTracePrompt);
3858+
fwrite($this->yyTraceFILE, sprintf("%sFail!\n", $this->yyTracePrompt));
38503859
}
38513860
while ($this->yyidx >= 0) {
38523861
$this->yy_pop_parser_stack();
@@ -3862,12 +3871,11 @@ private function yy_pop_parser_stack()
38623871
$yytos = $this->yystack[$this->yyidx];
38633872

38643873
if ($this->yyTraceFILE) {
3865-
fprintf(
3866-
$this->yyTraceFILE,
3874+
fwrite($this->yyTraceFILE, sprintf(
38673875
"%sPopping %s\n",
38683876
$this->yyTracePrompt,
3869-
self::$yyTokenName[$yytos->major],
3870-
);
3877+
self::$yyTokenName[$yytos->major]
3878+
));
38713879
}
38723880

38733881
$this->yy_destructor($yytos->major, $yytos->minor);
@@ -3887,12 +3895,11 @@ private function yy_reduce(int $yyruleno): void
38873895
{
38883896
$yygotominor = []; /* The LHS of the rule reduced */
38893897
if ($this->yyTraceFILE && isset(self::$yyRuleName[$yyruleno])) {
3890-
fprintf(
3891-
$this->yyTraceFILE,
3898+
fwrite($this->yyTraceFILE, sprintf(
38923899
"%sReduce [%s].\n",
38933900
$this->yyTracePrompt,
38943901
self::$yyRuleName[$yyruleno]
3895-
);
3902+
));
38963903
}
38973904

38983905
switch ($yyruleno) {
@@ -4801,13 +4808,13 @@ private function yy_shift(
48014808
$yytos->major = $yyMajor;
48024809
$yytos->minor = $yypMinor;
48034810
if ($this->yyTraceFILE) {
4804-
fprintf($this->yyTraceFILE, "%sShift %d\n", $this->yyTracePrompt, $yyNewState);
4805-
fprintf($this->yyTraceFILE, "%sStack:", $this->yyTracePrompt);
4811+
fwrite($this->yyTraceFILE, sprintf("%sShift %d\n", $this->yyTracePrompt, $yyNewState));
4812+
fwrite($this->yyTraceFILE, sprintf("%sStack:", $this->yyTracePrompt));
48064813
for ($i = 1; $i <= $this->yyidx; $i++) {
48074814
$ent = $this->yystack[$i];
4808-
fprintf($this->yyTraceFILE, " %s", self::$yyTokenName[$ent->major]);
4815+
fwrite($this->yyTraceFILE, sprintf(" %s", self::$yyTokenName[$ent->major]));
48094816
}
4810-
fprintf($this->yyTraceFILE, "\n");
4817+
fwrite($this->yyTraceFILE, "\n");
48114818
}
48124819
}
48134820

0 commit comments

Comments
 (0)