what does a token actually represent?

Please explain the below paragraph

"Typically with a lexer/parser a token is a structure that holds not only the name of the token, but the characters/symbols that make up the token and the start and end position of the string of characters that make up the token, with the start and end position being used for error reporting, highlighting, etc. a token will more likely hold the start and end position of the characters/symbols that represent the token and the lexeme, sequence of characters/symbols can be derived from the start and end position as needed because the input is static."

I am not able to get the understanding of the start and ending position which the token will hold ,plz clarify it.

Replies

  • ManojKiran Eda
    ManojKiran Eda
    radha gogia
    Please explain the below paragraph

    "Typically with a lexer/parser a token is a structure that holds not only the name of the token, but the characters/symbols that make up the token and the start and end position of the string of characters that make up the token, with the start and end position being used for error reporting, highlighting, etc. a token will more likely hold the start and end position of the characters/symbols that represent the token and the lexeme, sequence of characters/symbols can be derived from the start and end position as needed because the input is static."

    I am not able to get the understanding of the start and ending position which the token will hold ,plz clarify it.
    Actually I know that a token is a small part of a program that may be a variable or a constant....But after reading the above mentioned paragraph I am actually confused tooo...
  • rahul69
    rahul69
    MANOJ KIRAN
    Actually I know that a token is a small part of a program that may be a variable or a constant....But after reading the above mentioned paragraph I am actually confused tooo...
    In the original post, Info given about token is in context to lexical analyzer.
    Simply put, when data is fed to lex, it is just strings of characters, eg:
    a=b+c
    Then it will divide it into tokens:
    {a,=,b,+,c}
    This is just an analogy for understanding,(not the original process), but hope it clear some doubts. 😀

You are reading an archived discussion.

Related Posts

Instrument used to measure temperatures about 1000degree Celsius (in engine etc) ?
After a well-documented and a highly ridiculed launch of the new Macbook because of its lone USB port, the latest Macbook has given us one more reason to get laughed...
Fashionove.com is a Fashion & Apparel Company founded by Sharad Kumar and Tanushree Khandelwal in the year 2014. Fashionove aims to provide a holistic service of fashion information and reviews...
I had read somewhere that energy obtained due to the droping hammer is double to that of potential energy..can any1 explain with mathematical model??
When the big guns in the industry who have worked at Timex and Nike collaborate with a company, the product that they create is one of finesse. Here's a brand...