[education/rkward/mr-origin-23] rkward/syntax: Improve handling of float in R console highlighting

Thomas Friedrichsmeier null at kde.org
Wed Oct 18 17:24:53 BST 2023


Git commit 8327ebcc86bf218126783a1495c35b16b6cdb884 by Thomas Friedrichsmeier, on behalf of Pierre de Villemereuil.
Committed on 18/10/2023 at 18:21.
Pushed by tfry into branch 'mr-origin-23'.

Improve handling of float in R console highlighting

Default detection of Int/Float does not work well for R. R does not
really distinguish Int from Float, and Float includes scientific
notation.

M  +2    -3    rkward/syntax/rkward.xml

https://invent.kde.org/education/rkward/-/commit/8327ebcc86bf218126783a1495c35b16b6cdb884

diff --git a/rkward/syntax/rkward.xml b/rkward/syntax/rkward.xml
index 756a273ad..b6bce5381 100644
--- a/rkward/syntax/rkward.xml
+++ b/rkward/syntax/rkward.xml
@@ -135,8 +135,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
 			<DetectChar attribute="String" context="backquotedsymbol" char="`"/>
 			<keyword attribute="Control Structure" context="#stay" String="controls"/>
 			<keyword attribute="Reserved Words" context="#stay" String="words"/>
-			<Float attribute="Float" context="#stay"/>
-			<Int attribute="Int" context="#stay"/>
+			<!-- No need to distinguish Int and Float in R, but Float should include scientific notations -->
+			<RegExpr attribute="Float" context="#stay" String="(\b[0-9]+\.?[0-9]*|\.[0-9]+)([eE][-+]?[0-9]+)?"/>
 			<RegExpr attribute="Keyword" context="#stay" String="[a-zA-Z_]+[a-zA-Z_\.0-9]*(?=[\s]*[(])"/>
 			<RegExpr attribute="Keyword" context="#stay" String="\.[a-zA-Z_\.]+[a-zA-Z_\.0-9]*(?=[\s]*[(])"/>
 			<RegExpr attribute="Symbol" context="parenthesis" String="\("/>
@@ -177,7 +177,6 @@ SPDX-License-Identifier: GPL-2.0-or-later
 		<itemData name="Operator" defStyleNum="dsOperator"/>
 		<itemData name="String Char"  defStyleNum="dsChar"/>
 		<itemData name="Float" defStyleNum="dsFloat"/>
-		<itemData name="Int" defStyleNum="dsDecVal"/>
 	</itemDatas>
 </highlighting>
 



More information about the rkward-tracker mailing list