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
7d0e4fb5
Commit
7d0e4fb5
authored
Feb 23, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some parsing stuff. Currently broken.
parent
0a07ffd1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
2 deletions
+76
-2
context.h
context.h
+5
-0
parser.c
parser.c
+40
-2
parser.h
parser.h
+31
-0
No files found.
context.h
View file @
7d0e4fb5
...
@@ -4,6 +4,11 @@
...
@@ -4,6 +4,11 @@
#define CONTEXT_HEADER
#define CONTEXT_HEADER
/*
Probably gonna' need to stratify this a bit more. A context object will store
the symbol table and any other necessary project-wide info. Each sass_document
struct will store src strings, line counts, etc.
*/
typedef
struct
{
typedef
struct
{
char
*
path
;
/* the full directory+filename of the source file */
char
*
path
;
/* the full directory+filename of the source file */
...
...
parser.c
View file @
7d0e4fb5
#include "parser.h"
#include <stdlib.h>
#include <stdlib.h>
#include "parser.h"
#include "prefix.h"
DEFINE_SASS_ARRAY_OF
(
sass_node_ptr
);
sass_token
sass_make_token
(
int
lexeme
,
char
*
beg
,
char
*
end
)
{
sass_token
t
;
t
.
lexeme
=
lexeme
;
t
.
beg
=
beg
;
t
.
end
=
end
;
return
t
;
}
int
sass_parse
(
sass_context
*
ctx
)
{
int
sass_parse
(
sass_context
*
ctx
)
{
sass_document
*
doc
=
(
sass_document
*
)
malloc
(
sizeof
(
sass_document
));
sass_document
*
doc
=
(
sass_document
*
)
malloc
(
sizeof
(
sass_document
));
doc
->
src
=
ctx
->
src
;
doc
->
src
=
ctx
->
src
;
return
0
;
return
0
;
}
}
sass_sass_node_ptr_array
sass_parse
(
sass_context
*
ctx
)
{
/* not sure how big of an array to allocate by default */
sass_sass_node_ptr_array
statements
=
sass_make_sass_node_ptr_array
(
16
);
while
(
ctx
->*
p
)
sass_sass_node_ptr_array_push
(
statements
,
sass_parse_statement
(
ctx
));
return
statements
;
}
static
sass_node_ptr
sass_parse_statement
(
sass_context
*
ctx
)
{
/* currently only handles rulesets; will expand to handle atkeywords */
return
sass_parse_ruleset
(
ctx
);
}
static
sass_node_ptr
sass_parse_ruleset
(
sass_context
*
ctx
)
{
sass_node_ptr
selector
=
sass_parse_selector
(
ctx
);
sass_node_ptr
declarations
=
sass_parse_declarations
(
ctx
);
return
sass_make_node
(
RULESET
,
selector
,
declarations
);
}
static
sass_node_ptr
sass_parse_selector
(
sass_context
*
ctx
)
{
/* will eventually need to be much more complicated */
char
*
lbrace
=
sass_prefix_find_first
(
ctx
->
pos
,
sass_prefix_is_lbrace
);
sass_node_ptr
node
=
sass_make_node
(
SELECTOR
);
node
->
token
=
sass_make_token
(
SELECTOR
,
pos
,
lbrace
);
ctx
->
pos
=
lbrace
;
return
node
;
}
\ No newline at end of file
parser.h
View file @
7d0e4fb5
...
@@ -2,5 +2,35 @@
...
@@ -2,5 +2,35 @@
#ifndef CONTEXT_HEADER
#ifndef CONTEXT_HEADER
#include "context.h"
#include "context.h"
#endif
#endif
#include "array.h"
enum
{
IDENT
,
ATKEYWORD
,
STRING
,
IDNAME
,
CLASSNAME
,
NUMBER
,
PERCENTAGE
,
DIMENSION
,
URI
,
SPACES
,
COMMENT
,
FUNCTION
,
EXACTMATCH
,
INCLUDES
,
DASHMATCH
,
PREFIXMATCH
,
SUFFIXMATCH
,
SUBSTRINGMATCH
};
typedef
struct
{
int
lexeme
;
char
*
beg
;
char
*
end
;
}
Token
;
#define sass_peek_token(src, lexeme) (sass_prefix_is_ ## lexeme(src))
int
sass_parse
(
sass_context
*
ctx
);
int
sass_parse
(
sass_context
*
ctx
);
\ No newline at end of file
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