Prolog lexer can't find the error
<p>I have a lexer that I am trying to build. I just want to know why it doesn't create the second list.</p>

<pre><code>%TokenList=[int, add, '(', int, a, ',', int, b, ')']. 


lexer([H|TokenList],Output,[Output|X2]):-
   lexer_test(H,Output),lexer(TokenList,Output,X2).

lexer_test(H,Output):-
   (
    H = '\'int\'' -&gt; Output = 'TYPE_INT'
    ;(H = '\'bool\'' -&gt; Output='TYPE_BOOL'
    ;(H = '\',\'' -&gt; Output='COMMA'
    ;(H = '\'=\'' -&gt; Output='ASSIGN'
    ;(H = '\'let\'' -&gt; Output='LET'
    ;(H = '\'in\'' -&gt; Output='LET_IN'
    ;(H = '\'if\'' -&gt; Output='COND_IF'
    ;(H = '\'then\'' -&gt; Output='COND_THEN'
    ;(H = '\'else\'' -&gt; Output='COND_ELSE'
    ;(H = '\'==\'' -&gt; Output='LOGIC_EQ'
    ;(H = '\'!=\'' -&gt; Output='LOGIC_NOT_EQ'
    ;(H = '\'&gt;\'' -&gt; Output='LOGIC_GT'
    ;(H = '\'&gt;=\'' -&gt; Output='LOGIC_GTEQ'
    ;(H = '\'+\'' -&gt; Output='ARITH_ADD'
    ;(H = '\'-\'' -&gt; Output='ARITH_SUB'
    ;(H = '\'(\'' -&gt; Output='OPEN_P'
    ;(H = '\')\'' -&gt; Output='CLOSE_P'
    ;(H = '\'0\'' -&gt; Output='INTEGER'
     ;(H = '\'1\'' -&gt; Output='INTEGER'
     ;(H = '\'2\'' -&gt; Output='INTEGER'
     ;(H = '\'3\'' -&gt; Output='INTEGER'
     ;(H = '\'4\'' -&gt; Output='INTEGER'
     ;(H = '\'5\'' -&gt; Output='INTEGER'
     ;(H = '\'6\'' -&gt; Output='INTEGER'
     ;(H = '\'7\'' -&gt; Output='INTEGER'
     ;(H = '\'8\'' -&gt; Output='INTEGER'
     ;(H = '\'9\'' -&gt; Output='INTEGER' 
    ;(Output='IDENTIFIER'
    )))))))))))))))))))))))))))).
</code></pre>

<p>Don't worry about the second function lexer_test. I can fix that. But I really don't know why I don't get an output list. And if I can make lexer/2 instead of lexer/3 that would be great. And if you could suggest some good reads to learn prolog please do let me know. Thanks.</p>