Au passage, t'es pas obligé de te taper les expressions régulières à la main, y'a des sites qui aident bien pour ça :
pour les créer
pour les convertir en pseudo-code
pour les tester
). Mais je n'ai pas la description du mode AfterLabel dans ton extrait (enfin plus exactement j'ai sa première ligne, cf. la dernière ligne de ton extrait, le tag ouvrant context avec l'attribut name="AfterLabel" ça devrait être ça. Mais tout ce que je peux te dire là c'est que lineEndContext="#pop" a a priori pour effet de revenir au mode précédent après un passage à la ligne, le reste je ne le vois pas)Folco (./29) :Ben c'est le choix des noms d'attributs le problème : tu en as un qui s'appelle « attribute » ce qui n'apporte aucune information, et un autre qui s'appelle « context » parce qu'il est censé avoir une valeur de type context, ce qui ne donne aucune indication sur à quoi *sert* cet attribut... (ils auraient appelé ça respectivement « style » et « contextAfterMatch » j'aurais compris plus vite
rah je suis content de te lire dire que c'est pas très clair tout ça
) <contexts>
<context attribute="Normal Text" lineEndContext="#stay" name="Normal">
<RegExpr attribute="Label" context="#stay" String="^[A-Za-z0-9_$@\][A-Za-z0-9_.$@]*:" />
<RegExpr attribute="Label" context="AfterLabel" String="^[A-Za-z0-9_$@][A-Za-z0-9_.$@]*(?=\s+[_\w])" />
<RegExpr attribute="Normal Text" context="AfterLabel" String="^\s+" />
<DetectChar attribute="Comment" context="Commentar 1" char=";" />
</context>
<context attribute="Normal Text" lineEndContext="#pop" name="AfterLabel">
<keyword attribute="Instruction" context="Instruction" String="instructions" />
<keyword attribute="Keyword" context="#stay" String="keywords" />
<keyword attribute="Register" context="#stay" String="registers" />
<RegExpr attribute="Hex" context="#stay" String="#?\$[0-9a-fA-F]+" />
<RegExpr attribute="Binary" context="#stay" String="#?%[01]+" />
<RegExpr attribute="Decimal" context="#stay" String="#?[-+]?[1-9][0-9]*" />
<RegExpr attribute="Normal Text" context="#stay" String="[A-Za-z_.$][A-Za-z0-9_.$]*" />
<RegExpr attribute="Char" context="#stay" String="'(\x[0-9a-fA-F][0-9a-fA-F]?|\[0-7]?[0-7]?[0-7]?|\.|.)" />
<DetectChar attribute="String" context="String" char=""" />
<DetectChar attribute="Comment" context="Commentar 1" char=";" />
<AnyChar attribute="Symbol" context="#stay" String="!#%&*()+,-<=>?/:[]^{@}~" />
</context>
<context attribute="Comment" lineEndContext="#pop" name="Commentar 1" />
<context attribute="String" lineEndContext="#pop" name="String">
<LineContinue attribute="String" context="Some Context" />
<HlCStringChar attribute="String Char" context="#stay" />
<DetectChar attribute="String" context="#pop" char=""" />
</context>
<context attribute="Instruction" lineEndContext="#pop" name="Instruction">
<RegExpr attribute="Instruction" context="#pop" String="(\.[lwbs])|[^a-zA-Z]" />
</context>
<context attribute="Normal Text" lineEndContext="#pop" name="Some Context" />
</contexts>
<itemDatas>
<itemData name="Normal Text" defStyleNum="dsNormal" />
<itemData name="Label" defStyleNum="dsNormal" />
<itemData name="Keyword" defStyleNum="dsKeyword" />
<itemData name="Decimal" defStyleNum="dsDecVal" />
<itemData name="Hex" defStyleNum="dsBaseN" />
<itemData name="Binary" defStyleNum="dsBaseN" />
<itemData name="Char" defStyleNum="dsChar" />
<itemData name="String" defStyleNum="dsString" />
<itemData name="String Char" defStyleNum="dsChar" />
<itemData name="Symbol" defStyleNum="dsNormal" />
<itemData name="Comment" defStyleNum="dsComment" />
<itemData name="Instruction" defStyleNum="dsNormal" />
<itemData name="Register" defStyleNum="dsNormal" />
</itemDatas>
</highlighting>
<general>
<comments>
<comment name="singleLine" start=";" />
</comments>
<keywords casesensitive="1" weakDeliminator="_$" />
</general>
</language><contexts>
<context attribute="Normal Text" lineEndContext="#stay" name="Normal">
<RegExpr attribute="Label" context="#stay" String="^[A-Za-z0-9_$@\][A-Za-z0-9_.$@]*:" />
<RegExpr attribute="Label" context="AfterLabel" String="^[A-Za-z0-9_$@][A-Za-z0-9_.$@]*(?=\s+[_\w])" />
<RegExpr attribute="Normal Text" context="AfterLabel" String="^\s+" />
<DetectChar attribute="Comment" context="Commentar 1" char=";" />
</context>
<context attribute="Normal Text" lineEndContext="#pop" name="AfterLabel">
<keyword attribute="Instruction" context="Instruction" String="instructions" />
<keyword attribute="Keyword" context="#stay" String="keywords" />
<keyword attribute="Register" context="#stay" String="registers" />
<RegExpr attribute="Hex" context="#stay" String="#?\$[0-9a-fA-F]+" />
<RegExpr attribute="Binary" context="#stay" String="#?%[01]+" />
<RegExpr attribute="Decimal" context="#stay" String="#?[-+]?[1-9][0-9]*" />
<RegExpr attribute="Normal Text" context="#stay" String="[A-Za-z_.$][A-Za-z0-9_.$]*" />
<RegExpr attribute="Char" context="#stay" String="'(\x[0-9a-fA-F][0-9a-fA-F]?|\[0-7]?[0-7]?[0-7]?|\.|.)" />
<DetectChar attribute="String" context="String" char=""" />
<DetectChar attribute="Comment" context="Commentar 1" char=";" />
<AnyChar attribute="Symbol" context="#stay" String="!#%&*()+,-<=>?/:[]^{@}~" />
</context>
<context attribute="Comment" lineEndContext="#pop" name="Commentar 1" />
<context attribute="String" lineEndContext="#pop" name="String">
<LineContinue attribute="String" context="Some Context" />
<HlCStringChar attribute="String Char" context="#stay" />
<DetectChar attribute="String" context="#pop" char=""" />
</context>
<context attribute="Instruction" lineEndContext="#pop" name="Instruction">
<RegExpr attribute="Instruction" context="#pop" String="(\.[lwbs])|[^a-zA-Z]" />
</context>
<context attribute="Normal Text" lineEndContext="#pop" name="Some Context" />
</contexts>(réindenté afin qu'on puisse le lire
)Ah merde, je viens de le faire comme ça : <contexts>
<context attribute="Normal Text" lineEndContext="#stay" name="Normal">
<RegExpr attribute="Label" context="#stay" String="^[A-Za-z0-9_$@\][A-Za-z0-9_.$@]*:" />
<RegExpr attribute="Label" context="AfterLabel" String="^[A-Za-z0-9_$@][A-Za-z0-9_.$@]*(?=\s+[_\w])" />
<RegExpr attribute="Normal Text" context="AfterLabel" String="^\s+" />
<DetectChar attribute="Comment" context="Commentar 1" char=";" />
</context>
<context attribute="Normal Text" lineEndContext="#pop" name="AfterLabel">
<keyword attribute="Instruction" context="Instruction" String="instructions" />
<keyword attribute="Keyword" context="#stay" String="keywords" />
<keyword attribute="Register" context="#stay" String="registers" />
<RegExpr attribute="Hex" context="#stay" String="#?\$[0-9a-fA-F]+" />
<RegExpr attribute="Binary" context="#stay" String="#?%[01]+" />
<RegExpr attribute="Decimal" context="#stay" String="#?[-+]?[1-9][0-9]*" />
<RegExpr attribute="Normal Text" context="#stay" String="[A-Za-z_.$][A-Za-z0-9_.$]*" />
<RegExpr attribute="Char" context="#stay" String="'(\x[0-9a-fA-F][0-9a-fA-F]?|\[0-7]?[0-7]?[0-7]?|\.|.)" />
<DetectChar attribute="String" context="String" char=""" />
<DetectChar attribute="Comment" context="Commentar 1" char=";" />
<AnyChar attribute="Symbol" context="#stay" String="!#%&*()+,-<=>?/:[]^{@}~" />
</context>
<context attribute="Comment" lineEndContext="#pop" name="Commentar 1" />
<context attribute="String" lineEndContext="#pop" name="String">
<LineContinue attribute="String" context="Some Context" />
<HlCStringChar attribute="String Char" context="#stay" />
<DetectChar attribute="String" context="#pop" char=""" />
</context>
<context attribute="Instruction" lineEndContext="#pop" name="Instruction">
<RegExpr attribute="Instruction" context="#pop" String="(\.[lwbs])|[^a-zA-Z]" />
</context>
<context attribute="Normal Text" lineEndContext="#po
. Mais tu as utilisé 4, pas 8
. Ceci dit tu m'as quand même collé un ascenseur horizontal
). Non j'ai juste posté ça parce que dans ton post ça n'était pas indenté du tout et que je ne peux pas analyser le code sans avoir sous les yeux une version indentée proprement ^^

