Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
18ec89bd
Commit
18ec89bd
authored
Feb 13, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More helper macros. Gonna' try to turn these string prefix matchers into a small, reusable library.
parent
d424389c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
test.c
src/parser/test.c
+3
-0
text_prefix_matchers.c
src/parser/text_prefix_matchers.c
+12
-2
No files found.
src/parser/test.c
View file @
18ec89bd
...
...
@@ -17,6 +17,8 @@ int main() {
}
unsigned
char
x
;
printf
(
"By the way, punctuation symbols are:
\n
"
);
for
(
x
=
'\0'
;
x
<
128
;
x
++
)
if
(
ispunct
(
x
))
printf
(
"%c"
,
x
);
putchar
(
'\n'
);
return
0
;
}
\ No newline at end of file
src/parser/text_prefix_matchers.c
View file @
18ec89bd
...
...
@@ -15,6 +15,10 @@ size_t text_starts_with_ ## type ## s(char *src) { \
return p; \
}
#define DEF_DELIMITED_PREFIX_MATCHER(name, begin, end, escapable) \
size_t text_starts_with_ ## name(char *src) { \
return text_has_delimited_prefix(src, begin, end, escapable); \
}
size_t
text_has_exact_prefix
(
char
*
src
,
char
*
pre
)
{
int
p
=
0
;
...
...
@@ -38,6 +42,10 @@ size_t text_has_delimited_prefix(char *src, char *beg, char *end, int esc) {
}
}
/*
These macro calls expand into function definitions. Their corresponding
signatures are in the comments.
*/
DEF_CTYPE_SEQUENCE_PREFIX_MATCHER
(
space
);
/* size_t text_starts_with_spaces(char *) */
DEF_CTYPE_SEQUENCE_PREFIX_MATCHER
(
alpha
);
/* size_t text_starts_with_alphas(char *) */
DEF_CTYPE_SEQUENCE_PREFIX_MATCHER
(
digit
);
/* size_t text_starts_with_digits(char *) */
...
...
@@ -60,9 +68,11 @@ size_t text_starts_with_line_comment(char *src) {
return
p
;
}
DEF_DELIMITED_PREFIX_MATCHER
(
dqstring
,
"
\"
"
,
"
\"
"
,
1
);
DEF_DELIMITED_PREFIX_MATCHER
(
sqstring
,
"'"
,
"'"
,
1
);
size_t
text_starts_with_string_constant
(
char
*
src
)
{
return
text_has_delimited_prefix
(
src
,
"
\"
"
,
"
\"
"
,
1
)
||
text_has_delimited_prefix
(
src
,
"'"
,
"'"
,
1
);
return
text_starts_with_dqstring
(
src
)
||
text_starts_with_sqstring
(
src
);
}
size_t
text_starts_with_interpolant
(
char
*
src
)
{
...
...
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