Created
February 24, 2016 21:24
-
-
Save SeijiEmery/63f9219cb6093550c98c to your computer and use it in GitHub Desktop.
full tokenizer regex for c-like languages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| matches + splits string, int, hex, and floating point literals, c-style identifiers, | |
| and greedily matches all symbols (differentiates between '+', '+=', '++'). | |
| Also includes two operators that I wish most languages _did_ have (you can remove these), | |
| ||= and &&=, which would codify/simplify the lua/js null check foo = x || default (foo ||= default) | |
| ('[^']*'|"[^"]*"|[_a-zA-Z][_a-zA-Z0-9]*|0x[a-fA-F\d]+|-?\d+(?:.\d+(?:[eE]\d+)?)?|//|/\*|\*/|\|\|=?|&&=?|\+\+|\-\-|\.\.|==|\->|[\+\-\*/%^\|&<>]=|[\?#\[\]\(\){}:;,\.\|&\+\-\*/%^<>=]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment