[education/rkward/mr-origin-23] rkward/syntax: Regroup common type rules under the same context

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


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

Regroup common type rules under the same context

M  +12   -9    rkward/syntax/rkward.xml

https://invent.kde.org/education/rkward/-/commit/c6bae6ef7ee2937d7129ae4fbdddc6c8b02a4b15

diff --git a/rkward/syntax/rkward.xml b/rkward/syntax/rkward.xml
index 408827a70..00bad1c6f 100644
--- a/rkward/syntax/rkward.xml
+++ b/rkward/syntax/rkward.xml
@@ -84,6 +84,15 @@ SPDX-License-Identifier: GPL-2.0-or-later
 		<context attribute="Output Error" lineEndContext="#pop" name="Output Error">
 		</context>
 		
+		<!-- Common type highlight -->
+		<context attribute="Output Common Type" name="outputcommontype">
+			<!-- Floats are hard to catch in R Output -->
+			<RegExpr attribute="Output Float" context="#stay" String="(?<=<|>|\(|\[| |^)-?([1-9][0-9]*|0)(\.[0-9]*)?i?(e[-+]?[ ]{0,3}[0-9]+)?(?![0-9a-zA-Z/_\~\-\]+]|[.,;:][^ \t])"/>
+			<WordDetect attribute="Output NA" context="#stay" String="NA"/>
+			<WordDetect attribute="Output True" context="#stay" String="TRUE"/>
+			<WordDetect attribute="Output False" context="#stay" String="FALSE"/>
+		</context>
+		
 		<!-- Special context for tibble output -->
 		<context attribute="Output Tibble" lineEndContext="#stay" name="outputtibble">
 			<!-- If a "> " is encountered at line start, pop back to ctxbase (and to command0 from there) -->
@@ -98,10 +107,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
 			<RegExpr attribute="Output Data Type" context="#stay" String="<(lgl|int|dbl|chr|cpl|raw|list|named list|fct|ord|date|dttm|drtn|time|int64|blob|df\[\,1\]|tibble\[\,1\]|I|\?\?\?|list<.+>|vctrs_vc|prtl_fctr|prtl|fn|sym|expression|quos)>"/>
 			<RegExpr attribute="Output Index" context="#stay" String="[ ]{0,2}[0-9]+" column="0"/>
 			<!-- Common highlights -->
-			<RegExpr attribute="Output Float" context="#stay" String="(?<=<|>|\(|\[| |^)-?([1-9][0-9]*|0)(\.[0-9]*)?i?(e[-+]?[ ]{0,3}[0-9]+)?(?![0-9a-zA-Z/_\~\-\]+]|[.,;:][^ \t])"/>
-			<WordDetect attribute="Output NA" context="#stay" String="NA"/>
-			<WordDetect attribute="Output True" context="#stay" String="TRUE"/>
-			<WordDetect attribute="Output False" context="#stay" String="FALSE"/>
+			<IncludeRules context="outputcommontype"/>
 		</context>
 		
 		<!-- Special context for str_view() -->
@@ -141,11 +147,8 @@ SPDX-License-Identifier: GPL-2.0-or-later
 			<!-- Other specials highlights -->
 			<RegExpr attribute="Output Index" context="#stay" String="([ ]{0,2}|[ ]*\[)[0-9]+,?[0-9]*(\]|\: )(?![.0-9]|.*[:,.;]$)" column="0"/>
 			<RegExpr attribute="Output Index" context="#stay" String="([ ]+\[,[1-9]+[0-9]*\])+$" column="0"/>
-			<!-- Floats are hard to catch in R Output -->
-			<RegExpr attribute="Output Float" context="#stay" String="(?<=<|>|\(|\[| |^)-?([1-9][0-9]*|0)(\.[0-9]*)?i?(e[-+]?[ ]{0,3}[0-9]+)?(?![0-9a-zA-Z/_\~\-\]+]|[.,;:][^ \t])"/>
-			<WordDetect attribute="Output NA" context="#stay" String="NA"/>
-			<WordDetect attribute="Output True" context="#stay" String="TRUE"/>
-			<WordDetect attribute="Output False" context="#stay" String="FALSE"/>
+			<!-- Common highlights -->
+			<IncludeRules context="outputcommontype"/>
 		</context>
 		
 		<!-- This context is not really used, but meant to be included. It checks whether a new line is a continuation of a command. If so, it eats the "+ " at the line start. Else it tries to pop back to the top level. (NOTE: An output line starting with "+" will be considered a command line!) -->


More information about the rkward-tracker mailing list