User:Ed Davis: Difference between revisions

Content added Content deleted
No edit summary
No edit summary
Line 3: Line 3:
----------------
----------------


From Wikipedia: (https://en.wikipedia.org/wiki/Lexical_analysis)
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
Line 15: Line 15:


;Specification
;Specification

{| class="wikitable"
|-
! Characters !! Regular expression !! Name
|-
| integers || [0-9]+ || Integer
|-
| char literal || 'x' || Integer
|-
| identifiers || [_a-zA-Z][_a-zA-Z0-9]+ || Ident
|-
| string literal || ".*" || String
|}


Notes: For char literals, '\n' is supported as a new line
character. To represent \, use: '\\'. \n may also be used in
Strings, to print a newline. No other special sequences are
supported.


operators:
operators:
Line 80: Line 61:
| ',' || comma || Comma
| ',' || comma || Comma
|}
|}

{| class="wikitable"
|-
! Characters !! Regular expression !! Name
|-
| integers || [0-9]+ || Integer
|-
| char literal || 'x' || Integer
|-
| identifiers || [_a-zA-Z][_a-zA-Z0-9]+ || Ident
|-
| string literal || ".*" || String
|}


Notes: For char literals, '\n' is supported as a new line
character. To represent \, use: '\\'. \n may also be used in
Strings, to print a newline. No other special sequences are
supported.



keywords:
keywords:
Line 122: Line 123:
------
------


{| class="wikitable"
line 4 col 1 Print
|-
line 4 col 6 Lparen
! Line !! Number !! Column !! Number !! Token name !! other data
line 4 col 7 String "Hello, World!\n"
|-
line 4 col 24 Rparen
line 4 col 25 Semi
| line || 4 || col || 1 Print ||
line 5 col 1 EOI
| line || 4 || col || 6 Lparen ||
| line || 4 || col || 7 String || "Hello, World!\n"
| line || 4 || col || 24 Rparen ||
| line || 4 || col || 25 Semi ||
| line || 5 || col || 1 EOI ||
|}


<lang c>
<lang c>