Create a tokenizer in Ruby.
Your tokenizer will take two command line arguments: The first willbe a grammar specification and the second will be a file totokenize. Tokenize the file and print the tokens (symbol, lexeme,line) to the screen. If the file cannot be tokenized, print anerror message identifying the line with the error.
grammar specification file:
NUM -> d+
ADDOP -> [-+]
MULOP -> [*/]
LP -> (
RP -> )
EQ -> =
ID -> [A-Z]w*
comment -> {[^}]*}
S -> ID EQ expr
expr -> expr ADDOP term | term
term -> term MULOP factor | factor
factor -> ID | NUM | LP expr RP
eample file 1 to tokenize:
4+2 {
PayPal Gateway not configured
PayPal Gateway not configured