Commit 9e10f4e2 authored by Chris Müller's avatar Chris Müller
Browse files

add scanning core characters that are forming basic cherry grammar

parent 77bab142
......@@ -61,7 +61,8 @@ enum CyTOK {
TOK_FLOAT,
TOK_SYMBOL,
TOK_TRUE,
TOK_FALSE
TOK_FALSE,
TOK_QUOTE
};
......
......@@ -558,6 +558,12 @@ lex_symbol(struct CyContext* context)
return TOK_SYMBOL;
}
#define LEX_RETURN(tok) \
p = cry_utf8_next(p); \
context->src = p; \
return tok;
enum CyTOK
cy_lex(struct CyContext* context)
{
......@@ -579,19 +585,21 @@ cy_lex(struct CyContext* context)
switch(ch) {
case '\0':
return TOK_EOF;
case ';':
return lex_comment(context);
case '(':
return TOK_ROUNDLEFTBRACE;
LEX_RETURN(TOK_ROUNDLEFTBRACE);
case ')':
return TOK_ROUNDRIGHTBRACE;
LEX_RETURN(TOK_ROUNDRIGHTBRACE);
case '[':
return TOK_SQUARELEFTBRACE;
LEX_RETURN(TOK_SQUARELEFTBRACE);
case ']':
return TOK_SQUARERIGHTBRACE;
LEX_RETURN(TOK_SQUARERIGHTBRACE);
case '.':
return TOK_DOT;
case '0': case '1': case '2': case '3': case '4':
LEX_RETURN(TOK_DOT);
case '\'':
LEX_RETURN(TOK_QUOTE);
case ';':
return lex_comment(context);
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
return lex_number(context);
case '\\':
......
Supports Markdown
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