summaryrefslogtreecommitdiff
path: root/lib/editor/ASMsyntaxhighlight.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/editor/ASMsyntaxhighlight.tcl')
-rw-r--r--[-rwxr-xr-x]lib/editor/ASMsyntaxhighlight.tcl302
1 files changed, 166 insertions, 136 deletions
diff --git a/lib/editor/ASMsyntaxhighlight.tcl b/lib/editor/ASMsyntaxhighlight.tcl
index fe364d5..1486201 100755..100644
--- a/lib/editor/ASMsyntaxhighlight.tcl
+++ b/lib/editor/ASMsyntaxhighlight.tcl
@@ -2,7 +2,7 @@
# Part of MCU 8051 IDE ( http://mcu8051ide.sf.net )
############################################################################
-# Copyright (C) 2007-2009 by Martin Ošmera #
+# Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 by Martin Ošmera #
# martin.osmera@gmail.com #
# #
# This program is free software; you can redistribute it and#or modify #
@@ -21,6 +21,11 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
############################################################################
+# >>> File inclusion guard
+if { ! [ info exists _ASMSYNTAXHIGHLIGHT_TCL ] } {
+set _ASMSYNTAXHIGHLIGHT_TCL _
+# <<< File inclusion guard
+
# --------------------------------------------------------------------------
# DESCRIPTION
# Implements syntax highlighting interface for assembly language
@@ -31,7 +36,7 @@ namespace eval ASMsyntaxHighlight {
# {
# {tag_name ?foreground? ?overstrike? ?italic? ?bold?}
# }
- variable hightlight_tags {
+ variable highlight_tags {
{tag_char #880066 0 0 0}
{tag_hex #8800BB 0 0 0}
{tag_oct #880000 0 0 0}
@@ -94,9 +99,9 @@ namespace eval ASMsyntaxHighlight {
# directives with argument(s) but without any label
variable directive_type1 {
- DSEG ISEG BSEG XSEG CSEG SKIP NAME
+ DSEG ISEG BSEG XSEG CSEG SKIP NAME LOCAL
}
- # directives for constants definitions
+ # directives for symbol definitions
variable directive_type2 {
EQU BIT SET CODE DATA IDATA XDATA MACRO FLAG
}
@@ -115,7 +120,7 @@ namespace eval ASMsyntaxHighlight {
variable expr_symbols {
= + - * / > < %
}
-
+
# control sequencies without any argument
variable controls_type0 {
NOLIST NOMOD NOOBJECT NOPAGING NOPRINT
@@ -185,26 +190,22 @@ namespace eval ASMsyntaxHighlight {
variable validation_L1 1 ;# Bool: Advancet validation enabled
## Define highlighting text tags in the given text widget
- # @parm Widget - ID of the target text widget
- # @parm Int - font size
- # @parm String - font family
- # @parm List = default - Highlighting tags definition
+ # @parm Widget text_widget - ID of the target text widget
+ # @parm Int fontSize - font size
+ # @parm String fontFamily - font family
+ # @parm List highlight=default - Highlighting tags definition
+ # @parm Bool nobold=0 - Ignore bold flag
# @return void
- proc create_tags args {
- variable hightlight_tags ;# Highlight tags definition
+ proc create_tags {text_widget fontSize fontFamily {highlight {}} {nobold 0}} {
+ variable highlight_tags ;# Highlight tags definition
# Handle arguments
- set text_widget [lindex $args 0] ;# text widget
- set fontSize [lindex $args 1] ;# font size
- set fontFamily [lindex $args 2] ;# font family
- if {[llength $args] > 3} { ;# highlighting definition
- set hightlight [lindex $args 3]
- } {
- set hightlight $hightlight_tags
+ if {$highlight == {}} { ;# highlighting definition
+ set highlight $highlight_tags
}
# Iterate over highlighting tags definition
- foreach item $hightlight {
+ foreach item $highlight {
# Create array of tag attributes
for {set i 0} {$i < 5} {incr i} {
set tag($i) [lindex $item $i]
@@ -217,13 +218,13 @@ namespace eval ASMsyntaxHighlight {
# Fonr slant
if {$tag(3) == 1} {
set tag(3) italic
- } {
+ } else {
set tag(3) roman
}
# Font weight
- if {$tag(4) == 1} {
+ if {$tag(4) == 1 && !$nobold} {
set tag(4) bold
- } {
+ } else {
set tag(4) normal
}
@@ -253,13 +254,13 @@ namespace eval ASMsyntaxHighlight {
}
## Perform syntax highlight on the given line in the given widget
- # @parm Widget Editor - Text widget
- # @parm Int LineNumber - Number of line to highlight
- # @parm Bool inline_asm - Inline assembler
- # @parm Int boundary_0 = 0 - Start index
- # @parm Int boundary_1 = end - End index
+ # @parm Widget p_editor - Text widget
+ # @parm Int linenumber - Number of line to highlight
+ # @parm Bool inlineasm - Inline assembler
+ # @parm Int linestart=0 - Start index
+ # @parm Int lineend=end - End index
# @return Bool - result
- proc highlight args {
+ proc highlight {p_editor linenumber {inlineasm 0} {linestart {}} {lineend {}}} {
variable editor ;# ID of the text widget
variable lineNumber ;# Number of current line
variable lineStart ;# Index of line start
@@ -282,27 +283,22 @@ namespace eval ASMsyntaxHighlight {
variable validation_L0 ;# Bool: Basic validation enabled
# Parse input arguments
- set editor [lindex $args 0]
- set lineNumber [lindex $args 1]
- set inline_asm [lindex $args 2]
- set lineStart [lindex $args 3]
- set lineEnd [lindex $args 4]
- if {$inline_asm == {}} {
- set inline_asm 0
- }
- if {$lineStart == {}} {
+ set editor $p_editor
+ set lineNumber $linenumber
+ set inline_asm $inlineasm
+ if {$linestart == {}} {
set lineStart $lineNumber.0
- } {
- set lineStart $lineNumber.$lineStart
+ } else {
+ set lineStart $lineNumber.$linestart
}
- if {$lineEnd == {}} {
- set lineEnd [$editor index "$lineStart lineend"]
- } {
+ if {$lineend == {}} {
+ set lineEnd [$editor index [list $lineStart lineend]]
+ } else {
set lineEnd $lineNumber.$lineEnd
}
- if {[lindex $args 3] != {}} {
- set start_offset [lindex $args 3]
- } {
+ if {$linestart != {}} {
+ set start_offset $linestart
+ } else {
set start_offset 0
}
@@ -339,7 +335,7 @@ namespace eval ASMsyntaxHighlight {
if {$comment_start == 0} {
set data {}
delete_tags
- } {
+ } else {
set data [string range $data 0 [expr {$comment_start - 1}]]
regsub {\s+$} $data {} data
}
@@ -358,7 +354,13 @@ namespace eval ASMsyntaxHighlight {
}
# Determinate 1st segment of the line
- regexp {^\s*[^\s:\(]+:?} $data seg_0
+ regexp {^\s*[^\s]+:?} $data seg_0
+ if {[regexp {\w\(} $seg_0]} {
+ regsub {\(.*$} $seg_0 {} seg_0
+ }
+ if {[string last {:} $seg_0] != -1} {
+ set seg_0 [string range $seg_0 0 [string last {:} $seg_0]]
+ }
set seg_0_end [string length $seg_0]
regsub {^\s+} $seg_0 {} seg_0
@@ -415,7 +417,7 @@ namespace eval ASMsyntaxHighlight {
if {![string length $seg_2]} {
put_error_on_segment 1
}
-
+
set seg_1 [string tolower $seg_1]
if {$seg_1 == {db} || $seg_1 == {.db} || $seg_1 == {byte} || $seg_1 == {.byte}} {
parse_operands
@@ -423,7 +425,7 @@ namespace eval ASMsyntaxHighlight {
$editor tag add tag_string \
$lineNumber.$seg_2_start \
[list $lineNumber.0 lineend]
- } {
+ } else {
parse_expressions
}
}
@@ -444,7 +446,7 @@ namespace eval ASMsyntaxHighlight {
if {
$validation_L0 &&
([regexp {^\d} $seg_1] || ![regexp {^\w+$} $seg_1])
- } {
+ } then {
put_error_on_segment 1
}
determinate_segment_2
@@ -464,7 +466,7 @@ namespace eval ASMsyntaxHighlight {
if {![string length $seg_2]} {
put_error_on_segment 0
}
-
+
set seg_0 [string tolower $seg_0]
if {$seg_0 == {db} || $seg_0 == {.db} || $seg_0 == {byte} || $seg_0 == {.byte}} {
parse_operands
@@ -472,7 +474,7 @@ namespace eval ASMsyntaxHighlight {
$editor tag add tag_string \
$lineNumber.$seg_2_start \
[list $lineNumber.0 lineend]
- } {
+ } else {
parse_expressions
}
}
@@ -494,6 +496,7 @@ namespace eval ASMsyntaxHighlight {
{unknown} {
determinate_segment_1
set seg_1_info [parse_segment $seg_1_start $seg_1_end $seg_1]
+
switch -- [lindex $seg_1_info 0] {
{control_0} {
determinate_segment_2
@@ -521,7 +524,7 @@ namespace eval ASMsyntaxHighlight {
$editor tag add tag_string \
$lineNumber.$seg_2_start \
[list $lineNumber.0 lineend]
- } {
+ } else {
parse_expressions
}
}
@@ -529,7 +532,7 @@ namespace eval ASMsyntaxHighlight {
if {
$validation_L0 &&
([regexp {^\d} $seg_0] || ![regexp {^\w+$} $seg_0])
- } {
+ } then {
put_error_on_segment 0
}
@@ -540,7 +543,7 @@ namespace eval ASMsyntaxHighlight {
$lineNumber.$seg_0_end
determinate_segment_2
parse_arguments
- } {
+ } else {
$editor tag add tag_constant_def \
$lineNumber.$seg_0_start \
$lineNumber.$seg_0_end
@@ -561,11 +564,12 @@ namespace eval ASMsyntaxHighlight {
}
{unknown} {
$editor tag add tag_macro $lineNumber.$seg_0_start $lineNumber.$seg_0_end
+
if {
$validation_L0 &&
([regexp {^\d} $seg_0] || ![regexp {^\w+$} $seg_0])
- } {
- put_error_on_segment 0
+ } then {
+ put_error_on_segment 0
}
determinate_segment_1_take_back
determinate_segment_2
@@ -576,7 +580,7 @@ namespace eval ASMsyntaxHighlight {
if {
$validation_L0 &&
([regexp {^\d} $seg_0] || ![regexp {^\w+$} $seg_0])
- } {
+ } then {
put_error_on_segment 0
}
}
@@ -592,7 +596,7 @@ namespace eval ASMsyntaxHighlight {
# @return void
proc delete_tags {} {
variable editor ;# ID of the text widget
- variable hightlight_tags ;# Highlight tags definition
+ variable highlight_tags ;# Highlight tags definition
variable lineStart ;# Index of line start
variable lineEnd ;# Index of line end
@@ -603,8 +607,8 @@ namespace eval ASMsyntaxHighlight {
$editor tag remove $tag $lineStart_truestart $lineStart_truestart+1l
}
- # Remove tags acording to pattern
- foreach tag $hightlight_tags {
+ # Remove tags according to pattern
+ foreach tag $highlight_tags {
$editor tag remove [lindex $tag 0] $lineStart_truestart $lineEnd
}
}
@@ -633,13 +637,14 @@ namespace eval ASMsyntaxHighlight {
variable last_index_backup ;# Auxiliary variable (some index)
# Line is empty
- if {![regexp {^\s*[^\s\(]+} $data seg_1]} {
+ # if {![regexp {^\s*[^\s\(]+} $data seg_1]}
+ if {![regexp {^\s*[^\s]+} $data seg_1]} {
set seg_1 {}
set seg_1_end $last_index
set seg_1_start $last_index
# Line is not empty
- } {
+ } else {
set data_backup $data
set last_index_backup $last_index
@@ -692,16 +697,17 @@ namespace eval ASMsyntaxHighlight {
# @parm String segment_data - content of segment to parse
# @return List - {segment_type expression_length} or {segment_type {}} or {{} {}}
proc parse_segment {start end segment_data} {
- variable controls_type0 ;# control sequencies without any argument
- variable controls_type1 ;# control sequencies with exactly 1 argument
+ variable controls_type0 ;# control sequencies without any argument
+ variable controls_type1 ;# control sequencies with exactly 1 argument
- variable keyword_lists ;# list of all reserved keywords
- variable editor ;# ID of the text widget
- variable lineNumber ;# Number of current line
- variable lineStart ;# Index of line start
- variable lineEnd ;# Index of line end
- variable data ;# Content of the line
- variable validation_L0 ;# Bool: Basic validation enabled
+ variable keyword_lists ;# list of all reserved keywords
+ variable editor ;# ID of the text widget
+ variable lineNumber ;# Number of current line
+ variable lineStart ;# Index of line start
+ variable lineEnd ;# Index of line end
+ variable data ;# Content of the line
+ variable validation_L0 ;# Bool: Basic validation enabled
+ variable inline_asm ;# Bool: Is inline assembler
# Local variables
set seg_type {} ;# segment type
@@ -729,7 +735,7 @@ namespace eval ASMsyntaxHighlight {
set seg_type $type
break
}
- } {
+ } else {
if {[lsearch -ascii -exact $keyword_list $segment_data] != -1} {
$editor tag add $tag $lineNumber.$start $lineNumber.$end
set seg_type $type
@@ -740,7 +746,6 @@ namespace eval ASMsyntaxHighlight {
# If segment type could not be recognized -> check for labels, macro's and controls
if {$seg_type == {}} {
-
# Handle compiler control sequences
if {[string index $segment_data 0] == {$}} {
set segment_data [string range $segment_data 1 end]
@@ -789,12 +794,22 @@ namespace eval ASMsyntaxHighlight {
}
# Labels
- } elseif {[regexp -nocase {^\w+:$} $segment_data]} {
+ } elseif {[regexp -nocase {^[^\s]*:$} $segment_data]} {
$editor tag add tag_label $lineNumber.$start $lineNumber.$end
set seg_type label
+ if {$inline_asm} {
+ if {![regexp -nocase {^\w+\$:$} $segment_data]} {
+ $editor tag add tag_error $lineNumber.$start $lineNumber.$end
+ }
+ } else {
+ if {![regexp -nocase {^[a-zA-Z]\w*:$} $segment_data]} {
+ $editor tag add tag_error $lineNumber.$start $lineNumber.$end
+ }
+ }
+
# Unknown type - possibly macro instruction
- } {
+ } else {
set seg_type unknown
}
}
@@ -817,9 +832,9 @@ namespace eval ASMsyntaxHighlight {
$editor tag add tag_symbol $lineNumber.$start_index $lineNumber.[expr {$start_index + 1}]
set end [expr {$end_index - 1}]
$editor tag add tag_symbol $lineNumber.$end $lineNumber.$end_index
-
+
$editor tag add tag_string $lineNumber.[expr {$start_index + 1}] $lineNumber.$end
- } {
+ } else {
if {$validation_L0} {
$editor tag add tag_error \
$lineNumber.$control_start $lineNumber.$control_end
@@ -840,7 +855,7 @@ namespace eval ASMsyntaxHighlight {
variable seg_0_end ;# End index of seg_0
variable seg_1_end ;# End index of seg_1
variable seg_2_end ;# End index of seg_2
-
+
if {!$validation_L0} {
return
}
@@ -876,9 +891,9 @@ namespace eval ASMsyntaxHighlight {
if {[regexp {^\s*$} $seg_2]} {return 0}
- while 1 {
+ while {1} {
# Handle redutant commas
- while 1 {
+ while {1} {
if {![regexp {^\s*\,} $seg_2]} {break}
set space_len 0
@@ -964,9 +979,9 @@ namespace eval ASMsyntaxHighlight {
set original_data $seg_2
set data [hide_strings $seg_2]
- while 1 {
+ while {1} {
# Handle redutant commas
- while 1 {
+ while {1} {
if {![regexp {^\s*\,} $data]} {break}
set space_len 0
@@ -1003,7 +1018,7 @@ namespace eval ASMsyntaxHighlight {
set space_len [string length $space]
set opr_start [expr {$last_index + $space_len}]
set operand [string range $operand $space_len end]
- } {
+ } else {
set opr_start $last_index
}
@@ -1012,7 +1027,7 @@ namespace eval ASMsyntaxHighlight {
set space_len [string length $space]
set opr_end [expr {$operand_len - $space_len}]
set operand [string range $operand 0 $opr_end]
- } {
+ } else {
set opr_end $operand_len
}
incr opr_end $last_index
@@ -1058,7 +1073,7 @@ namespace eval ASMsyntaxHighlight {
default {
if {[lsearch -ascii -exact {R0 R1 R2 R3 R4 R5 R6 R7 DPTR A AB C} $opr] != -1} {
lappend opr_types $opr
- } {
+ } else {
lappend opr_types {D}
}
}
@@ -1091,14 +1106,14 @@ namespace eval ASMsyntaxHighlight {
if {$validation_L0 && $len < 3} {
put_tag_on_operand tag_error
}
- if {$len > 3} {
+ if {$len > 3 && [string index $operand 1] != "\\"} {
put_tag_on_operand tag_string
- } {
+ } else {
put_tag_on_operand tag_imm_char
}
# Label in inline assembler
- } elseif {[regexp {^\d+\$$} $operand]} {
+ } elseif {[regexp {^\w+\$$} $operand]} {
put_tag_on_operand tag_imm_constant
# Operand has no value => incorrect operand
@@ -1108,10 +1123,10 @@ namespace eval ASMsyntaxHighlight {
$lineNumber.$opr_start $lineNumber.$opr_start+1c
} elseif {
- $validation_L0 &&
- ([string length $operand] == 0 || ![regexp {^[\w\$\.\\]+$} $operand])
- } {
- put_tag_on_operand tag_error
+ $validation_L0 &&
+ ([string length $operand] == 0 || ![regexp {^(\?\?)?[\w\$\.\\]+$} $operand])
+ } then {
+ put_tag_on_operand tag_error
# Operand value determinated successfully
} else {
@@ -1136,7 +1151,7 @@ namespace eval ASMsyntaxHighlight {
$operand != {DPTR} &&
$operand != {A+PC} &&
$operand != {A+DPTR}
- } {
+ } then {
put_tag_on_operand tag_error
}
@@ -1150,12 +1165,11 @@ namespace eval ASMsyntaxHighlight {
$lineNumber.$opr_start $lineNumber.$opr_start+1c
} elseif {
- $validation_L0 &&
- ([string length $operand] == 0 || ![regexp {^'?[\w\.]+'?$} $operand])
- } {
-
- # Operand has no value => incorrect operand
- put_tag_on_operand tag_error
+ $validation_L0 &&
+ ([string length $operand] == 0 || ![regexp {^'?[\w\.]+'?$} $operand])
+ } then {
+ # Operand has no value => incorrect operand
+ put_tag_on_operand tag_error
} else {
parse_operand_auxiliary $spec_bits {
@@ -1187,7 +1201,7 @@ namespace eval ASMsyntaxHighlight {
put_tag_on_operand tag_sfr
# Something else than SFR
- } {
+ } else {
parse_operand_auxiliary2 $tag_list
}
}
@@ -1206,9 +1220,9 @@ namespace eval ASMsyntaxHighlight {
variable inline_asm ;# Is inline assembler
# Label in inline assembler
- if {$inline_asm && [regexp {^\d+\$$} $operand]} {
+ if {$inline_asm && [regexp {^\w+\$$} $operand]} {
put_tag_on_operand [lindex $tag_list 6]
-
+
# Expression
} elseif {[regexp {\(|\)|\+|\-|\%|\=|\>|\<|\*|\/} $operand]} {
parse_expression $operand $opr_start $opr_end
@@ -1248,14 +1262,14 @@ namespace eval ASMsyntaxHighlight {
}
# Radix determinated correctly - continue normaly
- } {
+ } else {
# check for allowed operand value range
if {$validation_L0 && $opr_in_dec == {error}} {
## Operand value is invalid => incorrect operand
put_tag_on_operand tag_error
- } {
+ } else {
if {$validation_L0 && ($opr_in_dec > 65535 || $opr_in_dec < 0)} {
## Operand value is out of range => incorrect operand
@@ -1263,7 +1277,7 @@ namespace eval ASMsyntaxHighlight {
}
}
- # highlight acording to numeric base
+ # highlight according to numeric base
switch -- $opr_base {
{hex} {put_tag_on_operand [lindex $tag_list 1]}
{dec} {put_tag_on_operand [lindex $tag_list 2]}
@@ -1274,13 +1288,13 @@ namespace eval ASMsyntaxHighlight {
}
}
- # defined by a symbolic name
- } {
+ # Defined as a symbolic name
+ } else {
put_tag_on_operand [lindex $tag_list 6]
if {
- $validation_L0 && ($operand != {$}) && ![regexp {^\w+$} $operand]
- } {
- put_tag_on_operand tag_error
+ $validation_L0 && ($operand != {$}) && ![regexp {^(\?\?)?\w+$} $operand]
+ } then {
+ put_tag_on_operand tag_error
}
}
}
@@ -1302,6 +1316,18 @@ namespace eval ASMsyntaxHighlight {
# @parm String number - number to analyze
# @return List - {base decimal_value} or {base "error"}
proc which_radix {norange number} {
+ # Handle prefix notation for hexadecimal numbers, like 0xfa
+ if {
+ [string index $number 0] == {0}
+ &&
+ ([string index $number 1] == {x} || [string index $number 1] == {X})
+ &&
+ [string is xdigit [string index $number 2]]
+ } then {
+ set number [string replace $number 0 1]
+ append number {h}
+ }
+
set original_len [string length $number]
set len [string length [string trimleft $number {0}]]
if {$original_len > 1 && $len == 1} {
@@ -1318,12 +1344,12 @@ namespace eval ASMsyntaxHighlight {
if {[string index $number 0] == {'}} {
set number [string range $number 1 end]
- set base ascii
- if {[string length $number] == 1} {
+ set base {ascii}
+ if {[string length $number] == 1 || [string index $number 0] == "\\"} {
set dec_val 0
} elseif {[string length $number] > 1} {
- set base string
+ set base {string}
set dec_val 0
}
}
@@ -1358,7 +1384,7 @@ namespace eval ASMsyntaxHighlight {
if {[regexp {^[0-7]*$} $number]} {
if {$len != 3} {
set dec_val 0
- } {
+ } else {
if {[string index $number 0] <= 3} {
set dec_val 0
}
@@ -1376,7 +1402,7 @@ namespace eval ASMsyntaxHighlight {
if {[regexp {^[0-7]*$} $number]} {
if {$len != 3} {
set dec_val 0
- } {
+ } else {
if {[string index $number 0] <= 3} {
set dec_val 0
}
@@ -1399,7 +1425,7 @@ namespace eval ASMsyntaxHighlight {
}
# done ...
- return "$base $dec_val"
+ return [list $base $dec_val]
}
## Highlight expressions (eg. '( 10d - X MOD 55h)')
@@ -1426,7 +1452,7 @@ namespace eval ASMsyntaxHighlight {
# Remove strings
set e_idx 0
- while 1 {
+ while {1} {
if {![regexp -start $e_idx -- {'[^']*'} $data string_data]} {
break
}
@@ -1443,28 +1469,28 @@ namespace eval ASMsyntaxHighlight {
}
# remove and highlight '('
- set opended_par 0
- while 1 {
+ set opened_par 0
+ while {1} {
set symbol_idx [string first {(} $data]
if {$symbol_idx == -1} {break}
- incr opended_par
+ incr opened_par
set data [string replace $data $symbol_idx $symbol_idx { }]
incr symbol_idx $start_index
$editor tag add tag_symbol $lineNumber.$symbol_idx $lineNumber.[expr {$symbol_idx + 1}]
}
# remove and highlight ')'
- while 1 {
+ while {1} {
set symbol_idx [string first {)} $data]
if {$symbol_idx == -1} {break}
- incr opended_par -1
+ incr opened_par -1
set data [string replace $data $symbol_idx $symbol_idx { }]
incr symbol_idx $start_index
$editor tag add tag_symbol $lineNumber.$symbol_idx $lineNumber.[expr {$symbol_idx + 1}]
}
# chcek if parenthesies are balanced
- if {$validation_L0 && $opended_par != 0} {
+ if {$validation_L0 && $opened_par != 0} {
$editor tag add tag_error $lineNumber.$start_index $lineNumber.$end_index
}
@@ -1473,7 +1499,7 @@ namespace eval ASMsyntaxHighlight {
regsub -all {\t} $adjusted_data { } adjusted_data
append adjusted_data { }
foreach symbol $expr_instructions {
- while 1 {
+ while {1} {
set symbol_idx [string first " $symbol " $adjusted_data]
if {$symbol_idx == -1} {break}
set original_symbol_idx $symbol_idx
@@ -1500,7 +1526,7 @@ namespace eval ASMsyntaxHighlight {
$editor tag add tag_error \
$lineNumber.[expr {$symbol_idx + 1}] \
$lineNumber.$symbol_end_index
- } {
+ } else {
foreach smb $expr_instructions {
if {![string first $smb $tmp]} {
$editor tag add tag_error \
@@ -1515,7 +1541,7 @@ namespace eval ASMsyntaxHighlight {
}
# Highlight expression symbols (1 char) and remove them from the string
foreach symbol $expr_symbols {
- while 1 {
+ while {1} {
set symbol_idx [string first $symbol $data]
if {$symbol_idx == -1} {break}
set original_symbol_idx $symbol_idx
@@ -1530,9 +1556,9 @@ namespace eval ASMsyntaxHighlight {
$validation_L0 && (
!$original_symbol_idx
||
- ![regexp {^\s*((\'\\?[^']\')|\w|\$)} [string range $data $symbol_idx_org_1 end]]
+ ![regexp {^\s*((\'\\?[^']+\')|\w|\$)} [string range $data $symbol_idx_org_1 end]]
)
- } {
+ } then {
$editor tag add tag_error \
$lineNumber.$symbol_idx \
$lineNumber.$symbol_idx_1
@@ -1544,7 +1570,7 @@ namespace eval ASMsyntaxHighlight {
set last_index $start_index
set original_data $data
set data [hide_strings $data]
- while 1 {
+ while {1} {
if {![regexp {[^\s]+} $data value]} {break}
@@ -1595,11 +1621,11 @@ namespace eval ASMsyntaxHighlight {
} elseif {[regexp {^(\d|')} $data]} {
# Gain information about the value
- set opr_info [which_radix 1 $data]
+ set opr_info [which_radix 1 [$editor get $lineNumber.$start_index $lineNumber.$end_index]]
set opr_base [lindex $opr_info 0]
set opr_in_dec [lindex $opr_info 1]
- # Highlight value acording to info
+ # Highlight value according to info
if {$opr_base == {}} {
$editor tag add tag_unknown_base $lineNumber.$start_index $lineNumber.$end_index
if {$validation_L0 && ![regexp {^[0-9A-Fa-f]+$} $data]} {
@@ -1611,7 +1637,7 @@ namespace eval ASMsyntaxHighlight {
$editor tag add tag_error $lineNumber.$start_index $lineNumber.$end_index
}
- # Highlight acording to numeric base
+ # Highlight according to numeric base
switch -- $opr_base {
{hex} { ;# Hexadecimal
$editor tag add tag_hex $lineNumber.$start_index $lineNumber.$end_index
@@ -1638,11 +1664,11 @@ namespace eval ASMsyntaxHighlight {
# Constant
if {[lsearch -ascii -exact $spec_registers [string toupper $data]] != -1} {
set tag tag_sfr
- } {
+ } else {
set tag tag_constant
}
$editor tag add $tag $lineNumber.$start_index $lineNumber.$end_index
- if {$validation_L0 && ![regexp {^((\w+)|\$)$} $data]} {
+ if {$validation_L0 && ![regexp {^(((\?\?)?\w+)|\$)$} $data]} {
$editor tag add tag_error $lineNumber.$start_index $lineNumber.$end_index
}
}
@@ -1655,7 +1681,7 @@ namespace eval ASMsyntaxHighlight {
if {[string first {'} $data] == -1} {return $data}
# Perform replacement
- while 1 {
+ while {1} {
if {![regexp {'[^']*'} $data string]} {
break
}
@@ -1673,3 +1699,7 @@ namespace eval ASMsyntaxHighlight {
foreach item ${::ASMsyntaxHighlight::all_controls} {
lappend ::ASMsyntaxHighlight::all_controls__with_dolar "\$$item"
}
+
+# >>> File inclusion guard
+}
+# <<< File inclusion guard