Checking proper English sentences of user's input with grammar using C++
You could learn how to use bison. It designed specifically for this.

Boiler plate for flex/bison project:

Eng.l

%option c++

%{
#define IN_EXPR_LEXER
#include "EngYac.hpp"
%}

SpaceChar     [ \t]
Space         {SpaceChar}+
SpaceTerm     {SpaceChar}|&lt;&lt;EOF&gt;&gt;
FullStop      {SpaceChar}\.{SpaceTerm}

%%

and                     {return yy::parser::token::Conjunction;}
or                      {return yy::parser::token::Conjunction;}
but                     {return yy::parser::token::Conjunction;}

the                     {return yy::parser::token::Article;}

birds                   {return yy::parser::token::Noun;}
fish                    {return yy::parser::token::Noun;}
C\+\+                   {return yy::parser::token::Noun;}

rules                   {return yy::parser::token::Verb;}
fly                     {return yy::parser::token::Verb;}
swim                    {return yy::parser::token::Verb;}

{FullStop}              {return yy::parser::token::FullStop;}

{Space}                 {/*Ignore*/}
.                       {std::cerr &lt;&lt; "Error unknown character\n";}

%%

int yyFlexLexer::yywrap(void)
{
    return 1;
}


int yylex(int* /*type*/, yyFlexLexer&amp; lexer)
{
    return lexer.yylex();
}


Eng.y

%{
    #ifndef IN_EXPR_LEXER
    #include &lt;FlexLexer.h&gt;
    #endif
    int yylex(int* type, yyFlexLexer&amp; lexer);
%}
%skeleton "lalr1.cc"
%defines
%parse-param {yyFlexLexer&amp; lexer}
%lex-param   {yyFlexLexer&amp; lexer}

%token      Noun
%token      Verb
%token      Article
%token      Conjunction
%token      FullStop

%%
Input:      Sentence FullStop    

Sentence:   Noun Verb
        |   Article Noun Verb
        |   Sentence Conjunction Sentence


%%

void yy::parser::error(yy::location const&amp;, std::string const&amp; msg)
{
    std::cerr &lt;&lt; "Error: " &lt;&lt; msg &lt;&lt; "\n";
}


main.cpp

#include &lt;FlexLexer.h&gt;
#include "EngYac.hpp"

int main()
{
    yyFlexLexer     lexer(&amp;std::cin, &amp;std::cout);
    yy::parser      parser(lexer);

    std::cout &lt;&lt; (parser.parse() ? "FAIL" : "OK") &lt;&lt; "\n";
}


Makefile

FLEX_SRC    = $(wildcard *.l)
BISON_SRC   = $(wildcard *.y)
FLEX_CPP    = $(patsubst %.l, %Lex.cpp, $(FLEX_SRC))
BISON_CPP   = $(patsubst %.y, %Yac.cpp, $(BISON_SRC))

SRC         = $(filter-out $(BISON_CPP), $(filter-out $(FLEX_CPP), $(wildcard *.cpp))) $(FLEX_CPP) $(BISON_CPP)
OBJ         = $(patsubst %.cpp,%.o,$(SRC))


eng:       $(OBJ)
    g++ -o eng -O3 -Wall -Wextra -Werror $(OBJ)

clean:
    rm EngLex.cpp EngYac.cpp EngYac.hpp location.hh position.hh stack.hh $(OBJ) expr


$(OBJ): $(FLEX_CPP) $(BISON_CPP)

%Lex.cpp:       %.l
    flex -o $*Lex.cpp $^

%Yac.cpp:       %.y
    bison -o $*Yac.cpp $^


Usage:

&gt; make
&gt; echo "birds rules but fish swim." | ./eng

OK
&gt; echo "A test of English." | ./eng 
A test of English
Error: syntax error
FAIL