Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
unique-xids
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
unique-xids
Commits
45af9764
Commit
45af9764
authored
Feb 11, 2013
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Discontinue words as fixed tokens ('if', 'else' etc) and use ID's instead.
Fixes #1259
parent
8a73d957
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
28 deletions
+36
-28
v00018.vtc
bin/varnishtest/tests/v00018.vtc
+4
-4
generate.py
lib/libvcl/generate.py
+0
-5
vcc_compile.c
lib/libvcl/vcc_compile.c
+1
-1
vcc_parse.c
lib/libvcl/vcc_parse.c
+31
-18
No files found.
bin/varnishtest/tests/v00018.vtc
View file @
45af9764
...
...
@@ -84,9 +84,9 @@ varnish v1 -errvcl {Only http header variables can be unset.} {
sub vcl_fetch { unset beresp.do_gzip; }
}
varnish v1 -errvcl {Unknown token '
if
' when looking for STRING} {
varnish v1 -errvcl {Unknown token '
<<
' when looking for STRING} {
backend b { .host = "127.0.0.1"; }
sub vcl_recv { ban (
if
); }
sub vcl_recv { ban (
<<
); }
}
varnish v1 -errvcl {Expected an action, 'if', '{' or '}'} {
...
...
@@ -104,7 +104,7 @@ varnish v1 -errvcl {Expected an action, 'if', '{' or '}'} {
sub vcl_recv { kluf ; }
}
varnish v1 -errvcl {Unknown token '
if
' when looking for STRING_LIST} {
varnish v1 -errvcl {Unknown token '
<<
' when looking for STRING_LIST} {
backend b { .host = "127.0.0.1"; }
sub vcl_error { synthetic
if
"foo"; }
sub vcl_error { synthetic
<<
"foo"; }
}
lib/libvcl/generate.py
View file @
45af9764
...
...
@@ -62,11 +62,6 @@ tokens = {
"T_MUL"
:
"*="
,
"T_DIV"
:
"/="
,
"T_NOMATCH"
:
"!~"
,
"T_INCLUDE"
:
"include"
,
"T_IF"
:
"if"
,
"T_ELSEIF"
:
"elseif"
,
"T_ELSIF"
:
"elsif"
,
"T_ELSE"
:
"else"
,
# Single char tokens, for convenience on one line
None
:
"{}()*+-/
%
><=;!&.|~,"
,
...
...
lib/libvcl/vcc_compile.c
View file @
45af9764
...
...
@@ -435,7 +435,7 @@ vcc_resolve_includes(struct vcc *tl)
struct
source
*
sp
;
VTAILQ_FOREACH
(
t
,
&
tl
->
tokens
,
list
)
{
if
(
t
->
tok
!=
T_INCLUDE
)
if
(
t
->
tok
!=
ID
||
!
vcc_IdIs
(
t
,
"include"
)
)
continue
;
t1
=
VTAILQ_NEXT
(
t
,
list
);
...
...
lib/libvcl/vcc_parse.c
View file @
45af9764
...
...
@@ -84,37 +84,48 @@ static void
vcc_IfStmt
(
struct
vcc
*
tl
)
{
SkipToken
(
tl
,
T_IF
);
SkipToken
(
tl
,
ID
);
Fb
(
tl
,
1
,
"if "
);
vcc_Conditional
(
tl
);
ERRCHK
(
tl
);
L
(
tl
,
vcc_Compound
(
tl
));
ERRCHK
(
tl
);
while
(
1
)
{
switch
(
tl
->
t
->
tok
)
{
case
T_ELSE
:
while
(
tl
->
t
->
tok
==
ID
)
{
if
(
vcc_IdIs
(
tl
->
t
,
"else"
))
{
vcc_NextToken
(
tl
);
if
(
tl
->
t
->
tok
!=
T_IF
)
{
if
(
tl
->
t
->
tok
==
'{'
)
{
Fb
(
tl
,
1
,
"else
\n
"
);
L
(
tl
,
vcc_Compound
(
tl
));
ERRCHK
(
tl
);
return
;
}
/* FALLTHROUGH */
case
T_ELSEIF
:
case
T_ELSIF
:
if
(
tl
->
t
->
tok
!=
ID
||
!
vcc_IdIs
(
tl
->
t
,
"if"
))
{
VSB_printf
(
tl
->
sb
,
"'else' must be followed by 'if' or '{'
\n
"
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
return
;
}
Fb
(
tl
,
1
,
"else if "
);
vcc_NextToken
(
tl
);
vcc_Conditional
(
tl
);
ERRCHK
(
tl
);
L
(
tl
,
vcc_Compound
(
tl
));
ERRCHK
(
tl
);
}
else
if
(
vcc_IdIs
(
tl
->
t
,
"elseif"
)
||
vcc_IdIs
(
tl
->
t
,
"elsif"
)
||
vcc_IdIs
(
tl
->
t
,
"elif"
))
{
Fb
(
tl
,
1
,
"else if "
);
vcc_NextToken
(
tl
);
vcc_Conditional
(
tl
);
ERRCHK
(
tl
);
L
(
tl
,
vcc_Compound
(
tl
));
ERRCHK
(
tl
);
}
else
{
break
;
default:
C
(
tl
,
";"
);
return
;
}
}
C
(
tl
,
";"
);
}
/*--------------------------------------------------------------------
...
...
@@ -144,9 +155,6 @@ vcc_Compound(struct vcc *tl)
case
'{'
:
vcc_Compound
(
tl
);
break
;
case
T_IF
:
vcc_IfStmt
(
tl
);
break
;
case
'}'
:
vcc_NextToken
(
tl
);
tl
->
indent
-=
INDENT
;
...
...
@@ -170,11 +178,16 @@ vcc_Compound(struct vcc *tl)
tl
->
err
=
1
;
return
;
case
ID
:
i
=
vcc_ParseAction
(
tl
);
ERRCHK
(
tl
);
if
(
i
)
{
SkipToken
(
tl
,
';'
);
if
(
vcc_IdIs
(
tl
->
t
,
"if"
))
{
vcc_IfStmt
(
tl
);
break
;
}
else
{
i
=
vcc_ParseAction
(
tl
);
ERRCHK
(
tl
);
if
(
i
)
{
SkipToken
(
tl
,
';'
);
break
;
}
}
/* FALLTHROUGH */
default:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment