<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 4, 2015 at 7:06 PM, Knut Nesheim <span dir="ltr"><<a href="mailto:knutin@gmail.com" target="_blank">knutin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div id=":wv" class="" style="overflow:hidden">For my use case "select", "SELECT", "SeLeCt" means exactly the<br>
same.</div></blockquote></div><br>I'm not sure I understand this:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra"><div class="gmail_extra">[jlouis@lady-of-pain ~]$ cat z.xrl</div><div class="gmail_extra">%% Test</div><div class="gmail_extra"><br></div><div class="gmail_extra">Definitions.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Rules.</div><div class="gmail_extra"><br></div><div class="gmail_extra">[sS][eE][lL][eE][cC][tT] : {token, select}.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Erlang code.</div><div class="gmail_extra"><br></div><div class="gmail_extra">%% Nothing</div><div class="gmail_extra"><br></div><div class="gmail_extra">in an erl shell:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">4> leex:file("z").</div><div class="gmail_extra">{ok,"./z.erl"}</div><div><div>6> c("z.erl").</div><div>{ok,z}</div></div><div><div>9> [z:string(Str) || Str <- ["select", "SELECT", "SeLeCt"]].</div><div>[{ok,[select],1},{ok,[select],1},{ok,[select],1}]</div></div><div><br></div><div>Note how the token parses as the same thing.</div><div><br></div><div>[sS][eE][lL][eE][cC][tT] : {token, {identifier, string:to_lower(TokenChars)}}.<br></div></div></div><div><br></div><div>should also work, if select is not a keyword, but you want to handle it as an identifier.</div><div><br></div><div>some Regex engines provides convenience notation for [sS], [eE] etc, but it tends to be rare enough for keywords that you skip it. Another path through the game is the following age-old lexer hack:</div><div><br></div><div><div>[jlouis@lady-of-pain ~]$ cat y.xrl</div><div>%% Test</div><div><br></div><div>Definitions.</div><div><br></div><div>ALPHA = [a-zA-Z]</div><div><br></div><div>Rules.</div><div><br></div><div>{ALPHA}* : {token, analyze_alpha(string:to_lower(TokenChars))}.</div><div><br></div><div>Erlang code.</div><div><br></div><div>%% Match keywords, and if no keyword matches, regard the token as an identifier</div><div>analyze_alpha("select") -> select;</div><div>analyze_alpha(Otherwise) -> {identifier, Otherwise}.</div><div><br></div></div><div><div>13> leex:file("y"). </div><div>{ok,"./y.erl"}</div><div>14> c("y.erl"). </div><div>{ok,y}</div><div>15> [y:string(Str) || Str <- ["select", "SELECT", "SeLeCt"]].</div><div>[{ok,[select],1},{ok,[select],1},{ok,[select],1}]</div></div><div><br></div><div>Do any of these work for you?</div><div><br></div>-- <br><div class="gmail_signature">J.</div>
</div></div>