summaryrefslogtreecommitdiff
path: root/boot/stage19/cl.elna
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-02-02 12:10:40 +0100
committerEugen Wissner <belka@caraus.de>2026-02-04 18:17:47 +0100
commit8e89d33c214e3dad03a86057c2c45a0dc7608ad7 (patch)
tree6d6b52362c6e04a8466a3f393093157f49162588 /boot/stage19/cl.elna
parent39197fe88ab23bf452e00569ef36b556b787a421 (diff)
downloadelna-8e89d33c214e3dad03a86057c2c45a0dc7608ad7.tar.gz
Split up the rakefile
Diffstat (limited to 'boot/stage19/cl.elna')
-rw-r--r--boot/stage19/cl.elna73
1 files changed, 17 insertions, 56 deletions
diff --git a/boot/stage19/cl.elna b/boot/stage19/cl.elna
index 49fbbed..f721aef 100644
--- a/boot/stage19/cl.elna
+++ b/boot/stage19/cl.elna
@@ -316,14 +316,13 @@ type
ElnaLexerAction = (none, accumulate, skip, single, eof, finalize, composite, key_id, integer, delimited);
+ ElnaLexerTransition = record
+ action: ElnaLexerAction;
+ next_state: Word
+ end;
(**
* Classification table assigns each possible character to a group (class). All
* characters of the same group a handled equivalently.
- *
- * Transition = record
- * action: TransitionAction;
- * next_state: TransitionState
- * end;
*)
ElnaLexerClass = (
invalid,
@@ -586,7 +585,7 @@ var
* Each transition table entry is 8 bytes long. The table has 19 rows (transition states)
* and 23 columns (character classes), so 3496 = 8 * 19 * 23.
*)
- transition_table: [874]Word;
+ transition_table: [19][23]ElnaLexerTransition;
lexer_state: ElnaLexerCursor;
source_code: Word;
@@ -4745,20 +4744,15 @@ end;
proc _elna_lexer_get_transition(current_state: Word, character_class: Word);
var
- row_position: Word;
column_position: Word;
target: Word;
begin
(* Each state is 8 bytes long (2 words: action and next state).
There are 23 character classes, so a transition row 8 * 23 = 184 bytes long. *)
- row_position := current_state - 1;
- row_position := row_position * 184;
-
column_position := character_class - 1;
column_position := column_position * 8;
- target := @transition_table;
- target := target + row_position;
+ target := @transition_table[current_state];
return target + column_position
end;
@@ -4772,12 +4766,12 @@ end;
*)
proc _elna_lexer_set_transition(current_state: Word, character_class: Word, action: Word, next_state: Word);
var
- transition: Word;
+ transition: ^ElnaLexerTransition;
begin
transition := _elna_lexer_get_transition(current_state, character_class);
- _elna_lexer_transition_set_action(transition, action);
- _elna_lexer_transition_set_state(transition, next_state)
+ transition^.action := action;
+ transition^.next_state := next_state
end;
(* Sets same action and state transition for all character classes in one transition row. *)
@@ -4950,37 +4944,6 @@ begin
_elna_lexer_set_transition(ElnaLexerState.trait, ElnaLexerClass.x, ElnaLexerAction.accumulate, ElnaLexerState.trait)
end;
-proc _elna_lexer_transition_get_action(this: Word);
- return this^
-end;
-
-proc _elna_lexer_transition_set_action(this: Word, value: Word);
-begin
- this^ := value
-end;
-
-proc _elna_lexer_transition_get_state(this: Word);
-begin
- this := this + 4;
- return this^
-end;
-
-proc _elna_lexer_transition_set_state(this: Word, value: Word);
-begin
- this := this + 4;
- this^ := value
-end;
-
-(**
- * Resets the lexer state for reading the next token.
- *)
-proc _elna_lexer_reset();
-begin
- (* Transition start state is 1. *)
- lexer_state.state := ElnaLexerState.start;
- lexer_state.finish := lexer_state.start
-end;
-
(**
* One time lexer initialization.
*)
@@ -5228,21 +5191,16 @@ end;
proc _elna_lexer_execute_transition(kind: Word);
var
- next_transition: Word;
- next_state: Word;
+ next_transition: ^ElnaLexerTransition;
global_state: Word;
- action_to_perform: Word;
begin
next_transition := _elna_lexer_next_transition();
- next_state := _elna_lexer_transition_get_state(next_transition);
- action_to_perform := _elna_lexer_transition_get_action(next_transition);
-
global_state := @lexer_state;
- global_state^ := next_state;
- _elna_lexer_execute_action(action_to_perform, kind);
+ global_state^ := next_transition^.next_state;
+ _elna_lexer_execute_action(next_transition^.action, kind);
- return next_state
+ return next_transition^.next_state
end;
proc _elna_lexer_advance_token(kind: Word);
@@ -5257,10 +5215,13 @@ end;
(**
* Reads the next token and writes its type into the address in the kind parameter.
+ * Resets the lexer state for reading the next token.
*)
proc _elna_lexer_read_token(kind: Word);
begin
- _elna_lexer_reset();
+ lexer_state.state := ElnaLexerState.start;
+ lexer_state.finish := lexer_state.start;
+
_elna_lexer_advance_token(kind)
end;