TokenizationAndParsing - Tokenization and parsing We have...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Tokenization and parsing We have implemented a small calculator. We can enter an expression, the calculator prints the value of the expression. How does the calculator get from the expression (which is just a string) to the value? This process is a very simple version of what happens in interpreters or compilers for programming languages (e.g. the Javascript interpreter built into your web browser, the macro languages of Excel, Maple, or Matlab, or even the Java compiler itself). The process consists of three steps: lexical analysis , syntactic analysis and semantic analysis . Lexical analysis Lexical analysis ( tokenization ) splits the input text (a string or a text file) into minimal meaningful units. The minimal units are called tokens , and lexical analyzers are also called tokenizers . For our calculator we need three kinds of tokens: numbers (real numbers, such as 3, 71, 23 . 45), identifiers (variable names, like i , j , a123 ), operators ( + , - , * , / , · · · ) If the expression below is given to a tokenizer (abc12+27 * 23.0(12abc34 the result would be the following: symbol ( identifier abc12 symbol + number 27.0 symbol * number 23.0 symbol ( number 12.0 identifer abc34 The tokenizer does not know anything about the meaning or syntax of expressions. Even though the string
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern