Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ vendor/grammars/Slash.tmbundle:
vendor/grammars/Stata.tmbundle:
- source.mata
- source.stata
vendor/grammars/strata-grammar:
- source.strata
vendor/grammars/Stylus:
- source.stylus
vendor/grammars/Sublime-Coq:
Expand Down
9 changes: 9 additions & 0 deletions lib/linguist/heuristics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ disambiguations:
named_pattern: vba
- language: Visual Basic 6.0
named_pattern: vb-module
- extensions: [".str"]
rules:
- language: Strata
pattern: >-
(?x)
\\b (func) \\b |
\\b import \\s+ \\w+ \\s+ from \\s+ |
(std|package):: \\w+ |
=>
- extensions: ['.bb']
rules:
- language: BlitzBasic
Expand Down
8 changes: 8 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7496,6 +7496,14 @@ Stata:
tm_scope: source.stata
ace_mode: text
language_id: 358
Strata:
type: programming
color: "#4B0082"
extensions:
- ".str"
tm_scope: source.strata
ace_mode: text
language_id: 744998756
StringTemplate:
type: markup
color: "#3fb34f"
Expand Down
95 changes: 95 additions & 0 deletions samples/Strata/algorithms.str
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))
66 changes: 66 additions & 0 deletions samples/Strata/functions.str
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)
46 changes: 46 additions & 0 deletions vendor/grammars/strata-grammar/strata.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
Copy link
Collaborator

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-grammar program 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

"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": "\\*/" }
]
}
}
}