@@ -627,6 +627,106 @@ function julia(hljs) {
627627 return DEFAULT ;
628628}
629629
630+ /*
631+ Language: Julia IR
632+ Description: Julia Static Single Assignment (SSA) form Intermediate Representation
633+ Author: Matt Bauman
634+ Website: https://docs.julialang.org/en/v1/devdocs/ssair/
635+ Category: scientific
636+ Extends: julia.js
637+ */
638+
639+ function juliaIR (hljs ) {
640+ // Get the base Julia language definition
641+ const jl = hljs .getLanguage (" julia" );
642+
643+ if (! jl) {
644+ throw new Error (
645+ " Julia language definition not found. Julia IR extends Julia."
646+ );
647+ }
648+
649+ // Clone the Julia definition to avoid modifying the original
650+ const jlir = {
651+ ... jl,
652+ name: " julia-ir" ,
653+ };
654+
655+ // Add IR-specific keywords to existing Julia keywords
656+ const IR_KEYWORDS = [
657+ " goto" ,
658+ " not" ,
659+ " invoke" ,
660+ " call" ,
661+ " enter" ,
662+ " leave" ,
663+ " unreachable" ,
664+ " φᶜ" ,
665+ " φ" ,
666+ " π" ,
667+ " ϒ" ,
668+ ];
669+
670+ // Extend keywords
671+ if (jlir .keywords ) {
672+ jlir .keywords = {
673+ ... jlir .keywords ,
674+ keyword: [... (juliaIR .keywords .keyword || []), ... IR_KEYWORDS],
675+ };
676+ }
677+
678+ // IR-specific patterns that need to be added to the contains array
679+ const IR_PATTERNS = [
680+ // SSA values (%1, %2, etc.) - highest priority
681+ {
682+ scope: " variable" ,
683+ match: / %\d + / ,
684+ relevance: 10 ,
685+ },
686+
687+ // Basic block labels (1 ─, 2 ┄, etc.) and box drawing
688+ {
689+ scope: " section" ,
690+ match: / ^ \s * \d * [ ─│╻╷└┃┌┄] + / ,
691+ relevance: 8 ,
692+ },
693+
694+ // Control flow labels (#1, #2, etc.)
695+ {
696+ scope: " symbol" ,
697+ match: / #\d + / ,
698+ relevance: 5 ,
699+ },
700+
701+ // Warned type annotations
702+ {
703+ scope: " type.unstable" ,
704+ match: / ::(Any| Box)\b / ,
705+ relevance: 8 ,
706+ },
707+
708+ // CodeInfo wrapper
709+ {
710+ scope: " meta" ,
711+ begin: / \b CodeInfo\s * \( / ,
712+ end: / $ / ,
713+ contains: [" self" ],
714+ relevance: 10 ,
715+ },
716+ ];
717+
718+ // Prepend IR patterns to the contains array (higher priority than base Julia patterns)
719+ if (jlir .contains ) {
720+ jlir .contains = [... IR_PATTERNS, ... jlir .contains ];
721+ } else {
722+ jlir .contains = IR_PATTERNS ;
723+ }
724+
725+ jlir .case_insensitive = false ;
726+
727+ return jlir;
728+ }
729+
630730/*
631731 Language: Julia REPL
632732 Description: Julia REPL sessions
@@ -703,6 +803,30 @@ function juliaRepl(hljs) {
703803 ],
704804 },
705805 },
806+ {
807+ className: " meta.prompt" ,
808+ begin: / ^ julia>(?=\s + @? code_(typed| lowered| warntype)\b )/ ,
809+ relevance: 15 ,
810+ starts: {
811+ end: / ^ (?=julia>)/ ,
812+ returnBegin: true ,
813+ contains: [
814+ {
815+ // The Julia command line itself
816+ begin: / \s + @? code_(typed| lowered| warntype)/ ,
817+ end: / ^ (?![ ] {6} )/ ,
818+ subLanguage: " julia" ,
819+ endsWithParent: true ,
820+ },
821+ {
822+ // The IR that follows
823+ begin: / ^ . / ,
824+ subLanguage: " julia-ir" ,
825+ endsWithParent: true ,
826+ },
827+ ],
828+ },
829+ },
706830 {
707831 className: " meta.prompt" ,
708832 begin: / ^ julia>/ ,
@@ -777,6 +901,7 @@ function juliaRepl(hljs) {
777901
778902export default apiInitializer ((api ) => {
779903 api .registerHighlightJSLanguage (" julia" , julia);
904+ api .registerHighlightJSLanguage (" julia-ir" , juliaIR);
780905 api .registerHighlightJSLanguage (" julia-repl" , juliaRepl);
781906 // Register meta-language that auto-detects between julia and julia-repl
782907 api .registerHighlightJSLanguage (" julia-auto" , function (hljs ) {
0 commit comments