Carbon language support#7011
Conversation
lildude
left a comment
There was a problem hiding this comment.
Please follow the CONTRIBUTING.md instructions. We will also need a search result for each extension.
|
Do you really want to add support without syntax highlighting? Normally the only reason people add support for a language is to get syntax highlighting on GitHub. |
|
There is no syntax highlighter for it avaliable, although I may try to add one in the future.
|
|
@BTDW Usually when we add support for a language that doesn't have a syntax highlighting grammar (or one released under a permissive license), we sometimes use another language's grammar as a fallback that happens to produce "good enough" highlighting. For example, here's one of your Carbon samples highlighted using Rust: (Click to toggle)package Shapes api;
import Math;
// Circle
class Circle {
var Radius: f32 = 1;
const var Diameter: f32 = self.Radius * 2;
const var Pi: f32 = Math.Pi;
fn Area() -> self;
fn Circumference() -> self;
}
fn Circle.Area() -> self {
return Math.Pi * .Radius ^ 2
}
fn Circle.Circumference() -> self {
return 2 * Math.Pi * .Radius
}
// Rectangle
class Rectangle {
var Width: f32 = 3;
var Height: f32 = 1;
fn Area() -> self;
}
fn Rectangle.Area() -> self {
return .Width * .Height;
}
// Square (Note: Provides same functions as "Rectangle" class.)
class Square {
var Width: f32 = 3;
var Height: f32 = 1;
fn Area() -> self;
}
fn Square.Area() -> self {
return .Width * .Height;
}
// Triangle
class Triangle {
var Width: f32 = 3;
var Height: f32 = 3;
fn Area() -> self;
}
fn Triangle.Area() -> self {
return (.Width * .Height) / 2;
}
// Hexagon
class Hexagon {
var Side: f32 = 5;
fn Area() -> self;
}
fn Hexagon.Area() -> self {
return ((3 * 1.732) / 2) * .Side ^ 2
} |
I've experimented with a couple and found the syntax for V works the best: package Shapes api;
import Math;
// Circle
class Circle {
var Radius: f32 = 1;
const var Diameter: f32 = self.Radius * 2;
const var Pi: f32 = Math.Pi;
fn Area() -> self;
fn Circumference() -> self;
}
fn Circle.Area() -> self {
return Math.Pi * .Radius ^ 2
}
fn Circle.Circumference() -> self {
return 2 * Math.Pi * .Radius
}
// Rectangle
class Rectangle {
var Width: f32 = 3;
var Height: f32 = 1;
fn Area() -> self;
}
fn Rectangle.Area() -> self {
return .Width * .Height;
}
// Square (Note: Provides same functions as "Rectangle" class.)
class Square {
var Width: f32 = 3;
var Height: f32 = 1;
fn Area() -> self;
}
fn Square.Area() -> self {
return .Width * .Height;
}
// Triangle
class Triangle {
var Width: f32 = 3;
var Height: f32 = 3;
fn Area() -> self;
}
fn Triangle.Area() -> self {
return (.Width * .Height) / 2;
}
// Hexagon
class Hexagon {
var Side: f32 = 5;
fn Area() -> self;
}
fn Hexagon.Area() -> self {
return ((3 * 1.732) / 2) * .Side ^ 2
} |
Co-authored-by: John Gardner <gardnerjohng@gmail.com>
|
Thanks for the suggestion, it was committed |

Adds support for the Carbon language. Carbon is an experimental language developed by Google.
Checklist
#222222#000000, but they are similar.Closes #6013