Files
carbon-lang/utils/textmate/Samples/main.carbon
T
Mats Larsen 8ba4916ab4 Implement minimal textmate language definition (#1595)
TextMate is the go-to definition language for syntax highlighting for editors lack dedicated language support for a given programming language. This patch contains a very minimal, yet functional TextMate bundle definition for Carbon.

This allows Carbon users to import the TextMate bundle into their editors to get basic syntax highlighting for Carbon code until we have a more solid specification for the language (that's when the fun with dedicated plugins/extensions begins!).

**Support**
- String literals with escape codes (currently using C highlighting rules)
- Numeric literals in decimal, hexadecimal and binary (lacks _ separator support though)
- Single and multi-line comments
- Highlighting of all? (let me know if some are missing) keywords in the language

Here is an image of the highlighting in action in IntelliJ Dracula mode
![image](https://user-images.githubusercontent.com/42585241/180587912-23b5ae3e-2bdb-49a1-83e8-24e6e0b7cfb5.png)
2022-07-28 11:32:41 -07:00

47 lines
880 B
Plaintext

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// More single line comments
package Carbon api;
interface HasValueParam(T:! Type, V:! T) {
fn Go[me: Self]() -> T;
}
impl () as HasValueParam(i32, 5) {
fn Go[me: Self]() -> i32 { return 42; }
}
class Point {
fn Origin() -> Self {
return {.x = 0, .y = 0};
}
var x: i32;
var y: i32;
}
fn Procedure() -> i32 {
returned var zoop: i32 = 0;
while (DoSomeJob() {
zoop += 1;
}
return var;
}
fn Main() -> i32 {
let str = "Hello world";
let hex = 0xABCDEF1234567890;
let bin = 0b0000111001010010;
let dec = 123456789012345678;
let big: Carbon.Int(1024) = 1234;
let aaa: auto = "Carbon";
let view: StringView = "Carbon";
return Procedure();
}