-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Carbon language support #7011
Carbon language support #7011
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the CONTRIBUTING.md instructions. We will also need a search result for each extension.
A basic sample in |
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 <[email protected]>
Thanks for the suggestion, it was committed |
@btdw You'll need to fix the failed test reported here. It simply involves updating --- expected
+++ actual
@@ -83,6 +83,7 @@
- **Cairo:** [xshitaka/atom-language-cairo](https://github.com/xshitaka/atom-language-cairo)
- **CameLIGO:** [pewulfman/Ligo-grammar](https://github.com/pewulfman/Ligo-grammar)
- **Cap'n Proto:** [textmate/capnproto.tmbundle](https://github.com/textmate/capnproto.tmbundle)
+- **Carbon:** [0x9ef/vscode-vlang](https://github.com/0x9ef/vscode-vlang) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks.
Note: this PR will not be merged until close to when the next release is made. See here for more details.
Adds support for the Carbon language. Carbon is an experimental language developed by Google.
Checklist
#222222
#000000
, but they are similar.Closes #6013