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] bool
|
||||||
- [x] Lex keywords
|
- [x] Lex keywords
|
||||||
- [x] Ignore comments (//, /**/, #)
|
- [x] Ignore comments (//, /**/, #)
|
||||||
- [ ] Lex delimiters
|
- [x] Lex delimiters
|
||||||
- [x] ()
|
- [x] ()
|
||||||
- [x] {}
|
- [x] {}
|
||||||
- [x] .
|
- [x] .
|
||||||
- [x] :
|
- [x] :
|
||||||
- [x] ,
|
- [x] ,
|
||||||
- [ ] ==, =
|
- [x] ==, =
|
||||||
- [ ] >, >=
|
- [x] >, >=
|
||||||
- [ ] <, <=
|
- [x] <, <=
|
||||||
- [ ] !, !=
|
- [x] !, !=
|
||||||
- [ ] +, +=, ++
|
- [x] +, +=, ++
|
||||||
- [ ] -, -=, --
|
- [x] -, -=, --
|
||||||
- [ ] *, *=
|
- [x] *, *=
|
||||||
- [ ] /, /=
|
- [x] /, /=
|
||||||
- [ ] Lex types
|
- [ ] Lex types
|
||||||
- [x] Basic types (int, double, string, bool, char)
|
- [x] Basic types (int, double, string, bool, char)
|
||||||
- [ ] Advanced types (fun(...), template(...), object(...))
|
- [ ] Advanced types (fun(...), template(...), object(...))
|
||||||
|
|||||||
@@ -503,6 +503,44 @@ ResultType(voidptr, charptr) lex(SolsLexer* lexer) {
|
|||||||
break;
|
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
|
// '.' requires checking whether it's a number or an identifier after
|
||||||
case '.': {
|
case '.': {
|
||||||
ResultType(char, Nothing) peek = lexerPeek(lexer, 1);
|
ResultType(char, Nothing) peek = lexerPeek(lexer, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user