<div dir="ltr">Hello,<div>I'm developing the transpiler for an IoT oriented DSL to Erlang.</div><div>The idea is to take a domain specific language in input and create the erlang source code in output.</div><div>In my erlang project, I'm using the venerable Leex and Yecc tools to build the lexer and parser.</div><div>Using Erlang/OTP 22 [erts-10.5.2], so far, so good.</div><div><br></div><div>Today I was trying to define a UUID data type in the DSL language using the following definition in the leex <font face="monospace">.xlr</font> file:</div><div><font face="monospace"><br></font></div><div><font face="monospace">UUID = [0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}</font><br></div><div><br></div><div>and the corresponding rule:</div><div><font face="monospace">{UUID}       : {token, {uuid, TokenChars, TokenLine}}.</font></div><div><br></div><div>in the same file there is also the definition for an atom type:</div><div><font face="monospace"><br></font></div><div><font face="monospace">ATOM = [a-zA-Z0-9_]*</font><br></div><div><br></div><div>with the rule</div><div><font face="monospace">{ATOM}       : {token, {atom, list_to_atom(TokenChars), TokenLine}}.</font><br></div><div><br></div><div>I found that the generated lexer cannot match this UUID </div><div><font face="monospace">3eeb8daf-4e66-4c02-bb28-68934157e36e</font> in input, </div><div><br></div><div>but it matches the following tokens sequence:</div><div><font face="monospace">{atom,'3eeb8daf',25},{minus,25},{atom,'4e66',25},{minus,25},{atom,'4c02',25},{minus,25},{atom,bb28,25},{minus,25},{atom,'68934157e36e',25}<br></font></div><div><br></div><div>The minus token is present because I'm implementing also unary and arithmetic expressions.</div><div><br></div><div>I tested my definition with re:</div><div><font face="monospace">7> re:run("3eeb8daf-4e66-4c02-bb28-68934157e36e", "[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}", [{capture,all,list},unicode]).          <br>{match,["3eeb8daf-4e66-4c02-bb28-68934157e36e"]}</font></div><div><font face="monospace"><br>8> re:run("3eeb8daf-4e66-4c02-bb28-68934157e36e", "[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}", [{capture,first,list},unicode]).<br>{match,["3eeb8daf-4e66-4c02-bb28-68934157e36e"]}<br></font></div><div><br></div><div>so I guess that at least the definition should be right. </div><div><br></div><div>My workaround is to include the UUIDs in the source code between double quotes and then parsing UUIDs as strings, but I'm still wondering if I'm doing something wrong.</div><div><br></div><div>Thanks,</div><div>Massimo</div></div>