User Defined Language for GCode Help
-
I’m Trying to develop a User Defined Language for a CNC G Code system. I have it kind of working the only real thing is I can’t get the keywords to work. Is there some way to make a keyword list that overrides everything else?
Here is what I mean. Here’s a section of my file:
I am trying to make Power and Off both key words, but only Off is working, not Power. Power is all multi colored because they can perfix the numbers, but F can also prefix a number but Off still works.
I’m trying to get words from the keyword list to be orange and if a word is not in the keyword list, it will be red unless they are in a comment or a label and then they will be the comment or label color… that part is working.
Here only the Off part of Offset is orange, even though Offset is in the same list as Off, and also in I misspell ‘OffSte’ I would like the entire thing to be Red because even though it contains Off, it’s not a valid keyword. I also can’t figure out how to make A-F to be considered numbers after a $ which indicates Hexadecimal which you can also see below
Here is my language file:
<NotepadPlus> <UserLang name="ProAuto" ext="Tap" udlVersion="2.1"> <Settings> <Global caseIgnored="yes" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" /> <Prefix Keywords1="yes" Keywords2="yes" Keywords3="yes" Keywords4="no" Keywords5="yes" Keywords6="yes" Keywords7="yes" Keywords8="no" /> </Settings> <KeywordLists> <Keywords name="Comments">00; 00: 00~ 01 02 03 04</Keywords> <Keywords name="Numbers, prefix1"></Keywords> <Keywords name="Numbers, prefix2"></Keywords> <Keywords name="Numbers, extras1"></Keywords> <Keywords name="Numbers, extras2"></Keywords> <Keywords name="Numbers, suffix1">.</Keywords> <Keywords name="Numbers, suffix2"></Keywords> <Keywords name="Numbers, range"></Keywords> <Keywords name="Operators1">+ / - * X Y Z I J K F S T M N E , ABS</Keywords> <Keywords name="Operators2">ARC ArcRate ump call return load M e re urn an n ar ophow ool wa pe c</Keywords> <Keywords name="Folders in code1, open"></Keywords> <Keywords name="Folders in code1, middle"></Keywords> <Keywords name="Folders in code1, close"></Keywords> <Keywords name="Folders in code2, open"></Keywords> <Keywords name="Folders in code2, middle"></Keywords> <Keywords name="Folders in code2, close"></Keywords> <Keywords name="Folders in comment, open"></Keywords> <Keywords name="Folders in comment, middle"></Keywords> <Keywords name="Folders in comment, close"></Keywords> <Keywords name="Keywords1">Load Return</Keywords> <Keywords name="Keywords2">Ask</Keywords> <Keywords name="Keywords3">SQR
SQRT
ARCTAN
Tan
SIN
ARCSIN 
COS
ARCCOS
Round</Keywords> <Keywords name="Keywords4">G0
G00
G1
G01
G2
G92
G93
G90
G80
G81
G82
G83
G84
G85
G86
G87
G88
G89
G02
G3
G03
G38
G38.3
G38.2
G4
G04
G90
G80
G81
G82
G83
G84
G85
G86
G87
G88
G89
</Keywords> <Keywords name="Keywords5">RATE Offset Q START STOP Array Number Up Down Drawend redraw Diameter draw color circle line Dwell aterial hickness Clearance Rapid Cutting Path Ret Ull able Disable umber pe Vector le Relative Absolute Position ap RPM ump gimov gifee gireplac Program oolup ooldown</Keywords> <Keywords name="Keywords6">MZ
MW
MV
MU
MT
Power On Off
MD
Head</Keywords> <Keywords name="Keywords7">=</Keywords> <Keywords name="Keywords8"></Keywords> <Keywords name="Delimiters">00@ 00& 01 02@ 02& 03[ 04 05] 06( 07 08) 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23</Keywords> </KeywordLists> <Styles> <WordsStyle name="DEFAULT" fgColor="FF0000" bgColor="000000" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="COMMENTS" fgColor="0080FF" bgColor="000000" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="LINE COMMENTS" fgColor="C0C0C0" bgColor="000000" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="NUMBERS" fgColor="00FF00" bgColor="000000" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS1" fgColor="FCB103" bgColor="000000" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS2" fgColor="FF6AFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS3" fgColor="00FF80" bgColor="000000" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS4" fgColor="04D0CB" bgColor="000000" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS5" fgColor="FFFF00" bgColor="000000" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS6" fgColor="80FFFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS7" fgColor="3C9DFF" bgColor="000000" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="KEYWORDS8" fgColor="8000FF" bgColor="000000" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="OPERATORS" fgColor="FFFF00" bgColor="000000" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="FOLDER IN CODE1" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="FOLDER IN CODE2" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="FOLDER IN COMMENT" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS1" fgColor="9797FF" bgColor="000000" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS2" fgColor="A230FE" bgColor="000000" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS3" fgColor="FF8000" bgColor="000000" fontName="" fontStyle="0" nesting="117702655" /> <WordsStyle name="DELIMITERS4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS5" fgColor="FFFF80" bgColor="000000" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS6" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> <WordsStyle name="DELIMITERS8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0" /> </Styles> </UserLang> </NotepadPlus>
Here’s a partial sample file:
;----------------------------------------- ; Production Automation ; (c)2023 All Rights Reserved ~Machine~ = `ProAuto All` ~Program~ = `11 Division C1 B` ~Quantity Needed~ = 6 ~Created by~ = `James M Richters` ~Date Created~ = `Sat Apr 1 19:50:08 2023` ;------------- Custom Start -------------- &Count Start& = 0 Load[M:\CNC_Data\Econ Odome\CNC Divisions\Vertical\~\Start.Tap] ;----------------------------------------- Vector File = M:\CNC_Data\Econ Odome\CNC Divisions\Vertical\2x6\11 Division C1 B.ccd ;---------- Information Totals ----------- ; All XY Contours: 1456.882 Inches ; All Z Downfeeds: 29.006 Inches ; All Rapid Moves: 585.51 Inches ; Estimated Run Time: 13 Minutes 55 Seconds ;--------------- Material ---------------- Material Size = 5.39398 x 34.27707 Material Thickness = 1.5 Material Offset = 0 , 0 Material Draw Color = ($BFE0) : Neon Yellow Cuts Outside Material Set Clearance = 0 Set Rapid = 0 Set Cutting = 0 [Job #1 <T17><Rough Square Edge R>] ;T17 - Router 0.500 - 1/2 x 1-3/4 Roughing Resharp ;------------ Job Information ------------ ; Job XY Contours: 7.1 Inches ; Job Z Downfeeds: 4.1 Inches ; Job Rapid Moves: 13.795 Inches ; Estimated Job Time: 3 Seconds ;----------------------------------------- ;----------- Custom Job Start ------------ Load [M:\CNC_Data\Econ Odome\CNC Divisions\Vertical\~\Rough Square Edge R Start.Tap] ;----------------------------------------- T17 S10000 Tool Diameter = 0.5 Tool Path Color = Sky Blue ; Value At Home = 10.411 XY Rate = 150 Z Rate = 400 ; A Axis = 0 G0 X6.3 Y-0.4 C0 G0 Z3.25 G1 Z-0.85 G1 X-0.8 Y-0.4 Head Up ;------------ Custom Job End ------------- Load [M:\CNC_Data\Econ Odome\CNC Divisions\Vertical\~\Rough Square Edge R End.Tap] ;----------------------------------------- Return
Any help getting this to work is greatly appreciated.
-
@James-Richters
I’m not going to go into too much detail trying to figure out implementation, but the EnhanceAnyLexer plugin is your friend here.
For example, if you want the single letters X, Y, Z, I, J, K, F, S, T, M, N, E (not part of a word) to be colored red, you could do something like:0x0000ff = \b[XYZIJKFSTMNE]\b
Or to make 2-4 digit hex numbers preceded by a $ sign blue, you’d use
0xff0000 = \$[\da-fA-F]{2,4}
-
@James-Richters ,
I’m not sure what the problem is that you’re having as I just created a UDL using your code, a sample file from the one you provided, and it seems to be working fine for me without that multicoloredPower
keyword. There is one with it and I can’t find in your definition for the UDL where those singular or grouped letters would do that goofy multi color stuff. Here’s a screen shot of what I have after I typed in thePower Off
keyword set:@Mark-Olson is right though, that any other coloring changes that would need to have a Regex needed such as your need for a if/or condition should be done using the EnhanceAnyLexer plugin.