User:Ed Davis: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
From [https://en.wikipedia.org/wiki/Lexical_analysis Wikipedia] |
|||
Lexical analysis is the process of converting a sequence of characters (such as in a |
Lexical analysis is the process of converting a sequence of characters (such as in a |
||
computer program or web page) into a sequence of tokens (strings with an identified |
computer program or web page) into a sequence of tokens (strings with an identified |
||
Line 22: | Line 20: | ||
! Characters !! Common name !! Name |
! Characters !! Common name !! Name |
||
|- |
|- |
||
| |
| * || multiply || Mul |
||
|- |
|- |
||
| |
| / || divide || Div |
||
|- |
|- |
||
| |
| + || plus || Add |
||
|- |
|- |
||
| |
| - || minus and unary minus || Sub and Uminus |
||
|- |
|- |
||
| |
| < || less than || Lss |
||
|- |
|- |
||
| |
| <= || less than or equal || Leq |
||
|- |
|- |
||
| |
| > || greater than || Gtr |
||
|- |
|- |
||
| |
| != || not equal || Neq |
||
|- |
|- |
||
| |
| = || assign || Assign |
||
|- |
|- |
||
| |
| && || and || And |
||
|} |
|} |
||
Line 49: | Line 47: | ||
! Characters !! Common name !! Name |
! Characters !! Common name !! Name |
||
|- |
|- |
||
| |
| ( || left parenthesis || Lparen |
||
|- |
|- |
||
| |
| ) || right parenthesis || Rparen |
||
|- |
|- |
||
| |
| { || left brace || Lbrace |
||
|- |
|- |
||
| |
| } || right brace || Rbrace |
||
|- |
|- |
||
| |
| ; || semi colon || Semi |
||
|- |
|- |
||
| |
| , || comma || Comma |
||
|} |
|} |
||
Line 68: | Line 66: | ||
! Characters !! Name |
! Characters !! Name |
||
|- |
|- |
||
| |
| if || If |
||
|- |
|- |
||
| |
| while || While |
||
|- |
|- |
||
| |
| print || Print |
||
|- |
|- |
||
| |
| putc || Putc |
||
|} |
|} |
||
Line 105: | Line 103: | ||
;Program output |
;Program output |
||
Output of the program should be |
Output of the program should be: |
||
found token starts, followed by the Token name. For tokens |
|||
* the word line, followed by: |
|||
Integer, Ident and String, the Integer, identifier, or string |
|||
* the line number where the token starts, followed by: |
|||
should follow. |
|||
* the abbreviation col, followed by: |
|||
* the column number where the token starts, followed by: |
|||
* the token name. |
|||
* If the token name is one of Integer, Ident or String, the |
|||
actual value of the same should follow. |
|||
;Test Cases |
;Test Cases |
||
Line 184: | Line 187: | ||
* Unrecognized character. Example: | |
* Unrecognized character. Example: | |
||
;Reference |
|||
Refer additional questions to the C and Python implementations. |
|||
The C and Python versions can be considered reference implementations. |
|||
;Implementations |
|||
=={{header|C}}== |
=={{header|C}}== |