Skip to content

Commit

Permalink
Add % to in ... solve and < / > / <> / >= / <= / = ops
Browse files Browse the repository at this point in the history
  • Loading branch information
Lartu committed Jun 29, 2024
1 parent 440c961 commit 5bb9d51
Show file tree
Hide file tree
Showing 3 changed files with 262 additions and 133 deletions.
39 changes: 37 additions & 2 deletions src/aux/aux_c_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// | TODO: comment and format this file properly |
// +---------------------------------------------+

#include "../ldpl.h"

// Given a full variable (with accesses and everything, like foo:0:'hi there' or
// bar) returns the C++ representation of said variable in order to be accessed.
string get_c_variable(compiler_state &state, string &variable)
Expand Down Expand Up @@ -103,9 +105,12 @@ string get_c_condition(compiler_state &state, vector<string> tokens,
string second_value;
string rel_op;
ct++; // We validate the token after we get the second value
if (tokens[ct] == "IS")
if (tokens[ct] == "IS" || tokens[ct] == "=" || tokens[ct] == "<>" || tokens[ct] == "<" || tokens[ct] == ">" || tokens[ct] == "<=" || tokens[ct] == ">=")
{
MATCH("IS");
if (tokens[ct] == "IS")
{
MATCH("IS");
}
if (tokens[ct] == "EQUAL")
{
MATCH("EQUAL");
Expand Down Expand Up @@ -155,6 +160,36 @@ string get_c_condition(compiler_state &state, vector<string> tokens,
rel_op = "LESS THAN";
}
}
else if (tokens[ct] == "<")
{
MATCH("<");
rel_op = "LESS THAN";
}
else if (tokens[ct] == "<=")
{
MATCH("<=");
rel_op = "LESS THAN OR EQUAL TO";
}
else if (tokens[ct] == ">")
{
MATCH(">");
rel_op = "GREATER THAN";
}
else if (tokens[ct] == ">=")
{
MATCH(">=");
rel_op = "GREATER THAN OR EQUAL TO";
}
else if (tokens[ct] == "=")
{
MATCH("=");
rel_op = "EQUAL TO";
}
else if (tokens[ct] == "<>")
{
MATCH("<>");
rel_op = "NOT EQUAL TO";
}
else
{
return "[ERROR]";
Expand Down
Loading

0 comments on commit 5bb9d51

Please sign in to comment.