Basic language support for EasyLang:
Tip
This extension can be downloaded from the Visual Studio Code Marketplace or installed directly within VS Code by searching for "EasyLang".
EasyLang's VS Code extension provides comprehensive syntax highlighting driven by a TextMate grammar (v0.1.3) that recognizes all major language constructs:
- Control Flow:
if,then,else,repeat,while,from,to,do,continue,break,return,try,handle - Declarations:
let,constant,be(reassignment),=(assignment),define - Pattern Matching:
match,when,otherwise,with - Logical Operators:
and,or,not,equals,not equals - Comparison:
less,greater(word-based),==,!=,<,>,<=,>=(symbol-based) - Arithmetic: Word-based (
plus,minus,mul,div,modulus,expo) and symbol-based (+,-,*,/,%,**,//) - Type Keywords:
int,float,text,boolean - Comments: Single-line (
$) and block ($$ ... $$) comments - Strings & Numbers: Double-quoted strings with escape sequences, integers and floats
- Object-Oriented:
define class,define method,make,selfkeyword - Module System:
bring,as(for imports) - File I/O:
print,read,open,close,readline,writeline,as,for,into,with - Collections: Dictionary literals with
{ key: value }syntax
Automatically recognizes and opens .elang and .elangh files with EasyLang syntax highlighting enabled.
Install the EasyLang extension from the VS Code Marketplace, or launch VS Code Quick Open (Ctrl+P) and paste:
ext install Greenbugx0xNA.easylang
Then open or create files with .elang or .elangh extensions to get instant EasyLang-aware syntax highlighting.
Combine this extension with your preferred VS Code theme to fine-tune the colors applied to the EasyLang TextMate scopes. Different themes will render syntax tokens with varying color schemes. The grammar file easylang.tmLanguage.json defines all scope names for theme customization.
$ This is a line comment
$$ This is a
block comment
spanning multiple lines
$$
let count be 5 $ integer
let pi be 3.14159 $ float
let name be "Alice" $ text/string
let active be true $ boolean
let empty be null $ null value
let x = 10 $ initialization with =
constant TIMEOUT = 5 $ immutable constant
x be 20 $ reassignment with be
Control flow uses bracket-based blocks [ ... ] instead of end keywords:
if score greater 90 then [
print "Excellent!"
] else if score greater 80 then [
print "Good!"
] else [
print "Keep trying"
]
$ Counted loop
repeat from i = 1 to 5: do [
print i
]
$ While loop
repeat while counter greater 0: do [
print counter
counter be counter minus 1
]
$ ForEach loop
repeat item from myList: do [
print item
]
$ Free function with parameters
define add(x, y): do [
return x plus y
]
$ Free function without parameters
define greet(): do [
print "Hello!"
]
$ Class definition with methods
define class Person: [
let name be "Unknown"
let age be 0
define method when_created(n, a): do [
self.name be n
self.age be a
]
define method introduce(): do [
print "I am " plus self.name
]
]
$ Create instance
make person1 be Person("Alice", 25)
person1.introduce()
match day with [
when "Monday" then [
print "Start of week"
]
when "Friday" or "Saturday" or "Sunday" then [
print "Near weekend"
]
otherwise [
print "Midweek day"
]
]
let numbers be [1, 2, 3, 4, 5]
print numbers[0] $ access element
numbers.push(6) $ add element
numbers.pop() $ remove last element
print numbers.length() $ get size
let user be { name: "Bob", age: 30, active: true }
print user["name"] $ access by key
user["email"] be "bob@example.com" $ add/update key
print user.keys() $ get all keys
print user.values() $ get all values
print "Hello, World!"
read userInput
$ File operations
open "data.txt" as file for read
readline file into line
print line
close file
open "output.txt" as out for write
writeline out with "Result: 42"
close out
try [
let result be 10 div 0 $ might fail
] handle error [
print "Error occurred!"
]
bring "strings" as str
bring "math.elangh"
bring "time" as t
print str.upper("hello")
print math.sqrt(16)
5 plus 3 $ 8
10 minus 4 $ 6
3 mul 4 $ 12
20 div 5 $ 4.0
10 modulus 3 $ 1
2 expo 3 $ 8
5 + 3 $ 8
10 - 4 $ 6
3 * 4 $ 12
20 / 5 $ 4.0
10 % 3 $ 1
2 ** 3 $ 8 (power)
10 // 3 $ 3 (integer division)
x less y
x greater y
x equals y
x == y
x != y
x < y
x > y
x <= y
x >= y
true and false $ false
true or false $ true
not true $ false
let x = 5 $ initialization
x be 10 $ reassignment
x += 5 $ compound assignment (add)
x -= 2 $ compound assignment (subtract)
x *= 3 $ compound assignment (multiply)
x /= 2 $ compound assignment (divide)
The extension uses a comprehensive TextMate grammar (easylang.tmLanguage.json) that defines tokenization rules for all EasyLang language features. The grammar includes:
- Scope categories: 15+ distinct pattern groups for precise highlighting
- Bracket-based blocks: Full support for
[ ]delimited code blocks - Dictionary literals: Special handling for
{ key: value }syntax - Module system: Recognition of
bringimports andasaliases - Operator separation: Distinct scopes for arithmetic, comparison, and logical operators
- Word operators: Dedicated patterns for English-like operators
This ensures consistent and accurate syntax highlighting across different color themes in VS Code.
print "Hello, World!"
define factorial(n): do [
if n less 2 then [
return 1
]
return n mul factorial(n minus 1)
]
print factorial(5) $ Output: 120
bring "strings" as str
let users be [
{ name: "Alice", score: 95 },
{ name: "Bob", score: 87 },
{ name: "Charlie", score: 92 }
]
repeat user from users: do [
let status be "Pass"
if user["score"] less 90 then [
status be "Review"
]
print str.upper(user["name"]) plus ": " plus status
]
- Visual Studio Code v1.80.0 or later
- EasyLang 0.1.2 or compatible versions
For issues, feature requests, or contributions, visit the GitHub repository.
This extension is released under the MIT License. See LICENSE file for details.
- Updated TextMate grammar (v013) with enhanced operator support
- Added dictionary literal syntax highlighting
- Improved module import keyword recognition
- Fixed integer division operator patterns
- Separated comparison and arithmetic operator scopes
- Added
definekeyword highlighting - Enhanced file I/O keyword modifiers