| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,28 @@ | |||
| 1 | + tokens = { NAME, NUMBER, STRING } | ||
| 2 | + ignore = '\t ' | ||
| 3 | + literals = { '=', '+', '-', '/', | ||
| 4 | + '*', '(', ')', ',', ';'} | ||
| 5 | + | ||
| 6 | + | ||
| 7 | + # Define tokens as regular expressions | ||
| 8 | + # (stored as raw strings) | ||
| 9 | + NAME = r'[a-zA-Z_][a-zA-Z0-9_]*' | ||
| 10 | + STRING = r'\".*?\"' | ||
| 11 | + | ||
| 12 | + # Number token | ||
| 13 | + @_(r'\d+') | ||
| 14 | + def NUMBER(self, t): | ||
| 15 | + | ||
| 16 | + # convert it into a python integer | ||
| 17 | + t.value = int(t.value) return t | ||
| 18 | + | ||
| 19 | + # Comment token | ||
| 20 | + @_(r'//.*') | ||
| 21 | + def COMMENT(self, t): | ||
| 22 | + pass | ||
| 23 | + | ||
| 24 | + # Newline token(used only for showing | ||
| 25 | + # errors in new line) | ||
| 26 | + @_(r'\n+') | ||
| 27 | + def newline(self, t): | ||
| 28 | + self.lineno = t.value.count('\n') | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments