am I doing the right thing here?
I am making a simple lexical analyzer and in the code below, I am trying to check if there is a valid "relational operator" in the input.
The code's parameters: input stream, the position of the current pointer, the success (initialized to zero).

it is supposed to return the 'x' position where it stopped checking and the 'success' equivalent, and the string/character.

My problem is, it did not showed that it was able to detect the valid "relational operator/s".

char* Lexical::validRelOp(wxString a, int* x, int* s)
{
  static char temp[100];

        if (a[*x]=='<' || a[*x]=='>' ||a[*x]=='!' ||a[*x]=='=')
        {
            *(x++);
            if (a[*x]=='=')
            {
                *(x++);
                if (isspace(a[*x]) || isalnum(a[*x])||isOperator(a[*x])==1 || isDelimiter(a[*x])==1)
                {
                    temp[0]=a[*x-2];
                    temp[1]=a[*x-1];
                    temp[2]='\0';

                    *s=1;
                    return temp;

                }
                else
                {
                    *s=3;
                    return 0;
                }
            }
            else if (isspace(a[*x]) || isalnum(a[*x]) || isOperator (a[*x]) || isDelimiter(a[*x]))
            {
                if (a[*(x-1)]=='<' || a[*(x-1)]=='>')
                {
                    temp[0]=a[*x-1];
                    temp[1]='\0';

                    *s=1;
                    return temp;

                }
                if (a[*(x-1)]=='=')
                {
                    temp[0]=a[*(x-1)];
                    temp[1]='\0';

                    *s=2;
                    return temp;
                }
            }
        }

        *s=0;
        return 0;
}

if (a[*x]=='<' || a[*x]=='>' ||a[*x]=='!' ||a[*x]=='=')

In the docs wxString just returns wxChar& and you compare it using the == operator. I'm not in linux now , see the helder or the docs of
wxChar and see whether it have a == operator or not, I'm giving you just an hint.can you see the docs and reply. This may be the
problem.
Edit: Sorry This should not be the problem cos wxChar is typedefed as char. So you can just use it. I'm currently at windows.

thanks for the reply, but I did not fully get your point.I have a code that almost looks like that but it is a working one.

if (a[*x]==':')
        {
            *(x++);
            if (a[*x]==':')
              {
                w[0]=a[*(x-1)];
                w[1]='\0';

                *s=1;
                return w;
            }
        }
This article has been dead for over six months. Start a new discussion instead.