Voici à quoi une règle ressemble :<RuleName attribute="(identifier)" context="(identifier)" [attributs propres à la règle] />
L'attribut identifie le style à utiliser pour les caractères correspondants par nom, et le contexte identifie le contexte à utiliser à partir de cet endroit.
Le contexte peut être identifié par :
Un identifiant, qui est le nom de l'autre contexte.
Un ordre demandant au moteur de rester dans le contexte actuel (#stay) ou de revenir à un contexte précédemment utilisé dans la chaîne (#pop).
Pour reculer de plusieurs étapes, le mot-clé #pop peut être répété : #pop#pop#pop.
Certaines règles peuvent avoir des sous-règles qui ne sont ensuite évaluées que si la règle parent correspondait. La chaîne entière concordante se verra affecter l'attribut défini par la règle parent. Voici à quoi ressemble une règle ayant des sous-règles :<RuleName (attributes)>
<ChildRuleName (attributes) />
...</RuleName>
(si ça n'est pas le cas je ne vois pas du tout à quoi correspondent les éléments keyword)
. Par ailleurs est-il vrai qu'une instruction doit obligatoirement être en début de ligne ?? Est-ce vrai d'un label ?
)
<itemDatas>
<itemData name="Normal Text" defStyleNum="dsNormal" />
<itemData name="Label" defStyleNum="dsNormal" />
<itemData name="Keyword" defStyleNum="dsKeyword" />
<itemData name="Decimal" defStyleNum="dsDecVal" />
<itemData name="Hex" defStyleNum="dsBaseN" />
<itemData name="Binary" defStyleNum="dsBaseN" />
<itemData name="Char" defStyleNum="dsChar" />
<itemData name="String" defStyleNum="dsString" />
<itemData name="String Char" defStyleNum="dsChar" />
<itemData name="Symbol" defStyleNum="dsNormal" />
<itemData name="Comment" defStyleNum="dsComment" />
<itemData name="Instruction" defStyleNum="dsNormal" />
<itemData name="Register" defStyleNum="dsNormal" />
</itemDatas>
</highlighting>
<general>
<comments>
<comment name="singleLine" start=";" />
</comments>
<keywords casesensitive="1" weakDeliminator="_$" />
</general>
)
). Il faut aussi ajouter une regexp pour les instructions. Si je ne me trompe pas, il ne peut y avoir qu'une instruction et ses arguments sont forcément après, non ? donc tu peux décomposer en mettant aussi un contexte AfterInstruction. Si une constante littérale ne peut apparaître qu'après une instruction, ça n'est pas la peine de mettre les règles dans AfterLabel, il vaut mieux les mettre dans AfterInstruction. Je verrais bien un truc comme ça :
<context ... name="AfterLabel">
<RegExpr attribute="Instruction" context="AfterInstruction" String="blabla" />
<DetectChar attribute="Comment" context="Commentar 1" char=";" />
</context>
<context ... name="AfterInstruction"
<RegExpr attribute="Hex" ... />
... [mettre ici ce qui était dans AfterLabel]
<RegExpr attribute="Register" String="blibli" />
</context>
)
(mais il ne propose pas des tabs de 3
) (plus sérieusement,
)<list name="keywords"> <item>include</item> <item>incbin</item> <item>even</item> <item>cnop</item> <item>xdef</item> ... <list name="instructions"> <item>abcd</item> <item>add</item> <item>adda</item> <item>addi</item> ... <list name="registers"> <item>a0</item> <item>a1</item> <item>a2</item> <item>a3</item>


Sally (./44) :
Je dirais d'après ce que tu me dis que tout le contexte Normal pourrait être rebaptisé Label
Il est bien sûr possible de créer une classe « négative » correspondant à « tout sauf ». Pour placer un caractère (^) au début de la classe : [^abc]correspondra à n'importe quel caractère sauf à « a » ,« b » ou « c ».
