aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/command_line_interface.elna8
-rw-r--r--source/common.elna12
-rw-r--r--source/cstdio.elna12
-rw-r--r--source/cstdlib.elna2
-rw-r--r--source/cstring.elna12
-rw-r--r--source/lexer.elna42
-rw-r--r--source/main.elna44
7 files changed, 66 insertions, 66 deletions
diff --git a/source/command_line_interface.elna b/source/command_line_interface.elna
index 6aaf440..62965db 100644
--- a/source/command_line_interface.elna
+++ b/source/command_line_interface.elna
@@ -9,15 +9,15 @@ import cstdlib, cstring, common
type
CommandLine* = record
- input: ^Char;
- output: ^Char;
+ input: ^Word8;
+ output: ^Word8;
lex: Bool;
parse: Bool
end
-proc parse_command_line*(argc: Int; argv: ^^Char): ^CommandLine
+proc parse_command_line*(argc: Int; argv: ^^Word8): ^CommandLine
var
- parameter: ^Char
+ parameter: ^Word8
i: Int
result: ^CommandLine
parsed: Bool
diff --git a/source/common.elna b/source/common.elna
index 1bdfa1f..c5b67f8 100644
--- a/source/common.elna
+++ b/source/common.elna
@@ -17,13 +17,13 @@ type
proc write*(fd: Int; buf: Pointer; Word: Int): Int
extern
-proc write_s*(value: []const Char)
+proc write_s*(value: []const Word8)
begin
(* fwrite(cast(value.ptr: Pointer), value.length, 1u, stdout) *)
write(1, cast(value.ptr: Pointer), cast(value.length: Int))
return
-proc write_z*(value: ^Char)
+proc write_z*(value: ^Word8)
begin
write(1, cast(value: Pointer), cast(strlen(value): Int))
return
@@ -37,7 +37,7 @@ begin
end
return
-proc write_c*(value: Char)
+proc write_c*(value: Word8)
begin
putchar(cast(value: Int));
fflush(nil)
@@ -47,7 +47,7 @@ proc write_i*(value: Int)
var
digit: Int
n: Word
- buffer: [10]Char
+ buffer: [10]Word8
begin
n := 10u;
@@ -58,7 +58,7 @@ begin
digit := value % 10;
value := value / 10;
- buffer[n] := cast(cast('0': Int) + digit: Char);
+ buffer[n] := cast(cast('0': Int) + digit: Word8);
n := n - 1u
end;
while n < 10u do
@@ -78,7 +78,7 @@ begin
return nil
(* Returns true or false depending whether two strings are equal. *)
-proc string_compare*(lhs_pointer: ^Char; lhs_length: Word; rhs_pointer: []const Char): Bool
+proc string_compare*(lhs_pointer: ^Word8; lhs_length: Word; rhs_pointer: []const Word8): Bool
var
result: Bool
begin
diff --git a/source/cstdio.elna b/source/cstdio.elna
index f44a972..cd218fe 100644
--- a/source/cstdio.elna
+++ b/source/cstdio.elna
@@ -10,7 +10,7 @@ var
stdout*: ^FILE := extern
stderr*: ^FILE := extern
-proc fopen*(pathname, mode: ^const Char): ^FILE
+proc fopen*(pathname, mode: ^const Word8): ^FILE
extern
proc fclose*(stream: ^FILE): Int
@@ -37,22 +37,22 @@ extern
proc fputc*(c: Int; stream: ^FILE): Word
extern
-proc perror*(s: ^const Char)
+proc perror*(s: ^const Word8)
extern
-proc puts*(s: ^const Char): Int
+proc puts*(s: ^const Word8): Int
extern
proc putchar*(c: Int): Int
extern
-proc sprintf*(str: Pointer; format: ^const Char; number: Word): Int
+proc sprintf*(str: Pointer; format: ^const Word8; number: Word): Int
extern
-proc fprintf*(stream: Pointer; format: ^const Char; number: Word): Int
+proc fprintf*(stream: Pointer; format: ^const Word8; number: Word): Int
extern
-proc fdopen*(fildes: Int; mode: ^const Char): Pointer
+proc fdopen*(fildes: Int; mode: ^const Word8): Pointer
extern
end.
diff --git a/source/cstdlib.elna b/source/cstdlib.elna
index 32669c1..0f78c8e 100644
--- a/source/cstdlib.elna
+++ b/source/cstdlib.elna
@@ -14,7 +14,7 @@ extern
proc realloc*(ptr: Pointer; size: Word): Pointer
extern
-proc atoi*(str: ^Char): Int
+proc atoi*(str: ^Word8): Int
extern
proc exit*(code: Int): !
diff --git a/source/cstring.elna b/source/cstring.elna
index 0b4bd90..9290a5c 100644
--- a/source/cstring.elna
+++ b/source/cstring.elna
@@ -2,7 +2,7 @@
v. 2.0. If a copy of the MPL was not distributed with this file, You can
obtain one at https://mozilla.org/MPL/2.0/. *)
-proc memset*(ptr: Pointer; c: Int; n: Word): ^Char
+proc memset*(ptr: Pointer; c: Int; n: Word): ^Word8
extern
proc memcpy*(dst: Pointer; src: const Pointer; n: Word)
@@ -11,19 +11,19 @@ extern
proc memcmp*(s1, s2: const Pointer; n: Word): Int
extern
-proc strcmp*(s1: ^const Char; s2: ^const Char): Int
+proc strcmp*(s1: ^const Word8; s2: ^const Word8): Int
extern
-proc strncmp*(s1: ^const Char; s2: ^const Char; n: Word): Int
+proc strncmp*(s1: ^const Word8; s2: ^const Word8; n: Word): Int
extern
-proc strncpy*(dst: ^Char; src: ^const Char; dsize: Word): ^Char
+proc strncpy*(dst: ^Word8; src: ^const Word8; dsize: Word): ^Word8
extern
-proc strcpy*(dst: ^Char; src: ^const Char): ^Char
+proc strcpy*(dst: ^Word8; src: ^const Word8): ^Word8
extern
-proc strlen*(ptr: ^const Char): Word
+proc strlen*(ptr: ^const Word8): Word
extern
end.
diff --git a/source/lexer.elna b/source/lexer.elna
index fa79917..83e89df 100644
--- a/source/lexer.elna
+++ b/source/lexer.elna
@@ -28,17 +28,17 @@ type
)
ElnaLexerToken* = record
kind: ElnaLexerKind;
- start: []const Char; (* DEPRECATED *)
+ start: []const Word8; (* DEPRECATED *)
position: ElnaPosition
end
ElnaLexerBooleanToken* = record(ElnaLexerToken)
value: Bool
end
ElnaLexerCharacterToken* = record(ElnaLexerToken)
- value: Char
+ value: Word8
end
ElnaLexerStringToken* = record(ElnaLexerToken)
- value: []const Char
+ value: []const Word8
end
ElnaLexerIntegerToken* = record(ElnaLexerToken)
value: Int
@@ -55,19 +55,19 @@ type
ElnaLexerCursor = record
state: ElnaLexerState;
- start: ^Char;
- finish: ^Char;
+ start: ^Word8;
+ finish: ^Word8;
token: ^ElnaLexerToken;
position: ElnaPosition
end
BufferPosition* = record
- iterator: ^Char;
+ iterator: ^Word8;
location: ElnaLocation
end
Lexer* = record
input: ^FILE;
- buffer: ^Char;
+ buffer: ^Word8;
size: Word;
length: Word;
start: BufferPosition;
@@ -513,7 +513,7 @@ begin
cursor^.position.end_location.column := cursor^.position.end_location.column + 1u
return
-proc elna_lexer_classify_space(start_position: ^Char; location: ^ElnaLocation)
+proc elna_lexer_classify_space(start_position: ^Word8; location: ^ElnaLocation)
begin
if start_position^ = '\n' then
location^.line := location^.line + 1u;
@@ -532,7 +532,7 @@ begin
result^.position := position^
return result
-proc elna_lexer_classify_keyword(position_start, position_end: ^Char; position: ^ElnaPosition): ^ElnaLexerToken
+proc elna_lexer_classify_keyword(position_start, position_end: ^Word8; position: ^ElnaPosition): ^ElnaLexerToken
var
result: ^ElnaLexerToken
result_length: Word
@@ -587,9 +587,9 @@ begin
end
return result
-proc elna_lexer_classify_delimited(start_position, end_position: ^Char; position: ^ElnaPosition): ^ElnaLexerToken
+proc elna_lexer_classify_delimited(start_position, end_position: ^Word8; position: ^ElnaPosition): ^ElnaLexerToken
var
- delimiter: Char
+ delimiter: Word8
result: ^ElnaLexerToken
begin
delimiter := start_position^;
@@ -604,7 +604,7 @@ begin
result^.start := start_position[1 to cast(end_position - start_position: Word)]
return result
-proc elna_lexer_classify_integer(start_position, end_position: ^Char; position: ^ElnaPosition): ^ElnaLexerToken
+proc elna_lexer_classify_integer(start_position, end_position: ^Word8; position: ^ElnaPosition): ^ElnaLexerToken
var
result: ^ElnaLexerToken
begin
@@ -612,9 +612,9 @@ begin
result^.start := start_position[1 to cast(end_position - start_position: Word)]
return result
-proc elna_lexer_classify_finalize(start_position: ^Char; position: ^ElnaPosition): ^ElnaLexerToken
+proc elna_lexer_classify_finalize(start_position: ^Word8; position: ^ElnaPosition): ^ElnaLexerToken
var
- character: Char
+ character: Word8
result: ^ElnaLexerToken
begin
character := start_position^;
@@ -634,9 +634,9 @@ begin
end
return result
-proc elna_lexer_classify_single(start_position: ^Char; position: ^ElnaPosition): ^ElnaLexerToken
+proc elna_lexer_classify_single(start_position: ^Word8; position: ^ElnaPosition): ^ElnaLexerToken
var
- character: Char
+ character: Word8
result: ^ElnaLexerToken
begin
result := malloc(#size(ElnaLexerToken));
@@ -675,10 +675,10 @@ begin
end
return result
-proc elna_lexer_classify_composite(start_position, one_before_last: ^Char; position: ^ElnaPosition): ^ElnaLexerToken
+proc elna_lexer_classify_composite(start_position, one_before_last: ^Word8; position: ^ElnaPosition): ^ElnaLexerToken
var
- first_character: Char
- last_character: Char
+ first_character: Word8
+ last_character: Word8
result: ^ElnaLexerToken
begin
first_character := start_position^;
@@ -739,7 +739,7 @@ return token
proc elna_lexer_execute_transition(cursor: ^ElnaLexerCursor): ^ElnaLexerToken
var
next_transition: ^ElnaLexerTransition
- current_character: Char
+ current_character: Word8
begin
current_character := cursor^.finish^;
next_transition := elna_lexer_get_transition(cursor^.state,
@@ -750,7 +750,7 @@ return elna_lexer_execute_action(cursor, next_transition^.action)
(**
* One time lexer initialization.
*)
-proc elna_lexer_initialize(cursor: ^ElnaLexerCursor; code_pointer: ^Char)
+proc elna_lexer_initialize(cursor: ^ElnaLexerCursor; code_pointer: ^Word8)
begin
elna_lexer_classifications();
elna_lexer_transitions();
diff --git a/source/main.elna b/source/main.elna
index 369d013..d539d0d 100644
--- a/source/main.elna
+++ b/source/main.elna
@@ -6,7 +6,7 @@ import cstdio, cstdlib, cstring, cctype, common, command_line_interface, lexer
type
SourceFile* = record
- buffer: [1024]Char;
+ buffer: [1024]Word8;
handle: ^FILE;
size: Word;
index: Word
@@ -22,7 +22,7 @@ type
input: Pointer;
empty: proc(stream: Pointer): Bool;
advance: proc(stream: Pointer);
- head: proc(stream: Pointer): Char
+ head: proc(stream: Pointer): Word8
end
Tokenizer* = record
length: Word;
@@ -42,9 +42,9 @@ var
proc reallocarray(ptr: Pointer; n: Word; size: Word): Pointer
return realloc(ptr, n * size)
-proc string_dup(origin: []const Char): []const Char
+proc string_dup(origin: []const Word8): []const Word8
var
- copy: ^Char
+ copy: ^Word8
begin
copy := malloc(origin.length);
strncpy(copy, origin.ptr, origin.length)
@@ -59,13 +59,13 @@ begin
result.size := 0u
return result
-proc string_buffer_push(buffer: ^StringBuffer; char: Char)
+proc string_buffer_push(buffer: ^StringBuffer; char: Word8)
begin
if buffer^.size >= buffer^.capacity then
buffer^.capacity := buffer^.capacity + 1024u;
buffer^.data := realloc(buffer^.data, buffer^.capacity)
end;
- cast(buffer^.data + buffer^.size: ^Char)^ := cast(char: Char);
+ cast(buffer^.data + buffer^.size: ^Word8)^ := cast(char: Word8);
buffer^.size := buffer^.size + 1u
return
@@ -74,11 +74,11 @@ begin
buffer^.size := buffer^.size - count
return
-proc string_buffer_clear(buffer: ^StringBuffer): []const Char
+proc string_buffer_clear(buffer: ^StringBuffer): []const Word8
var
- result: []const Char
+ result: []const Word8
begin
- result := cast(buffer^.data: ^Char)[1 to buffer^.size];
+ result := cast(buffer^.data: ^Word8)[1 to buffer^.size];
buffer^.size := 0u
return result
@@ -86,7 +86,7 @@ return result
Source code stream procedures.
*)
-proc read_source(filename: ^Char): ^SourceFile
+proc read_source(filename: ^Word8): ^SourceFile
var
result: ^SourceFile
file_handle: ^FILE
@@ -113,7 +113,7 @@ begin
end
return source_file^.size = 0u
-proc source_file_head(source_input: Pointer): Char
+proc source_file_head(source_input: Pointer): Word8
var
source_file: ^SourceFile
begin
@@ -132,7 +132,7 @@ return
proc source_code_empty(source_code: ^SourceCode): Bool
return source_code^.empty(source_code^.input)
-proc source_code_head(source_code: SourceCode): Char
+proc source_code_head(source_code: SourceCode): Word8
return source_code.head(source_code.input)
proc source_code_advance(source_code: ^SourceCode)
@@ -147,14 +147,14 @@ begin
source_code^.position.column := 0u
return
-proc source_code_expect(source_code: ^SourceCode; expected: Char): Bool
+proc source_code_expect(source_code: ^SourceCode; expected: Word8): Bool
return ~source_code_empty(source_code) & source_code_head(source_code^) = expected
(*
Token procedures.
*)
-proc lexer_escape(escape: Char; result: ^Char): Bool
+proc lexer_escape(escape: Word8; result: ^Word8): Bool
var
successful: Bool
begin
@@ -194,7 +194,7 @@ return successful
(* Skip spaces. *)
proc lexer_spaces(source_code: ^SourceCode)
var
- current: Char
+ current: Word8
begin
while ~source_code_empty(source_code) & isspace(cast(source_code_head(source_code^): Int)) <> 0 do
current := source_code_head(source_code^);
@@ -207,7 +207,7 @@ begin
return
(* Checker whether the character is allowed in an identificator. *)
-proc lexer_is_ident(char: Char): Bool
+proc lexer_is_ident(char: Word8): Bool
return isalnum(cast(char: Int)) <> 0 or char = '_'
proc lexer_identifier(source_code: ^SourceCode; token_content: ^StringBuffer)
@@ -241,7 +241,7 @@ begin
end
return trailing = 2u
-proc lexer_character(source_code: ^SourceCode; token_content: ^Char): Bool
+proc lexer_character(source_code: ^SourceCode; token_content: ^Word8): Bool
var
successful: Bool
begin
@@ -264,10 +264,10 @@ return successful
proc lexer_string(source_code: ^SourceCode; token_content: ^StringBuffer): Bool
var
- token_end, constructed_string: ^Char
+ token_end, constructed_string: ^Word8
token_length: Word
is_valid: Bool := true
- next_char: Char
+ next_char: Word8
begin
while is_valid & ~source_code_empty(source_code) & source_code_head(source_code^) <> '"' do
is_valid := lexer_character(source_code, @next_char);
@@ -296,7 +296,7 @@ begin
return
(* Categorize an identifier. *)
-proc lexer_categorize(token_content: []const Char): ^ElnaLexerToken
+proc lexer_categorize(token_content: []const Word8): ^ElnaLexerToken
var
current_token: ^ElnaLexerToken
begin
@@ -395,7 +395,7 @@ return
proc lexer_next(source_code: SourceCode; token_buffer: ^StringBuffer): ^ElnaLexerToken
var
current_token: ^ElnaLexerToken := nil
- first_char: Char
+ first_char: Word8
begin
first_char := source_code_head(source_code);
@@ -777,7 +777,7 @@ begin
end
return return_code
-proc process(argc: Int; argv: ^^Char): Int
+proc process(argc: Int; argv: ^^Word8): Int
var
tokens: ^ElnaLexerToken
tokens_size: Word