Lexical Comparison - recognizing tokens during comparison of source code
Overview
To improve source code comparison, Code Compare
incorporates Lexical Comparison — one of the key principles of Code Orientation.
This algorithm allows for a better file comparison, sync and merge through detecting
lexemes from major programming languages — namely C#, C++, JavaScript, Java, and
Visual Basic — and comparing them as single-pieces.
Language Combo Box
Lexical Comparison algorithm chooses the programming language automatically, based
on the file extension. However, you can change this setting using the Language Combo
Box on the toolbar. The chosen language wil be applied immediately, while
the Text option turns off the Lexical Comparison algorithm.
Below you can find descriptions of the most popular cases when Lexical Comparison
proved exceptionally useful.
Lexical Comparison vs. Text Comparison
-
Text comparison mode within Code Compare can be inconvenient for source code comparison
as it does not recognize language elements and looks for similar symbols in totally
different lexemes.
With Lexical Comparison enabled, different lexeme types are never compared with
each other.
-
Code Compare tool with Lexical comparison enabled always compares numbers wholly.
This is illustrated by the next screenshot.
If you choose text comparison mode, the numbers will be compared digit-by-digit,
which is irrational in the context of source code comparison.
Additional Options
-
Ignoring comments can be enabled in Comparison options menu.
With respective checkbox checked, comparison tool will disregard any source code
comments and highlight the blocks different by this sign only as unchanged.
For details on the major feature set of our file diff and merge tool, refer to the
overview page of Code Compare.