Skip to content

Commit 6dcd8ba

Browse files
author
TheDevConnor
committed
Updated char to be byte
1 parent 98d1e50 commit 6dcd8ba

File tree

30 files changed

+474
-554
lines changed

30 files changed

+474
-554
lines changed

.vscode/c_cpp_properties.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

.vscode/launch.json

Lines changed: 0 additions & 17 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 0 additions & 44 deletions
This file was deleted.

config.default.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# config.default.mk
22

3-
CC ?= gcc
3+
CC := gcc
44
CFLAGS ?= -Wall -Wextra -std=c17 -Wno-unused-variable -O2
55
LDFLAGS ?=
66
INCLUDES ?= -Isrc

docs/docs.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Luma provides a straightforward type system with both primitive and compound typ
104104
| `float` | Floating point | 32-bit |
105105
| `double` | Floating point | 64-bit |
106106
| `bool` | Boolean | 1 byte |
107-
| `char` | Unicode Character| 1 byte |
107+
| `byte` | Unicode byteacter| 1 byte |
108108
| `str` | String | Variable |
109109

110110
### Enumerations
@@ -734,14 +734,14 @@ const main -> fn () int {
734734
### Input Functions
735735

736736
```luma
737-
input<T>(prompt: *char) -> T // Read typed input
737+
input<T>(prompt: *byte) -> T // Read typed input
738738
```
739739

740740
The `input` function is generic and reads a value of the specified type:
741741

742742
```luma
743743
const main -> fn () int {
744-
let name: *char = input<*char>("Enter your name: ");
744+
let name: *byte = input<*byte>("Enter your name: ");
745745
let age: int = input<int>("Enter your age: ");
746746
let height: double = input<double>("Enter height (meters): ");
747747
@@ -756,7 +756,7 @@ const main -> fn () int {
756756
### System Commands
757757

758758
```luma
759-
system(command: *char) -> int // Execute system command
759+
system(command: *byte) -> int // Execute system command
760760
```
761761

762762
Execute shell commands from your program:
@@ -780,7 +780,7 @@ Get the size of any type at compile time:
780780
```luma
781781
const main -> fn () int {
782782
outputln("int: ", sizeof<int>); // 8
783-
outputln("char: ", sizeof<char>); // 1
783+
outputln("byte: ", sizeof<byte>); // 1
784784
outputln("double: ", sizeof<double>); // 8
785785
786786
// Use in allocations
@@ -816,7 +816,7 @@ const main -> fn () int {
816816
let rounded: int = cast<int>(pi); // 3
817817
818818
// Between integer types
819-
let small: char = cast<char>(65); // 'A'
819+
let small: byte = cast<byte>(65); // 'A'
820820
let large: int = cast<int>(small); // 65
821821
822822
return 0;
@@ -846,7 +846,7 @@ const main -> fn () int {
846846

847847
```luma
848848
const main -> fn () int {
849-
let ptr: *char = cast<*char>(alloc(10));
849+
let ptr: *byte = cast<*byte>(alloc(10));
850850
defer free(ptr);
851851
852852
// Pointer to integer
@@ -856,7 +856,7 @@ const main -> fn () int {
856856
let offset_addr: int = addr + 5;
857857
858858
// Back to pointer
859-
let offset_ptr: *char = cast<*char>(offset_addr);
859+
let offset_ptr: *byte = cast<*byte>(offset_addr);
860860
861861
return 0;
862862
}
@@ -873,7 +873,7 @@ Luma supports fixed-size arrays with compile-time known sizes.
873873
```luma
874874
// Syntax: [Type; Size]
875875
let numbers: [int; 10]; // Array of 10 integers
876-
let chars: [char; 256]; // Array of 256 characters
876+
let bytes: [byte; 256]; // Array of 256 byteacters
877877
let buffer: [double; 100]; // Array of 100 doubles
878878
879879
// Constants can be arrays too
@@ -928,27 +928,27 @@ const main -> fn () int {
928928

929929
### String Literals
930930

931-
String literals are null-terminated character arrays:
931+
String literals are null-terminated byteacter arrays:
932932

933933
```luma
934934
const main -> fn () int {
935-
// String literal - type is *char
936-
let message: *char = "Hello, World!";
935+
// String literal - type is *byte
936+
let message: *byte = "Hello, World!";
937937
outputln(message);
938938
939939
return 0;
940940
}
941941
```
942942

943-
### Character Literals
943+
### byteacter Literals
944944

945-
Single characters use single quotes:
945+
Single byteacters use single quotes:
946946

947947
```luma
948948
const main -> fn () int {
949-
let letter: char = 'A'; // Character literal
950-
let newline: char = '\n'; // Escape sequence
951-
let tab: char = '\t'; // Tab character
949+
let letter: byte = 'A'; // byteacter literal
950+
let newline: byte = '\n'; // Escape sequence
951+
let tab: byte = '\t'; // Tab byteacter
952952
953953
return 0;
954954
}
@@ -963,7 +963,7 @@ const main -> fn () int {
963963
'\\' // Backslash
964964
'\'' // Single quote
965965
'\"' // Double quote
966-
'\0' // Null character
966+
'\0' // Null byteacter
967967
'\xHH' // Hexadecimal byte (e.g., '\x1b' for ESC)
968968
```
969969

@@ -1023,11 +1023,11 @@ const INTERNAL_CONSTANT: int = 42;
10231023
```luma
10241024
const Person -> struct {
10251025
pub:
1026-
name: *char,
1026+
name: *byte,
10271027
age: int,
10281028
10291029
priv:
1030-
ssn: *char,
1030+
ssn: *byte,
10311031
internal_id: int
10321032
};
10331033
```
@@ -1520,7 +1520,7 @@ mem::memeq(a, b, n) // Check equality
15201520
@use "memory" as mem
15211521
15221522
const main -> fn () int {
1523-
let buffer: *void = mem::calloc(10, sizeof<char>);
1523+
let buffer: *void = mem::calloc(10, sizeof<byte>);
15241524
defer free(buffer);
15251525
15261526
mem::memset(buffer, 65, 10); // Fill with 'A'
@@ -1538,7 +1538,7 @@ String manipulation functions.
15381538
@use "string" as string
15391539
15401540
// Creation
1541-
string::from_char(c) // Create string from char
1541+
string::from_byte(c) // Create string from byte
15421542
string::from_int(n) // Convert int to string
15431543
15441544
// Measurement
@@ -1548,11 +1548,11 @@ string::strlen(s) // Get length
15481548
string::strcmp(s1, s2) // Compare strings
15491549
15501550
// Search
1551-
string::s_char(s, c) // Find character
1551+
string::s_byte(s, c) // Find byteacter
15521552
15531553
// Manipulation
15541554
string::copy(dest, src) // Copy string
1555-
string::n_copy(dest, src, n) // Copy n characters
1555+
string::n_copy(dest, src, n) // Copy n byteacters
15561556
string::cat(dest, s1, s2) // Concatenate
15571557
```
15581558

@@ -1561,11 +1561,11 @@ string::cat(dest, s1, s2) // Concatenate
15611561
@use "string" as string
15621562
15631563
const main -> fn () int {
1564-
let name: *char = "Alice";
1564+
let name: *byte = "Alice";
15651565
let len: int = string::strlen(name);
15661566
outputln("Length: ", len);
15671567
1568-
let num_str: *char = string::from_int(42);
1568+
let num_str: *byte = string::from_int(42);
15691569
defer free(num_str);
15701570
outputln("Number: ", num_str);
15711571
@@ -1629,9 +1629,9 @@ Interactive terminal input functions.
16291629
```luma
16301630
@use "terminal" as term
16311631
1632-
term::getch() // Get single char (no echo, no enter)
1633-
term::getch_silent() // Get char silently
1634-
term::getche() // Get char with echo
1632+
term::getch() // Get single byte (no echo, no enter)
1633+
term::getch_silent() // Get byte silently
1634+
term::getche() // Get byte with echo
16351635
term::kbhit() // Check if key pressed
16361636
term::wait_for_key() // Wait for any key
16371637
term::clear_input_buffer() // Clear input buffer
@@ -1645,10 +1645,10 @@ term::getpass(prompt) // Get password (hidden input)
16451645
16461646
const main -> fn () int {
16471647
outputln("Press any key...");
1648-
let key: char = term::getch();
1649-
outputln("You pressed: ", string::from_char(key));
1648+
let key: byte = term::getch();
1649+
outputln("You pressed: ", string::from_byte(key));
16501650
1651-
let password: *char = term::getpass("Enter password: ");
1651+
let password: *byte = term::getpass("Enter password: ");
16521652
defer free(password);
16531653
outputln("Password entered");
16541654
@@ -1760,7 +1760,7 @@ Access: . :: [] * &
17601760

17611761
```
17621762
int double bool *T [T; N]
1763-
uint float char str void
1763+
uint float byte str void
17641764
```
17651765

17661766
### Common Patterns
@@ -1785,7 +1785,7 @@ if (ptr == cast<*T>(0)) {
17851785
let x: int = m::function();
17861786
17871787
// String operations
1788-
let s: *char = string::from_int(42);
1788+
let s: *byte = string::from_int(42);
17891789
defer free(s);
17901790
```
17911791

src/lexer/lexer.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,6 @@ static const KeywordEntry keywords[] = {
6161
{"false", TOK_FALSE},
6262
{"pub", TOK_PUBLIC},
6363
{"priv", TOK_PRIVATE},
64-
{"void", TOK_VOID},
65-
{"char", TOK_CHAR},
66-
{"str", TOK_STRINGT},
67-
{"int", TOK_INT},
68-
{"float", TOK_FLOAT},
69-
{"double", TOK_DOUBLE},
70-
{"bool", TOK_BOOL},
7164
{"let", TOK_VAR},
7265
{"fn", TOK_FN},
7366
{"output", TOK_PRINT},
@@ -85,6 +78,14 @@ static const KeywordEntry keywords[] = {
8578
{"input", TOK_INPUT},
8679
{"system", TOK_SYSTEM},
8780

81+
{"void", TOK_VOID},
82+
{"byte", TOK_CHAR},
83+
{"str", TOK_STRINGT},
84+
{"int", TOK_INT},
85+
{"float", TOK_FLOAT},
86+
{"double", TOK_DOUBLE},
87+
{"bool", TOK_BOOL},
88+
8889
{"__syscall__", TOK_SYSCALL},
8990
};
9091

src/lsp/language-support/syntaxes/luma.tmLanguage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
"patterns": [
150150
{
151151
"name": "support.type.primitive.luma",
152-
"match": "\\b(int|uint|float|double|bool|str|void|char|short|long|nil)\\b"
152+
"match": "\\b(int|uint|float|double|bool|str|void|byte|short|long|nil)\\b"
153153
},
154154
{
155155
"name": "entity.name.type.luma",

std/arena.lx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@use "memory" as memory
44

55
pub const Arena -> struct {
6-
memory: *char,
6+
memory: *byte,
77
offset: int,
88
capacity: int,
99
};

0 commit comments

Comments
 (0)