├── .gitignore ├── imgs ├── icon.png ├── img1.png └── img2.png ├── .vscodeignore ├── .gitattributes ├── CHANGELOG.md ├── .vscode └── launch.json ├── package.json ├── README.md ├── language-configuration.json ├── vsc-extension-quickstart.md └── syntaxes └── ir.tmLanguage.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.vsix -------------------------------------------------------------------------------- /imgs/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyn2028/kecc-ir-highlight/HEAD/imgs/icon.png -------------------------------------------------------------------------------- /imgs/img1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyn2028/kecc-ir-highlight/HEAD/imgs/img1.png -------------------------------------------------------------------------------- /imgs/img2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hyn2028/kecc-ir-highlight/HEAD/imgs/img2.png -------------------------------------------------------------------------------- /.vscodeignore: -------------------------------------------------------------------------------- 1 | .vscode/** 2 | .vscode-test/** 3 | .gitignore 4 | vsc-extension-quickstart.md 5 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set default behavior to automatically normalize line endings. 2 | * text=auto 3 | 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to the "kecc-ir-highlight" extension will be documented in this file. 4 | 5 | Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. 6 | 7 | ## [Unreleased] 8 | ## [1.0.0] - 2022-05-17 9 | - Initial release 10 | ## [1.0.1] - 2022-05-17 11 | - Fixed numeric constant recognition bug -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | // A launch configuration that launches the extension inside a new window 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | { 6 | "version": "0.2.0", 7 | "configurations": [ 8 | { 9 | "name": "Extension", 10 | "type": "extensionHost", 11 | "request": "launch", 12 | "args": [ 13 | "--extensionDevelopmentPath=${workspaceFolder}" 14 | ] 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "kecc-ir-highlight", 3 | "displayName": "KECC IR Highlight", 4 | "description": "Support for language highlighting of KECC(KAIST Educational C Compiler) IR", 5 | "version": "1.0.1", 6 | "repository": "https://github.com/hyn2028/kecc-ir-highlight", 7 | "icon": "imgs/icon.png", 8 | "publisher": "hyn2028", 9 | "engines": { 10 | "vscode": "^1.67.0" 11 | }, 12 | "categories": [ 13 | "Programming Languages" 14 | ], 15 | "contributes": { 16 | "languages": [ 17 | { 18 | "id": "ir", 19 | "aliases": [ 20 | "KECC IR", 21 | "ir" 22 | ], 23 | "extensions": [ 24 | ".ir" 25 | ], 26 | "configuration": "./language-configuration.json" 27 | } 28 | ], 29 | "grammars": [ 30 | { 31 | "language": "ir", 32 | "scopeName": "source.keccir", 33 | "path": "./syntaxes/ir.tmLanguage.json" 34 | } 35 | ] 36 | } 37 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # KECC-IR-HIGHLIGHT: README 2 | 3 | This is the README for extension `KECC-IR-HIGHLIGHT`. 4 | 5 | > This is ***not an official*** implementation by the KECC developers and is not affiliated with KECC. 6 | 7 | ## Features 8 | 9 | Support for language highlighting of KECC(KAIST Educational C Compiler) IR. So the theme you use is applied automatically to the `.ir` file. It does not contain themes. 10 | 11 | ![Example-VSCode Default Dark](imgs/img1.png) 12 | 13 | ![Example-Atom One Dark](imgs/img2.png) 14 | 15 | ## Requirements 16 | 17 | No special requirements. Simply install the extension from the Marketplace. 18 | 19 | If the highlighting does not work even after opening the `.ir` file, select `KECC IR` by clicking the `language mode` setting at the bottom bar. 20 | 21 | ## Extension Settings 22 | 23 | No special settings. 24 | 25 | ## Known Issues 26 | 27 | If the initializer for a global variable is not in a format that can be parsed as a number (`([0-9\\.]+?)(?=:|$)`), it is not recognized as a constant. 28 | 29 | If you find any other issues or have a solution, please feel free to contact us. 30 | 31 | ## Release Notes 32 | 33 | Users appreciate release notes as you update your extension. 34 | 35 | ### 1.0.1 36 | 37 | Fixed numeric constant recognition bug. 38 | 39 | ### 1.0.0 40 | 41 | Initial release. 42 | -------------------------------------------------------------------------------- /language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | // symbol used for single line comment. Remove this entry if your language does not support line comments 4 | "lineComment": "//", 5 | // symbols used for start and end a block comment. Remove this entry if your language does not support block comments 6 | "blockComment": [ 7 | "/*", 8 | "*/" 9 | ] 10 | }, 11 | // symbols used as brackets 12 | "brackets": [ 13 | [ 14 | "{", 15 | "}" 16 | ], 17 | [ 18 | "[", 19 | "]" 20 | ], 21 | [ 22 | "(", 23 | ")" 24 | ] 25 | ], 26 | // symbols that are auto closed when typing 27 | "autoClosingPairs": [ 28 | [ 29 | "{", 30 | "}" 31 | ], 32 | [ 33 | "[", 34 | "]" 35 | ], 36 | [ 37 | "(", 38 | ")" 39 | ], 40 | [ 41 | "\"", 42 | "\"" 43 | ], 44 | [ 45 | "'", 46 | "'" 47 | ] 48 | ], 49 | // symbols that can be used to surround a selection 50 | "surroundingPairs": [ 51 | [ 52 | "{", 53 | "}" 54 | ], 55 | [ 56 | "[", 57 | "]" 58 | ], 59 | [ 60 | "(", 61 | ")" 62 | ], 63 | [ 64 | "\"", 65 | "\"" 66 | ], 67 | [ 68 | "'", 69 | "'" 70 | ] 71 | ] 72 | } -------------------------------------------------------------------------------- /vsc-extension-quickstart.md: -------------------------------------------------------------------------------- 1 | # Welcome to your VS Code Extension 2 | 3 | ## What's in the folder 4 | 5 | * This folder contains all of the files necessary for your extension. 6 | * `package.json` - this is the manifest file in which you declare your language support and define the location of the grammar file that has been copied into your extension. 7 | * `syntaxes/ir.tmLanguage.json` - this is the Text mate grammar file that is used for tokenization. 8 | * `language-configuration.json` - this is the language configuration, defining the tokens that are used for comments and brackets. 9 | 10 | ## Get up and running straight away 11 | 12 | * Make sure the language configuration settings in `language-configuration.json` are accurate. 13 | * Press `F5` to open a new window with your extension loaded. 14 | * Create a new file with a file name suffix matching your language. 15 | * Verify that syntax highlighting works and that the language configuration settings are working. 16 | 17 | ## Make changes 18 | 19 | * You can relaunch the extension from the debug toolbar after making changes to the files listed above. 20 | * You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. 21 | 22 | ## Add more language features 23 | 24 | * To add features such as intellisense, hovers and validators check out the VS Code extenders documentation at https://code.visualstudio.com/docs 25 | 26 | ## Install your extension 27 | 28 | * To start using your extension with Visual Studio Code copy it into the `/.vscode/extensions` folder and restart Code. 29 | * To share your extension with the world, read on https://code.visualstudio.com/docs about publishing an extension. 30 | -------------------------------------------------------------------------------- /syntaxes/ir.tmLanguage.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", 3 | "name": "KECC IR", 4 | "patterns": [ 5 | { 6 | "include": "#array_types" 7 | }, 8 | { 9 | "include": "#normal" 10 | } 11 | ], 12 | "repository": { 13 | "array_types": { 14 | "_comment": "array types and its pointers", 15 | "begin": "\\[", 16 | "end": "\\]\\**", 17 | "name": "entity.name.class", 18 | "patterns": [ 19 | { 20 | "include": "#array_types" 21 | } 22 | ] 23 | }, 24 | "normal": { 25 | "patterns": [ 26 | { 27 | "_comment": "primitive types and its pointers", 28 | "name": "entity.name.class", 29 | "match": "(i8|i16|i32|i64|u1|u8|u16|u32|u64|f32|f64|unit)\\**" 30 | }, 31 | { 32 | "_comment": "struct and its pointers", 33 | "name": "entity.name.class", 34 | "match": "struct .+?(?=:|,| |$)" 35 | }, 36 | { 37 | "_comment": "keywords", 38 | "name": "keyword.ir", 39 | "match": "\\b(fun|init|block|bid|allocations|var)\\b" 40 | }, 41 | { 42 | "_comment": "instructions", 43 | "name": "keyword.control.ir", 44 | "match": "(?<=\\s|^)(nop|store|call|load|typecast|to|getelementptr|offset|cmp|ret|mul|div|mod|add|sub|shl|shr|eq|ne|lt|le|gt|ge|and|xor|or|plus|minus|negate|j|br|switch|default)(?=\\s)" 45 | }, 46 | { 47 | "_comment": "temporary registers", 48 | "name": "entity.name.variable.ir", 49 | "match": "\\%b[0-9]+?:i[0-9]+?(?=:)" 50 | }, 51 | { 52 | "_comment": "phinode registers", 53 | "name": "entity.name.variable.ir", 54 | "match": "\\%b[0-9]+?:p[0-9]+?(?=:)" 55 | }, 56 | { 57 | "_comment": "local variable registers", 58 | "name": "entity.name.variable.ir", 59 | "match": "\\%l[0-9]+?(?=:)" 60 | }, 61 | { 62 | "_comment": "function names as operand", 63 | "name": "entity.name.function.ir", 64 | "match": "(?<=\\s|^)(@.*?)(?=:)" 65 | }, 66 | { 67 | "_comment": "function names as function definition", 68 | "name": "entity.name.function.ir", 69 | "match": "(?<=\\s|^)(@.*?)(?=\\s)" 70 | }, 71 | { 72 | "_comment": "block ids", 73 | "name": "entity.name.function.ir", 74 | "match": "(?<=\\s|^)(b[0-9\\.]+)" 75 | }, 76 | { 77 | "_comment": "constants-numeric", 78 | "name": "constant.numeric.ir", 79 | "match": "\\b([0-9\\.]+?)(?=:|$)" 80 | }, 81 | { 82 | "_comment": "constant-undef", 83 | "name": "constant.numeric.ir", 84 | "match": "(undef)(?=:)" 85 | } 86 | ] 87 | } 88 | }, 89 | "scopeName": "source.keccir" 90 | } --------------------------------------------------------------------------------