Files
cloud-code/claude-code-source/node_modules/.ignored/highlight.js/lib/languages/gcode.js
janlaywss 6187147b74 reconstruct and build @anthropic-ai/claude-code source from source map
- Extract 4756 source files from cli.js.map (57MB)
- Set up Bun build system with bun:bundle feature flag shim
- Configure 90+ compile-time feature flags matching production defaults
- Inject MACRO constants (VERSION, BUILD_TIME, etc.)
- Create stubs for private packages (color-diff-napi, modifiers-napi, etc.)
- Install all public dependencies via pnpm
- Patch commander v14 to allow multi-char short flags (-d2e)
- Build output: dist/cli.js (22MB), verified working
2026-03-31 19:19:50 +08:00

89 lines
2.1 KiB
JavaScript

/*
Language: G-code (ISO 6983)
Contributors: Adam Joseph Cook <adam.joseph.cook@gmail.com>
Description: G-code syntax highlighter for Fanuc and other common CNC machine tool controls.
Website: https://www.sis.se/api/document/preview/911952/
*/
function gcode(hljs) {
const GCODE_IDENT_RE = '[A-Z_][A-Z0-9_.]*';
const GCODE_CLOSE_RE = '%';
const GCODE_KEYWORDS = {
$pattern: GCODE_IDENT_RE,
keyword: 'IF DO WHILE ENDWHILE CALL ENDIF SUB ENDSUB GOTO REPEAT ENDREPEAT ' +
'EQ LT GT NE GE LE OR XOR'
};
const GCODE_START = {
className: 'meta',
begin: '([O])([0-9]+)'
};
const NUMBER = hljs.inherit(hljs.C_NUMBER_MODE, {
begin: '([-+]?((\\.\\d+)|(\\d+)(\\.\\d*)?))|' + hljs.C_NUMBER_RE
});
const GCODE_CODE = [
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
hljs.COMMENT(/\(/, /\)/),
NUMBER,
hljs.inherit(hljs.APOS_STRING_MODE, {
illegal: null
}),
hljs.inherit(hljs.QUOTE_STRING_MODE, {
illegal: null
}),
{
className: 'name',
begin: '([G])([0-9]+\\.?[0-9]?)'
},
{
className: 'name',
begin: '([M])([0-9]+\\.?[0-9]?)'
},
{
className: 'attr',
begin: '(VC|VS|#)',
end: '(\\d+)'
},
{
className: 'attr',
begin: '(VZOFX|VZOFY|VZOFZ)'
},
{
className: 'built_in',
begin: '(ATAN|ABS|ACOS|ASIN|SIN|COS|EXP|FIX|FUP|ROUND|LN|TAN)(\\[)',
contains: [
NUMBER
],
end: '\\]'
},
{
className: 'symbol',
variants: [
{
begin: 'N',
end: '\\d+',
illegal: '\\W'
}
]
}
];
return {
name: 'G-code (ISO 6983)',
aliases: ['nc'],
// Some implementations (CNC controls) of G-code are interoperable with uppercase and lowercase letters seamlessly.
// However, most prefer all uppercase and uppercase is customary.
case_insensitive: true,
keywords: GCODE_KEYWORDS,
contains: [
{
className: 'meta',
begin: GCODE_CLOSE_RE
},
GCODE_START
].concat(GCODE_CODE)
};
}
module.exports = gcode;