8000 Lua scanner by Quintus · Pull Request #21 · rubychan/coderay · GitHub
[go: up one dir, main page]

Skip to content

Lua scanner #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Take unary - as part of the number rather than an operator.
Note Lua has no unary +.
  • Loading branch information
Quintus committed Apr 22, 2012
commit 9dc21e57ea0fbd1e7869405d206dc906aef1aee6
8 changes: 4 additions & 4 deletions lib/coderay/scanners/lua.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,12 @@ def handle_state_initial
@start_delim = match
@state = :string

# hex number ←|→ decimal number
elsif match = scan(/0x\h* \. \h+ (?:p[+\-]?\d+)? | \d*\.\d+ (?:e[+\-]?\d+)?/ix) # hexadecimal constants have no E power, decimal ones no P power
# ↓Prefix hex number ←|→ decimal number
elsif match = scan(/-? (?:0x\h* \. \h+ (?:p[+\-]?\d+)? | \d*\.\d+ (?:e[+\-]?\d+)?)/ix) # hexadecimal constants have no E power, decimal ones no P power
@encoder.text_token(match, :float)

# hex number ←|→ decimal number
elsif match = scan(/0x\h+ (?:p[+\-]?\d+)? | \d+ (?:e[+\-]?\d+)?/ix) # hexadecimal constants have no E power, decimal ones no P power
# ↓Prefix hex number ←|→ decimal number
elsif match = scan(/-? (?:0x\h+ (?:p[+\-]?\d+)? | \d+ (?:e[+\-]?\d+)?)/ix) # hexadecimal constants have no E power, decimal ones no P power
@encoder.text_token(match, :integer)

elsif match = scan(/[\+\-\*\/%^\#=~<>\(\)\[\]:;,] | \.(?!\d)/x)
Expand Down
0