Rosetta
A VSCode extension that provides C11, ARM assembly, and BNF/EBNF syntax highlighting.
Features
- Complete C11 syntax highlighting for
.playground
files
- ARM assembly syntax highlighting for
.s
and .asm
files
- BNF and EBNF syntax highlighting for
.bnf
, .ebnf
, and .grammar
files
- Support for highlighting:
- Functions, variables, and other syntax elements in C11
- Instructions, registers, directives, and labels in ARM assembly
- Rules, terminals, non-terminals, and operators in BNF/EBNF
- Comments, strings, and constants in all languages
Installation
From VS Code Extension Marketplace
- Open VS Code
- Click on the Extensions icon
- Search for "Rosetta"
- Click Install
From VSIX
- Download the latest
.vsix
file
- In VSCode, open the Extensions view
- Click on the "..." menu and select "Install from VSIX..."
- Select the downloaded
.vsix
file
From Source Code
- Clone the repository
- Navigate to the extension directory
- Run
npm install -g vsce
(if vsce is not installed)
- Run
vsce package
to generate a .vsix
file
- Follow the steps above to install the generated
.vsix
file
Usage
After installation:
- All files with the
.playground
extension will automatically use C11 syntax highlighting
- All files with
.s
and .asm
extensions will use ARM assembly syntax highlighting
- All files with
.bnf
, .ebnf
, and .grammar
extensions will use BNF/EBNF syntax highlighting
Examples
C11 Example
#include <stdio.h>
// This is a C11 example code
int main(void) {
// C11 variable declarations
int arr[5] = {1, 2, 3, 4, 5};
_Atomic int atomic_var = 10;
// C11 generic selection expression
int type = 1;
int value = _Generic(type,
int: 0,
float: 1,
default: 2);
printf("Hello, Rosetta!\n");
return 0;
}
ARM Assembly Example
/*
* ARM汇编示例
*/
.section .text
.global _start
@ 这是一个简单的ARM汇编程序
_start:
// 设置栈指针
mov sp, #0x8000
; 加载参数
mov r0, [#1](https://github.com/ghotihub/rosetta/issues/1) @ 输出到标准输出
ldr r1, =message
ldr r2, =message_end
sub r2, r2, r1 @ 计算消息长度
/* 系统调用 */
mov r7, [#4](https://github.com/ghotihub/rosetta/issues/4) @ write系统调用
svc 0 @ 触发系统调用
BNF/EBNF Example
/*
* BNF语法示例
*/
// 这是一个简化的JSON语法定义
<json> ::= <object> | <array>
<object> ::= "{" [ <members> ] "}"
<members> ::= <pair> | <pair> "," <members>
<pair> ::= <string> ":" <value>
<value> ::= <string> | <number> | <object> | <array> | "true" | "false" | "null"
/* EBNF示例 */
(* EBNF使用不同的注释样式 *)
# SQL查询的简化EBNF定义
query = select_clause, from_clause, [where_clause], ";" ;
select_clause = "SELECT", column_list ;
column_list = column, {",", column} ;