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
cd5a1d00
Commit
cd5a1d00
authored
Feb 15, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing a bug in my usage of va_args.
parent
16e32d31
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
25 deletions
+18
-25
prefix_primitives.c
src/parser/prefix_primitives.c
+6
-9
prefix_primitives.h
src/parser/prefix_primitives.h
+5
-3
test.c
src/parser/test.c
+7
-13
No files found.
src/parser/prefix_primitives.c
View file @
cd5a1d00
...
@@ -34,7 +34,7 @@ int prefix_is_delimited_by(char *src, char *beg, char *end, int esc) {
...
@@ -34,7 +34,7 @@ int prefix_is_delimited_by(char *src, char *beg, char *end, int esc) {
}
}
}
}
int
prefix_alternatives
(
char
*
src
,
...)
{
int
_
prefix_alternatives
(
char
*
src
,
...)
{
int
p
=
0
;
int
p
=
0
;
va_list
ap
;
va_list
ap
;
va_start
(
ap
,
src
);
va_start
(
ap
,
src
);
...
@@ -44,7 +44,7 @@ int prefix_alternatives(char *src, ...) {
...
@@ -44,7 +44,7 @@ int prefix_alternatives(char *src, ...) {
return
p
;
return
p
;
}
}
int
prefix_sequence
(
char
*
src
,
...)
{
int
_
prefix_sequence
(
char
*
src
,
...)
{
int
p
=
0
,
p_sum
=
0
;
int
p
=
0
,
p_sum
=
0
;
va_list
ap
;
va_list
ap
;
va_start
(
ap
,
src
);
va_start
(
ap
,
src
);
...
@@ -76,11 +76,8 @@ DEFINE_DELIMITED_MATCHER(block_comment, "/*", "*/", 0);
...
@@ -76,11 +76,8 @@ DEFINE_DELIMITED_MATCHER(block_comment, "/*", "*/", 0);
DEFINE_DELIMITED_MATCHER
(
double_quoted_string
,
"
\"
"
,
"
\"
"
,
1
);
DEFINE_DELIMITED_MATCHER
(
double_quoted_string
,
"
\"
"
,
"
\"
"
,
1
);
DEFINE_DELIMITED_MATCHER
(
single_quoted_string
,
"'"
,
"'"
,
1
);
DEFINE_DELIMITED_MATCHER
(
single_quoted_string
,
"'"
,
"'"
,
1
);
DEFINE_DELIMITED_MATCHER
(
interpolant
,
"#{"
,
"}"
,
0
);
DEFINE_DELIMITED_MATCHER
(
interpolant
,
"#{"
,
"}"
,
0
);
DEFINE_ALTERNATIVES_MATCHER
(
string
,
prefix_is_double_quoted_string
,
int
prefix_is_string
(
char
*
src
)
{
return
prefix_alternatives
(
src
,
prefix_is_double_quoted_string
,
prefix_is_single_quoted_string
);
prefix_is_single_quoted_string
);
}
DEFINE_EXACT_MATCHER
(
lparen
,
"("
);
DEFINE_EXACT_MATCHER
(
lparen
,
"("
);
DEFINE_EXACT_MATCHER
(
rparen
,
")"
);
DEFINE_EXACT_MATCHER
(
rparen
,
")"
);
...
@@ -129,7 +126,7 @@ DEFINE_ALTERNATIVES_MATCHER(identifier_initial, prefix_is_alphas, prefix_is_unde
...
@@ -129,7 +126,7 @@ DEFINE_ALTERNATIVES_MATCHER(identifier_initial, prefix_is_alphas, prefix_is_unde
DEFINE_ALTERNATIVES_MATCHER
(
identifier_trailing
,
prefix_is_alnums
,
prefix_is_underscore
);
DEFINE_ALTERNATIVES_MATCHER
(
identifier_trailing
,
prefix_is_alnums
,
prefix_is_underscore
);
DEFINE_FIRST_REST_MATCHER
(
identifier
,
prefix_is_identifier_initial
,
prefix_is_identifier_trailing
);
DEFINE_FIRST_REST_MATCHER
(
identifier
,
prefix_is_identifier_initial
,
prefix_is_identifier_trailing
);
// DEFINE_ALTERNATIVES_MATCHER(
DEFINE_SEQUENCE_MATCHER
(
hyphen_and_alpha
,
prefix_is_hyphen
,
prefix_is_alpha
);
// DEFINE_ALTERNATIVES_MATCHER(word_initial, prefix_is_identifier, prefix_is_hyphen_
);
DEFINE_ALTERNATIVES_MATCHER
(
word_initial
,
prefix_is_identifier
,
prefix_is_hyphen_and_alpha
);
DEFINE_ALTERNATIVES_MATCHER
(
word_trailing
,
prefix_is_alnums
,
prefix_is_
underscore
,
prefix_is_hyphen
);
DEFINE_ALTERNATIVES_MATCHER
(
word_trailing
,
prefix_is_alnums
,
prefix_is_
hyphen
,
prefix_is_underscore
);
DEFINE_FIRST_REST_MATCHER
(
word
,
prefix_is_word_initial
,
prefix_is_word_trailing
);
DEFINE_FIRST_REST_MATCHER
(
word
,
prefix_is_word_initial
,
prefix_is_word_trailing
);
src/parser/prefix_primitives.h
View file @
cd5a1d00
...
@@ -4,8 +4,10 @@ int prefix_is_exactly(char *, char*);
...
@@ -4,8 +4,10 @@ int prefix_is_exactly(char *, char*);
int
prefix_is_one_of
(
char
*
,
char
*
);
int
prefix_is_one_of
(
char
*
,
char
*
);
int
prefix_is_some_of
(
char
*
,
char
*
);
int
prefix_is_some_of
(
char
*
,
char
*
);
int
prefix_is_delimited_by
(
char
*
,
char
*
,
char
*
,
int
);
int
prefix_is_delimited_by
(
char
*
,
char
*
,
char
*
,
int
);
int
prefix_alternatives
(
char
*
,
...);
int
_prefix_alternatives
(
char
*
,
...);
int
prefix_sequence
(
char
*
,
...);
int
_prefix_sequence
(
char
*
,
...);
#define prefix_alternatives(src, ...) _prefix_alternatives(src, __VA_ARGS__, NULL)
#define prefix_sequence(src, ...) _prefix_sequence(src, __VA_ARGS__, NULL)
int
prefix_optional
(
char
*
,
prefix_matcher
);
int
prefix_optional
(
char
*
,
prefix_matcher
);
#define DECLARE_MATCHER(name) \
#define DECLARE_MATCHER(name) \
...
@@ -82,8 +84,8 @@ DECLARE_MATCHER(line_comment);
...
@@ -82,8 +84,8 @@ DECLARE_MATCHER(line_comment);
DECLARE_MATCHER
(
block_comment
);
DECLARE_MATCHER
(
block_comment
);
DECLARE_MATCHER
(
double_quoted_string
);
DECLARE_MATCHER
(
double_quoted_string
);
DECLARE_MATCHER
(
single_quoted_string
);
DECLARE_MATCHER
(
single_quoted_string
);
DECLARE_MATCHER
(
interpolant
);
DECLARE_MATCHER
(
string
);
DECLARE_MATCHER
(
string
);
DECLARE_MATCHER
(
interpolant
);
DECLARE_MATCHER
(
lparen
);
DECLARE_MATCHER
(
lparen
);
DECLARE_MATCHER
(
rparen
);
DECLARE_MATCHER
(
rparen
);
DECLARE_MATCHER
(
lbrack
);
DECLARE_MATCHER
(
lbrack
);
...
...
src/parser/test.c
View file @
cd5a1d00
...
@@ -23,23 +23,17 @@ int main() {
...
@@ -23,23 +23,17 @@ int main() {
char
*
x
=
"12nonidentifier_"
;
char
*
x
=
"12nonidentifier_"
;
char
*
y
=
"-blah-blah_blah"
;
char
*
y
=
"-blah-blah_blah"
;
int
(
*
funcs
[])(
char
*
)
=
{
prefix_is_string
,
prefix_is_block_comment
,
NULL
};
printn
(
s
,
prefix_is_string
(
s
));
printn
(
s
,
funcs
[
0
](
s
));
printn
(
s
,
prefix_is_one_of
(
s
,
"abcde+'"
));
printn
(
s
,
prefix_is_one_of
(
s
,
"abcde+'"
));
printn
(
s
,
prefix_is_some_of
(
s
,
"'abcdefghijklmnopqrstuvwxyz "
));
printn
(
s
,
prefix_is_some_of
(
s
,
"'abcdefghijklmnopqrstuvwxyz "
));
printn
(
t
,
funcs
[
1
]
(
t
));
printn
(
t
,
prefix_is_block_comment
(
t
));
printn
(
u
,
prefix_is_interpolant
(
u
));
printn
(
u
,
prefix_is_interpolant
(
u
));
printn
(
v
,
prefix_is_alphas
(
v
));
printn
(
v
,
prefix_is_alphas
(
v
));
printn
(
v
,
prefix_is_
one_
alpha
(
v
));
printn
(
v
,
prefix_is_alpha
(
v
));
printn
(
v
,
prefix_is_exactly
(
v
,
"hello"
));
printn
(
v
,
prefix_is_exactly
(
v
,
"hello"
));
printn
(
x
,
prefix_sequence
(
x
,
prefix_is_digits
,
prefix_is_alnums
));
{
printn
(
x
,
prefix_alternatives
(
x
,
prefix_is_hyphen
,
prefix_is_alphas
,
prefix_is_puncts
,
prefix_is_digits
));
int
hidden
=
42
;
//printn(y, prefix_is_word(y));
printf
(
"%d
\n
"
,
hidden
);
printf
(
"blah"
);
}
printf
(
"%s"
,
"Did this run?
\n
"
);
return
0
;
return
0
;
}
}
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