Carbon language support by sirkingbinx · Pull Request #7011 · github-linguist/linguist · GitHub
Skip to content

Carbon language support#7011

Merged
lildude merged 8 commits into
github-linguist:masterfrom
sirkingbinx:master
Aug 29, 2024
Merged

Carbon language support#7011
lildude merged 8 commits into
github-linguist:masterfrom
sirkingbinx:master

Conversation

@sirkingbinx

@sirkingbinx sirkingbinx commented Aug 23, 2024

Copy link
Copy Markdown

Adds support for the Carbon language. Carbon is an experimental language developed by Google.

Checklist

Closes #6013

@sirkingbinx sirkingbinx requested a review from a team as a code owner August 23, 2024 22:42

@lildude lildude left a comment

Copy link
Copy Markdown
Member

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.

@sirkingbinx sirkingbinx requested a review from lildude August 24, 2024 17:07
@sirkingbinx

sirkingbinx commented Aug 24, 2024

Copy link
Copy Markdown
Author

@lildude

lildude commented Aug 25, 2024

Copy link
Copy Markdown
Member

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.

@sirkingbinx

sirkingbinx commented Aug 25, 2024 via email

Copy link
Copy Markdown
Author

@Alhadis

Alhadis commented Aug 25, 2024

Copy link
Copy Markdown
Collaborator

@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
}

@sirkingbinx

Copy link
Copy Markdown
Author

@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:

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
}

@sirkingbinx

Copy link
Copy Markdown
Author

I've experimented with a couple and found the syntax for V works the best:

9bdc91c adds V syntax highlighting to Carbon files

Comment thread lib/linguist/languages.yml
Co-authored-by: John Gardner <gardnerjohng@gmail.com>
@sirkingbinx

Copy link
Copy Markdown
Author

Thanks for the suggestion, it was committed

@sirkingbinx sirkingbinx requested a review from Alhadis August 26, 2024 01:11
Alhadis
Alhadis previously approved these changes Aug 26, 2024
@Alhadis

Alhadis commented Aug 26, 2024

Copy link
Copy Markdown
Collaborator

@lildude lildude left a comment

Copy link
Copy Markdown
Member

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.

@lildude lildude added this pull request to the merge queue Aug 29, 2024
Merged via the queue into github-linguist:master with commit d378ac3 Aug 29, 2024
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Dec 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Language: Carbon

3 participants