Skip to content

Instantly share code, notes, and snippets.

@rahul-sani
Last active February 5, 2020 04:42
Show Gist options
  • Save rahul-sani/5958583b13ae4c8164940b3a588dbdb2 to your computer and use it in GitHub Desktop.
Save rahul-sani/5958583b13ae4c8164940b3a588dbdb2 to your computer and use it in GitHub Desktop.
DIGIT= [0-9]
LETTER= [a-zA-Z]
%%
[\n] {System.out.println("NL ");}
"main" {System.out.println("Keywords ");}
"(" {System.out.println("Left paranthesis ");}
")" {System.out.println("Right paranthesis ");}
"var" {System.out.println("Keywords ");}
"{" {System.out.println("Left curly braces ");}
"}" {System.out.println("Right curly braces ");}
(integer|char|string|float)
{System.out.println("Datatypes ");}
{LETTER}({LETTER}|{DIGIT}*)
{System.out.println("Identifiers ");}
"=" {System.out.println("Assignment operator ");}
"input()" {System.out.println("Input Function ");}
"output()" {System.out.println("Output Function ");}
"\""({LETTER}+)"\"" {System.out.println("String ");}
"if" {System.out.println("IF ");}
" " {System.out.println("WhiteSpace ");}
"," {System.out.println("Coma ");}
";" {System.out.println("Semicolon ");}
(>|<|>=|<+|==|!=|"|"|&&) {System.out.println("Logical Operators ");}
("+"|"-"|"*"|"/"|"%") {System.out.println("Operators Arithmetic ");}
"then" {System.out.println("THEN ");}
"else" {System.out.println("ELSE ");}
"++" {System.out.println("Increment Operator ");}
"--" {System.out.println("Decrement Operator ");}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment