As I mentioned above when rule.regex is [a,b,c,undefined] then the last regex will probably be undefined (depend on the return value of the regex before it).  Both remove the trailing comma or add this check will prevent the issue.  If I remove this check we should make sure there are no trailing comma at any where https://github.com/NStal/swig/blob/master/lib/lexer.js#L76 in future.