Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
7bb73c58
Commit
7bb73c58
authored
Jul 13, 2020
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Slight polish while looking at #3360
parent
d2886e6a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
33 deletions
+27
-33
vcc_compile.c
lib/libvcc/vcc_compile.c
+4
-9
vcc_compile.h
lib/libvcc/vcc_compile.h
+2
-5
vcc_token.c
lib/libvcc/vcc_token.c
+21
-19
No files found.
lib/libvcc/vcc_compile.c
View file @
7bb73c58
...
...
@@ -251,7 +251,7 @@ EmitCoordinates(const struct vcc *tl, struct vsb *vsb)
{
struct
token
*
t
;
unsigned
lin
,
pos
;
struct
source
*
sp
;
const
struct
source
*
sp
;
const
char
*
p
;
VSB_cat
(
vsb
,
"/* ---===### Source Code ###===---*/
\n
"
);
...
...
@@ -610,7 +610,7 @@ vcc_resolve_includes(struct vcc *tl)
VTAILQ_INSERT_TAIL
(
&
tl
->
sources
,
sp
,
list
);
sp
->
idx
=
tl
->
nsources
++
;
tl
->
t
=
t2
;
vcc_Lexer
(
tl
,
sp
);
vcc_Lexer
(
tl
,
sp
,
0
);
VTAILQ_REMOVE
(
&
tl
->
tokens
,
t
,
list
);
VTAILQ_REMOVE
(
&
tl
->
tokens
,
t1
,
list
);
...
...
@@ -654,7 +654,7 @@ vcc_CompileSource(struct vcc *tl, struct source *sp, const char *jfile)
/* Register and lex the main source */
VTAILQ_INSERT_TAIL
(
&
tl
->
sources
,
sp
,
list
);
sp
->
idx
=
tl
->
nsources
++
;
vcc_Lexer
(
tl
,
sp
);
vcc_Lexer
(
tl
,
sp
,
0
);
if
(
tl
->
err
)
return
(
NULL
);
...
...
@@ -663,12 +663,7 @@ vcc_CompileSource(struct vcc *tl, struct source *sp, const char *jfile)
assert
(
sp
!=
NULL
);
VTAILQ_INSERT_TAIL
(
&
tl
->
sources
,
sp
,
list
);
sp
->
idx
=
tl
->
nsources
++
;
vcc_Lexer
(
tl
,
sp
);
if
(
tl
->
err
)
return
(
NULL
);
/* Add "END OF INPUT" token */
vcc_AddToken
(
tl
,
EOI
,
sp
->
e
,
sp
->
e
);
vcc_Lexer
(
tl
,
sp
,
1
);
if
(
tl
->
err
)
return
(
NULL
);
...
...
lib/libvcc/vcc_compile.h
View file @
7bb73c58
...
...
@@ -91,7 +91,7 @@ struct token {
unsigned
tok
;
const
char
*
b
;
const
char
*
e
;
struct
source
*
src
;
const
struct
source
*
src
;
VTAILQ_ENTRY
(
token
)
list
;
unsigned
cnt
;
char
*
dec
;
...
...
@@ -249,7 +249,6 @@ struct vcc {
struct
tokenhead
tokens
;
VTAILQ_HEAD
(,
source
)
sources
;
unsigned
nsources
;
struct
source
*
src
;
struct
token
*
t
;
int
indent
;
int
hindent
;
...
...
@@ -404,12 +403,10 @@ void vcc_Warn(struct vcc *);
void
vcc__Expect
(
struct
vcc
*
tl
,
unsigned
tok
,
unsigned
line
);
int
vcc_IdIs
(
const
struct
token
*
t
,
const
char
*
p
);
void
vcc_ExpectVid
(
struct
vcc
*
tl
,
const
char
*
what
);
void
vcc_Lexer
(
struct
vcc
*
tl
,
struct
source
*
sp
);
void
vcc_Lexer
(
struct
vcc
*
tl
,
const
struct
source
*
sp
,
int
eoi
);
void
vcc_NextToken
(
struct
vcc
*
tl
);
void
vcc__ErrInternal
(
struct
vcc
*
tl
,
const
char
*
func
,
unsigned
line
);
void
vcc_AddToken
(
struct
vcc
*
tl
,
unsigned
tok
,
const
char
*
b
,
const
char
*
e
);
/* vcc_types.c */
vcc_type_t
VCC_Type
(
const
char
*
p
);
...
...
lib/libvcc/vcc_token.c
View file @
7bb73c58
...
...
@@ -362,8 +362,9 @@ vcc_decstr(struct vcc *tl)
* Add a token to the token list.
*/
void
vcc_AddToken
(
struct
vcc
*
tl
,
unsigned
tok
,
const
char
*
b
,
const
char
*
e
)
static
void
vcc_addtoken
(
struct
vcc
*
tl
,
unsigned
tok
,
const
struct
source
*
sp
,
const
char
*
b
,
const
char
*
e
)
{
struct
token
*
t
;
...
...
@@ -372,7 +373,7 @@ vcc_AddToken(struct vcc *tl, unsigned tok, const char *b, const char *e)
t
->
tok
=
tok
;
t
->
b
=
b
;
t
->
e
=
e
;
t
->
src
=
tl
->
src
;
t
->
src
=
sp
;
if
(
tl
->
t
!=
NULL
)
VTAILQ_INSERT_AFTER
(
&
tl
->
tokens
,
tl
->
t
,
t
,
list
);
else
...
...
@@ -385,12 +386,11 @@ vcc_AddToken(struct vcc *tl, unsigned tok, const char *b, const char *e)
*/
void
vcc_Lexer
(
struct
vcc
*
tl
,
struct
source
*
sp
)
vcc_Lexer
(
struct
vcc
*
tl
,
const
struct
source
*
sp
,
int
eoi
)
{
const
char
*
p
,
*
q
;
unsigned
u
;
tl
->
src
=
sp
;
for
(
p
=
sp
->
b
;
p
<
sp
->
e
;
)
{
/* Skip any whitespace */
...
...
@@ -412,9 +412,9 @@ vcc_Lexer(struct vcc *tl, struct source *sp)
if
(
*
q
==
'/'
&&
q
[
1
]
==
'*'
)
{
VSB_cat
(
tl
->
sb
,
"/* ... */ comment contains /*
\n
"
);
vcc_
AddToken
(
tl
,
EOI
,
p
,
p
+
2
);
vcc_
addtoken
(
tl
,
EOI
,
sp
,
p
,
p
+
2
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
vcc_
AddToken
(
tl
,
EOI
,
q
,
q
+
2
);
vcc_
addtoken
(
tl
,
EOI
,
sp
,
q
,
q
+
2
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
return
;
}
...
...
@@ -425,7 +425,7 @@ vcc_Lexer(struct vcc *tl, struct source *sp)
}
if
(
q
<
sp
->
e
)
continue
;
vcc_
AddToken
(
tl
,
EOI
,
p
,
p
+
2
);
vcc_
addtoken
(
tl
,
EOI
,
sp
,
p
,
p
+
2
);
VSB_cat
(
tl
->
sb
,
"Unterminated /* ... */ comment, starting at
\n
"
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
...
...
@@ -443,7 +443,7 @@ vcc_Lexer(struct vcc *tl, struct source *sp)
if
(
*
p
==
'C'
&&
p
[
1
]
==
'{'
)
{
for
(
q
=
p
+
2
;
q
<
sp
->
e
;
q
++
)
{
if
(
*
q
==
'}'
&&
q
[
1
]
==
'C'
)
{
vcc_
AddToken
(
tl
,
CSRC
,
p
,
q
+
2
);
vcc_
addtoken
(
tl
,
CSRC
,
sp
,
p
,
q
+
2
);
break
;
}
}
...
...
@@ -451,7 +451,7 @@ vcc_Lexer(struct vcc *tl, struct source *sp)
p
=
q
+
2
;
continue
;
}
vcc_
AddToken
(
tl
,
EOI
,
p
,
p
+
2
);
vcc_
addtoken
(
tl
,
EOI
,
sp
,
p
,
p
+
2
);
VSB_cat
(
tl
->
sb
,
"Unterminated inline C source, starting at
\n
"
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
...
...
@@ -462,7 +462,7 @@ vcc_Lexer(struct vcc *tl, struct source *sp)
if
(
*
p
==
'{'
&&
p
[
1
]
==
'"'
)
{
for
(
q
=
p
+
2
;
q
<
sp
->
e
;
q
++
)
{
if
(
*
q
==
'"'
&&
q
[
1
]
==
'}'
)
{
vcc_
AddToken
(
tl
,
CSTR
,
p
,
q
+
2
);
vcc_
addtoken
(
tl
,
CSTR
,
sp
,
p
,
q
+
2
);
break
;
}
}
...
...
@@ -476,7 +476,7 @@ vcc_Lexer(struct vcc *tl, struct source *sp)
tl
->
t
->
dec
[
u
]
=
'\0'
;
continue
;
}
vcc_
AddToken
(
tl
,
EOI
,
p
,
p
+
2
);
vcc_
addtoken
(
tl
,
EOI
,
sp
,
p
,
p
+
2
);
VSB_cat
(
tl
->
sb
,
"Unterminated long-string, starting at
\n
"
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
...
...
@@ -486,7 +486,7 @@ vcc_Lexer(struct vcc *tl, struct source *sp)
/* Match for the fixed tokens (see generate.py) */
u
=
vcl_fixed_token
(
p
,
&
q
);
if
(
u
!=
0
)
{
vcc_
AddToken
(
tl
,
u
,
p
,
q
);
vcc_
addtoken
(
tl
,
u
,
sp
,
p
,
q
);
p
=
q
;
continue
;
}
...
...
@@ -499,14 +499,14 @@ vcc_Lexer(struct vcc *tl, struct source *sp)
break
;
}
if
(
*
q
==
'\r'
||
*
q
==
'\n'
)
{
vcc_
AddToken
(
tl
,
EOI
,
p
,
q
);
vcc_
addtoken
(
tl
,
EOI
,
sp
,
p
,
q
);
VSB_cat
(
tl
->
sb
,
"Unterminated string at
\n
"
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
return
;
}
}
vcc_
AddToken
(
tl
,
CSTR
,
p
,
q
);
vcc_
addtoken
(
tl
,
CSTR
,
sp
,
p
,
q
);
if
(
vcc_decstr
(
tl
))
return
;
p
=
q
;
...
...
@@ -518,7 +518,7 @@ vcc_Lexer(struct vcc *tl, struct source *sp)
for
(
q
=
p
;
q
<
sp
->
e
;
q
++
)
if
(
!
vct_isident
(
*
q
))
break
;
vcc_
AddToken
(
tl
,
ID
,
p
,
q
);
vcc_
addtoken
(
tl
,
ID
,
sp
,
p
,
q
);
p
=
q
;
continue
;
}
...
...
@@ -529,20 +529,22 @@ vcc_Lexer(struct vcc *tl, struct source *sp)
if
(
!
vct_isdigit
(
*
q
))
break
;
if
(
*
q
!=
'.'
)
{
vcc_
AddToken
(
tl
,
CNUM
,
p
,
q
);
vcc_
addtoken
(
tl
,
CNUM
,
sp
,
p
,
q
);
p
=
q
;
continue
;
}
for
(
++
q
;
q
<
sp
->
e
;
q
++
)
if
(
!
vct_isdigit
(
*
q
))
break
;
vcc_
AddToken
(
tl
,
FNUM
,
p
,
q
);
vcc_
addtoken
(
tl
,
FNUM
,
sp
,
p
,
q
);
p
=
q
;
continue
;
}
vcc_
AddToken
(
tl
,
EOI
,
p
,
p
+
1
);
vcc_
addtoken
(
tl
,
EOI
,
sp
,
p
,
p
+
1
);
VSB_cat
(
tl
->
sb
,
"Syntax error at
\n
"
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
return
;
}
if
(
eoi
)
vcc_addtoken
(
tl
,
EOI
,
sp
,
sp
->
e
,
sp
->
e
);
}
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