-
Notifications
You must be signed in to change notification settings - Fork 5k
Added Strata Language #7749
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
Draft
oopsio
wants to merge
9
commits into
github-linguist:main
Choose a base branch
from
oopsio:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+226
−0
Draft
Added Strata Language #7749
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c43fccd
Update languages.yml
oopsio ff022c8
Merge branch 'github-linguist:main' into main
oopsio ed773fd
Added Strata language
oopsio 28d0843
Add support for Strata language in heuristics
oopsio 52d6b26
Merge branch 'main' into main
oopsio a09b901
Merge branch 'main' into main
oopsio ff3535d
Merge branch 'main' into main
oopsio fb19857
Update lib/linguist/heuristics.yml
oopsio 3b644e9
Delete SCIL language configuration
oopsio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| // Examples: Common Algorithms | ||
| // Demonstrates: practical algorithm implementations | ||
|
|
||
| import io from str | ||
| import math from str | ||
|
|
||
| io.print("=== Fibonacci Sequence ===") | ||
| var a: int = 0 | ||
| var b: int = 1 | ||
|
|
||
| for (var i: int = 0; i < 10; var i: int = i + 1) { | ||
| io.print(a) | ||
| let temp: int = a + b | ||
| var a: int = b | ||
| var b: int = temp | ||
| } | ||
|
|
||
| io.print("=== Prime Number Check ===") | ||
|
|
||
| func isPrime(n: int) => bool { | ||
| if (n <= 1) { | ||
| return false | ||
| } | ||
|
|
||
| if (n == 2) { | ||
| return true | ||
| } | ||
|
|
||
| if (n % 2 == 0) { | ||
| return false | ||
| } | ||
|
|
||
| var i: int = 3 | ||
| while (i * i <= n) { | ||
| if (n % i == 0) { | ||
| return false | ||
| } | ||
| var i: int = i + 2 | ||
| } | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| io.print("Primes up to 30:") | ||
| for (var num: int = 2; num <= 30; var num: int = num + 1) { | ||
| if (isPrime(num)) { | ||
| io.print(num) | ||
| } | ||
| } | ||
|
|
||
| io.print("=== Sum of Digits ===") | ||
|
|
||
| func sumDigits(n: int) => int { | ||
| var sum: int = 0 | ||
| var num: int = n | ||
|
|
||
| while (num > 0) { | ||
| var digit: int = num % 10 | ||
| var sum: int = sum + digit | ||
| var num: int = num / 10 | ||
| } | ||
|
|
||
| return sum | ||
| } | ||
|
|
||
| io.print(sumDigits(12345)) | ||
| io.print(sumDigits(999)) | ||
|
|
||
| io.print("=== GCD (Greatest Common Divisor) ===") | ||
|
|
||
| func gcd(a: int, b: int) => int { | ||
| while (b != 0) { | ||
| let temp: int = b | ||
| var b: int = a % b | ||
| var a: int = temp | ||
| } | ||
| return a | ||
| } | ||
|
|
||
| io.print(gcd(48, 18)) | ||
| io.print(gcd(100, 75)) | ||
|
|
||
| io.print("=== Linear Search ===") | ||
|
|
||
| func contains(target: int) => bool { | ||
| for (var i: int = 1; i <= 10; var i: int = i + 1) { | ||
| if (i == target) { | ||
| return true | ||
| } | ||
| } | ||
| return false | ||
| } | ||
|
|
||
| io.print(contains(5)) | ||
| io.print(contains(15)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // Examples: Function Declarations | ||
| // Demonstrates: func with type annotations and return types | ||
|
|
||
| import io from str | ||
|
|
||
| // Simple function - no parameters | ||
| func greet() => string { | ||
| return "Hello, Strata!" | ||
| } | ||
|
|
||
| io.print("=== Greeting ===") | ||
| io.print(greet()) | ||
|
|
||
| // Function with parameters | ||
| func add(a: int, b: int) => int { | ||
| return a + b | ||
| } | ||
|
|
||
| io.print("=== Addition ===") | ||
| let result: int = add(10, 20) | ||
| io.print(result) | ||
|
|
||
| // Function with multiple parameters | ||
| func multiply(x: int, y: int) => int { | ||
| return x * y | ||
| } | ||
|
|
||
| io.print("=== Multiplication ===") | ||
| io.print(multiply(6, 7)) | ||
|
|
||
| // Function with boolean return | ||
| func isEven(n: int) => bool { | ||
| return n % 2 == 0 | ||
| } | ||
|
|
||
| io.print("=== Is Even Check ===") | ||
| io.print(isEven(4)) | ||
| io.print(isEven(7)) | ||
|
|
||
| // Function with float | ||
| func average(a: float, b: float) => float { | ||
| return (a + b) / 2 | ||
| } | ||
|
|
||
| io.print("=== Average ===") | ||
| io.print(average(10.5, 20.5)) | ||
|
|
||
| // Function that uses loops | ||
| func factorial(n: int) => int { | ||
| var result: int = 1 | ||
| for (var i: int = 1; i <= n; var i: int = i + 1) { | ||
| var result: int = result * i | ||
| } | ||
| return result | ||
| } | ||
|
|
||
| io.print("=== Factorial ===") | ||
| io.print(factorial(5)) | ||
|
|
||
| // Function that doesn't return a value | ||
| func printNumber(n: int) => any { | ||
| io.print(n) | ||
| } | ||
|
|
||
| io.print("=== Print via Function ===") | ||
| printNumber(42) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| { | ||
| "scopeName": "source.strata", | ||
| "name": "Strata", | ||
| "patterns": [ | ||
| { "include": "#keywords" }, | ||
| { "include": "#modules" }, | ||
| { "include": "#functions" }, | ||
| { "include": "#strings" }, | ||
| { "include": "#numbers" }, | ||
| { "include": "#comments" } | ||
| ], | ||
| "repository": { | ||
| "keywords": { | ||
| "patterns": [ | ||
| { "name": "keyword.control.strata", "match": "\\b(func|create|type|set|var|import|from)\\b" } | ||
| ] | ||
| }, | ||
| "modules": { | ||
| "patterns": [ | ||
| { "name": "support.other.module.strata", "match": "\\b(str\\.io|str\\.math|str\\.util|str\\.time|str\\.lang|str\\.net|str\\.sql|str\\.xml|str\\.rmi|str\\.security|str\\.text)\\b" } | ||
| ] | ||
| }, | ||
| "functions": { | ||
| "patterns": [ | ||
| { "name": "support.function.strata", "match": "\\b(io\\.print|math\\.sqrt|math\\.pow|math\\.random|util\\.randomInt|time\\.now)\\b" } | ||
| ] | ||
| }, | ||
| "strings": { | ||
| "patterns": [ | ||
| { "name": "string.quoted.single.strata", "match": "'[^']*'" }, | ||
| { "name": "string.quoted.double.strata", "match": "\"[^\"]*\"" } | ||
| ] | ||
| }, | ||
| "numbers": { | ||
| "patterns": [ | ||
| { "name": "constant.numeric.strata", "match": "\\b\\d+\\b" } | ||
| ] | ||
| }, | ||
| "comments": { | ||
| "patterns": [ | ||
| { "name": "comment.line.double-slash.strata", "match": "//.*$" }, | ||
| { "name": "comment.block.strata", "begin": "/\\*", "end": "\\*/" } | ||
| ] | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You haven't added this grammar correctly. You need to use the
script/add-grammarprogram to add the grammar's repository as a submodule (which requires that it exist as an external project).$ ./script/add-grammar https://github.com/user/strata-grammar-repository