eval: basic done
This commit is contained in:
parent
8619caa1b6
commit
3603776303
13
eval.c
13
eval.c
|
@ -3,6 +3,8 @@
|
||||||
#include "lexer.h"
|
#include "lexer.h"
|
||||||
#include "form.h"
|
#include "form.h"
|
||||||
|
|
||||||
|
// TODO: BLOCKQUOTE OL PROGRESS CODE TABLE
|
||||||
|
|
||||||
#define PAGE_WIDTH 80
|
#define PAGE_WIDTH 80
|
||||||
|
|
||||||
#define EXPAND_LIT(x) x, sizeof(x)
|
#define EXPAND_LIT(x) x, sizeof(x)
|
||||||
|
@ -45,8 +47,15 @@ void evaluate(Token* token){
|
||||||
printf(FC_nBOLD);
|
printf(FC_nBOLD);
|
||||||
break_line();
|
break_line();
|
||||||
}
|
}
|
||||||
|
else if (token->type == UL){
|
||||||
|
state.inList = 1;
|
||||||
|
}
|
||||||
|
else if (token->type == UL){
|
||||||
|
state.inList = 0;
|
||||||
|
}
|
||||||
else if (token->type == LI)
|
else if (token->type == LI)
|
||||||
{
|
{
|
||||||
|
break_line();
|
||||||
print_text(EXPAND_LIT("- "));
|
print_text(EXPAND_LIT("- "));
|
||||||
}
|
}
|
||||||
else if (token->type == END_LI)
|
else if (token->type == END_LI)
|
||||||
|
@ -92,6 +101,10 @@ void evaluate(Token* token){
|
||||||
printf(FC_nUDL);
|
printf(FC_nUDL);
|
||||||
print_text(EXPAND_LIT(" "));
|
print_text(EXPAND_LIT(" "));
|
||||||
}
|
}
|
||||||
|
else if (token->type == P)
|
||||||
|
{
|
||||||
|
if (!state.inList) break_line();
|
||||||
|
}
|
||||||
else if (token->type == END_P)
|
else if (token->type == END_P)
|
||||||
{
|
{
|
||||||
break_line();
|
break_line();
|
||||||
|
|
1
eval.h
1
eval.h
|
@ -8,6 +8,7 @@ typedef struct PageState {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
int beginLine;
|
int beginLine;
|
||||||
|
int inList;
|
||||||
} PageState;
|
} PageState;
|
||||||
|
|
||||||
void evaluate(Token* token);
|
void evaluate(Token* token);
|
||||||
|
|
2
lexer.c
2
lexer.c
|
@ -245,6 +245,8 @@ TokenType token_by_name(const char name[HTML_BALISE_LEN]){
|
||||||
return HR;
|
return HR;
|
||||||
} else if (strncmp(name, "br", HTML_BALISE_LEN) == 0){
|
} else if (strncmp(name, "br", HTML_BALISE_LEN) == 0){
|
||||||
return BR;
|
return BR;
|
||||||
|
} else if (strncmp(name, "p", HTML_BALISE_LEN) == 0){
|
||||||
|
return P;
|
||||||
} else if (strncmp(name, "/p", HTML_BALISE_LEN) == 0){
|
} else if (strncmp(name, "/p", HTML_BALISE_LEN) == 0){
|
||||||
return END_P;
|
return END_P;
|
||||||
} else if (strncmp(name, "a", HTML_BALISE_LEN) == 0){
|
} else if (strncmp(name, "a", HTML_BALISE_LEN) == 0){
|
||||||
|
|
2
lexer.h
2
lexer.h
|
@ -18,7 +18,7 @@ typedef enum TokenType {
|
||||||
IMG, END_IMG,
|
IMG, END_IMG,
|
||||||
BLOCKQUOTE, END_BLOCKQUOTE,
|
BLOCKQUOTE, END_BLOCKQUOTE,
|
||||||
CODE, END_CODE,
|
CODE, END_CODE,
|
||||||
HR, BR, END_P,
|
HR, BR, P, END_P,
|
||||||
PROGRESS, END_PROGRESS,
|
PROGRESS, END_PROGRESS,
|
||||||
STRONG, B, I, EM,
|
STRONG, B, I, EM,
|
||||||
END_STRONG, END_B, END_I, END_EM,
|
END_STRONG, END_B, END_I, END_EM,
|
||||||
|
|
Loading…
Reference in New Issue