Commit 18c59ade by Hampton Catlin

ZOMG SO MUCH WORK DONE

parent f0e44dc2
...@@ -4,26 +4,33 @@ CFLAGS=-I. -Wall -g ...@@ -4,26 +4,33 @@ CFLAGS=-I. -Wall -g
BIN=bin/ BIN=bin/
sassc: sassc.o sassc: sassc.o
$(CC) $(CFLAGS) -o $(BIN)sassc sassc.o libsass.o context.o $(CC) $(CFLAGS) -o $(BIN)sassc sassc.o libsass.o context.o parser.o emitter.o transforms.o
sassc.o: libsass.o sassc.o: libsass.o
libsass.o: context.o libsass.o: context.o parser.o emitter.o transforms.o
bstr: bstr/bsafe.o bstr: bstr/bsafe.o
bstr/bsafe.o: bstr/bsafe.o:
build: prefix.o context.o exception.o build: prefix.o context.o exception.o parser.o
prefix.o: prefix.o:
context.o:
exception.o: exception.o:
context.o: tree.h
parser.o: context.o
emitter.o: context.o
transforms.o: context.o
test: clean build sassc
./spec.rb spec/basic/
test_context: context.o test_context.o test_context: context.o test_context.o
$(CC) $(CFLAGS) -o $(BIN)test_context test_context.o context.o $(CC) $(CFLAGS) -o $(BIN)test_context test_context.o context.o
./$(BIN)test_context ./$(BIN)test_context
test_context.o: test_context.o:
clean: clean: clean_bin
rm -rf *.o rm -rf *.o
rm -rf sassc clean_bin:
\ No newline at end of file rm -rf bin/*
\ No newline at end of file
#include <setjmp.h> #include <setjmp.h>
#include <stdlib.h>
#include "tree.h"
#define CONTEXT_HEADER
typedef struct { typedef struct {
char *path; /* the full directory+filename of the source file */ char *path; /* the full directory+filename of the source file */
char *src; /* the text of the entire source file */ char *src; /* the text of the entire source file */
char *pos; /* keeps track of the parser/scanner's current position */ char *result; /* the final result, after all compiling */
size_t line; /* the number of the line currently being parsed/scanned */ char *pos; /* keeps track of the parser's current position */
jmp_buf env; /* the top of the exception-handling stack */ size_t line; /* the number of the line currently being parsed */
jmp_buf env; /* the top of the exception-handling stack */
sass_document *doc; /* the primary AST tree */
sass_document **imports; /* all imported files */
/* more to come */ /* more to come */
} sass_context; } sass_context;
......
#include "emitter.h"
int sass_emit(sass_context *ctx) {
ctx->result = ctx->doc->src;
return 0;
}
\ No newline at end of file
#ifndef CONTEXT_HEADER
#include "context.h"
#endif
int sass_emit(sass_context *ctx);
\ No newline at end of file
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include "exceptions.h" #include "exception.h"
raise(int code) { raise(int code) {
printf("Aborted with error code %d.", code); printf("Aborted with error code %d.", code);
......
#include "libsass.h" #include "libsass.h"
#include "emitter.h"
#include "transforms.h"
#include "parser.h"
char * sass_file_compile(char *filepath, int options) { char * sass_file_compile(char *filepath, int options) {
sass_context *ctx = sass_make_context_from_file(filepath); sass_context *ctx = sass_make_context_from_file(filepath);
...@@ -9,4 +12,11 @@ char * sass_file_compile(char *filepath, int options) { ...@@ -9,4 +12,11 @@ char * sass_file_compile(char *filepath, int options) {
char * sass_string_compile(char *input, int options) { char * sass_string_compile(char *input, int options) {
sass_context *ctx = sass_make_context_from_string(input); sass_context *ctx = sass_make_context_from_string(input);
return ctx->src; return ctx->src;
}
char * sass_compile(sass_context *ctx) {
sass_parse(ctx);
sass_transform(ctx);
sass_emit(ctx);
return ctx->result;
} }
\ No newline at end of file
#include "bstr/bstrlib.h" #include "bstr/bstrlib.h"
#include "context.h"
char * sass_file_compile(char *filepath, int options); char * sass_file_compile(char *filepath, int options);
char * sass_string_compile(char *input, int options); char * sass_string_compile(char *input, int options);
#include "parser.h"
#include <stdlib.h>
int sass_parse(sass_context *ctx) {
sass_document *doc = (sass_document*)malloc(sizeof(sass_document));
doc->src = ctx->src;
return 0;
}
\ No newline at end of file
#ifndef CONTEXT_HEADER
#include "context.h"
#endif
int sass_parse(sass_context *ctx);
\ No newline at end of file
#!/usr/bin/env ruby
searchpath = ARGV[0] searchpath = ARGV[0]
......
#include "transforms.h"
int sass_transform(sass_context *ctx) {
return 0;
}
\ No newline at end of file
#ifndef CONTEXT_HEADER
#include "context.h"
#endif
int sass_transform(sass_context *ctx);
\ No newline at end of file
typedef struct {
char *value;
} sass_expression;
typedef struct { typedef struct {
char *path; /* the full directory+filename of the source file */ char *value;
sass_ruleset *rules[]; } sass_selector;
} sass_document;
typedef struct { typedef struct {
sass_selector_group *selector; char *value; // Strip out the #{} nonsense
sass_ruleset *rules[]; int *indexes;
sass_declaration *declarations[]; sass_expression **expressions;
} sass_ruleset; } sass_property;
typedef struct { typedef struct {
sass_property *property; sass_property *property;
...@@ -17,19 +18,17 @@ typedef struct { ...@@ -17,19 +18,17 @@ typedef struct {
} sass_declaration; } sass_declaration;
typedef struct { typedef struct {
char *value; // Strip out the #{} nonsense sass_selector **selectors;
int indexes[];
sass_expression *expressions[];
} sass_property;
typedef struct {
sass_selector *selectors[];
} sass_selector_group; } sass_selector_group;
typedef struct { typedef struct {
char *value; sass_selector_group *selector;
} sass_selector; struct sass_ruleset **rules;
sass_declaration **declarations;
} sass_ruleset;
typedef struct { typedef struct {
char *value; char *path; /* the full directory+filename of the source file */
} sass_expression; char *src; /* CHEAAAAATTTTT */
\ No newline at end of file sass_ruleset **rules;
} sass_document;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment