Suppose I had a grammar like:
object
{ members }
members
pair
pair
string : value
value
number
string
string
" chars "
chars
char
char chars
number
digit
digit number
I could parse the following example: { "one" : 1234 }
As far as I understand, I should have the tokens object
, members
, pair
, value
, string
and chars
.
Tokenizing the example should produce
object
->members
->pair
->"one"
->"1234"
Parsing the tokens should produce
object
->pair
->"one"
->1234
It seems to me like the tokenizer is either useless or I don't fully understand what a it should do.
What is the responsibility of a tokenizer? What is the benefit of a tokenizer over parsing the original string?