Parse some more operations
This commit is contained in:
18
README.md
18
README.md
@@ -17,20 +17,20 @@ bash build.c
|
||||
- [x] bool
|
||||
- [x] Lex keywords
|
||||
- [x] Ignore comments (//, /**/, #)
|
||||
- [ ] Lex delimiters
|
||||
- [x] Lex delimiters
|
||||
- [x] ()
|
||||
- [x] {}
|
||||
- [x] .
|
||||
- [x] :
|
||||
- [x] ,
|
||||
- [ ] ==, =
|
||||
- [ ] >, >=
|
||||
- [ ] <, <=
|
||||
- [ ] !, !=
|
||||
- [ ] +, +=, ++
|
||||
- [ ] -, -=, --
|
||||
- [ ] *, *=
|
||||
- [ ] /, /=
|
||||
- [x] ==, =
|
||||
- [x] >, >=
|
||||
- [x] <, <=
|
||||
- [x] !, !=
|
||||
- [x] +, +=, ++
|
||||
- [x] -, -=, --
|
||||
- [x] *, *=
|
||||
- [x] /, /=
|
||||
- [ ] Lex types
|
||||
- [x] Basic types (int, double, string, bool, char)
|
||||
- [ ] Advanced types (fun(...), template(...), object(...))
|
||||
|
||||
@@ -503,6 +503,44 @@ ResultType(voidptr, charptr) lex(SolsLexer* lexer) {
|
||||
break;
|
||||
}
|
||||
|
||||
// These characters may be followed by an equals sign, or nothing else.
|
||||
case '=':
|
||||
case '!':
|
||||
case '>':
|
||||
case '<':
|
||||
case '*':
|
||||
case '/': {
|
||||
if (strcmp(buf.str, "") != 0) {
|
||||
ResultType(SolsToken, charptr) result = identifyToken(buf.str);
|
||||
if (result.error) {
|
||||
return Error(voidptr, charptr, createParsingError(lineNum, currentLine.str, result.as.error));
|
||||
}
|
||||
addTokenToSolsTokens(&lexer->output, result.as.success);
|
||||
DESTROY_ESTR(buf);
|
||||
buf = CREATE_ESTR("");
|
||||
}
|
||||
ResultType(char, Nothing) next = lexerPeek(lexer, 1);
|
||||
if (next.error || next.as.success != '=') {
|
||||
char tmp[] = {chr.as.success, '\0'};
|
||||
ResultType(SolsToken, charptr) result = identifyToken(tmp);
|
||||
if (result.error) {
|
||||
return Error(voidptr, charptr, createParsingError(lineNum, currentLine.str, result.as.error));
|
||||
}
|
||||
addTokenToSolsTokens(&lexer->output, result.as.success);
|
||||
}
|
||||
if (next.as.success == '=') {
|
||||
char tmp[] = {chr.as.success, '=', '\0'};
|
||||
ResultType(SolsToken, charptr) result = identifyToken(tmp);
|
||||
if (result.error) {
|
||||
return Error(voidptr, charptr, createParsingError(lineNum, currentLine.str, result.as.error));
|
||||
}
|
||||
addTokenToSolsTokens(&lexer->output, result.as.success);
|
||||
lexerConsume(lexer);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// '.' requires checking whether it's a number or an identifier after
|
||||
case '.': {
|
||||
ResultType(char, Nothing) peek = lexerPeek(lexer, 1);
|
||||
|
||||
Reference in New Issue
Block a user