Use symbols for logical operations
This commit is contained in:
		@@ -107,16 +107,16 @@ false                   {
 | 
			
		||||
nil                     {
 | 
			
		||||
                            return yy::parser::make_NIL(this->location);
 | 
			
		||||
                        }
 | 
			
		||||
and                     {
 | 
			
		||||
\&                      {
 | 
			
		||||
                            return yy::parser::make_AND(this->location);
 | 
			
		||||
                        }
 | 
			
		||||
xor                     {
 | 
			
		||||
                            return yy::parser::make_XOR(this->location);
 | 
			
		||||
                        }
 | 
			
		||||
or                      {
 | 
			
		||||
\|                      {
 | 
			
		||||
                            return yy::parser::make_OR(this->location);
 | 
			
		||||
                        }
 | 
			
		||||
not                     {
 | 
			
		||||
\~                      {
 | 
			
		||||
                            return yy::parser::make_NOT(this->location);
 | 
			
		||||
                        }
 | 
			
		||||
return                  {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										36
									
								
								source.elna
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								source.elna
									
									
									
									
									
								
							@@ -198,22 +198,22 @@ end
 | 
			
		||||
 | 
			
		||||
proc is_digit(c: Char) -> Bool;
 | 
			
		||||
begin
 | 
			
		||||
  return cast(c: Int) >= cast('0': Int) and cast(c: Int) <= cast('9': Int)
 | 
			
		||||
  return cast(c: Int) >= cast('0': Int) & cast(c: Int) <= cast('9': Int)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
proc is_alpha(c: Char) -> Bool;
 | 
			
		||||
begin
 | 
			
		||||
  return cast(c: Int) >= cast('A': Int) and cast(c: Int) <= cast('z': Int)
 | 
			
		||||
  return cast(c: Int) >= cast('A': Int) & cast(c: Int) <= cast('z': Int)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
proc is_alnum(c: Char) -> Bool;
 | 
			
		||||
begin
 | 
			
		||||
  return is_digit(c) or is_alpha(c)
 | 
			
		||||
  return is_digit(c) | is_alpha(c)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
proc is_space(c: Char) -> Bool;
 | 
			
		||||
begin
 | 
			
		||||
  return c = ' ' or c = '\n' or c = '\t'
 | 
			
		||||
  return c = ' ' | c = '\n' | c = '\t'
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
proc substring(string: String, start: Word, count: Word) -> String;
 | 
			
		||||
@@ -398,12 +398,12 @@ end
 | 
			
		||||
 | 
			
		||||
proc source_code_expect(source_code: ^SourceCode, expected: Char) -> Bool;
 | 
			
		||||
begin
 | 
			
		||||
  return not source_code_empty(source_code) and source_code_head(source_code^) = expected
 | 
			
		||||
  return ~source_code_empty(source_code) & source_code_head(source_code^) = expected
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
proc skip_spaces(source_code: ^SourceCode);
 | 
			
		||||
begin
 | 
			
		||||
  while not source_code_empty(source_code) and is_space(source_code_head(source_code^)) do
 | 
			
		||||
  while ~source_code_empty(source_code) & is_space(source_code_head(source_code^)) do
 | 
			
		||||
    if source_code_head(source_code^) = '\n' then
 | 
			
		||||
      source_code_break(source_code)
 | 
			
		||||
	end;
 | 
			
		||||
@@ -413,14 +413,14 @@ end
 | 
			
		||||
 | 
			
		||||
proc is_ident(char: Char) -> Bool;
 | 
			
		||||
begin
 | 
			
		||||
  return is_alnum(char) or char = '_'
 | 
			
		||||
  return is_alnum(char) | char = '_'
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
proc lex_identifier(source_code: ^SourceCode, token_content: ^StringBuffer);
 | 
			
		||||
var
 | 
			
		||||
  content_length: Word
 | 
			
		||||
begin
 | 
			
		||||
  while not source_code_empty(source_code) and is_ident(source_code_head(source_code^)) do
 | 
			
		||||
  while ~source_code_empty(source_code) & is_ident(source_code_head(source_code^)) do
 | 
			
		||||
    string_buffer_push(token_content, source_code_head(source_code^));
 | 
			
		||||
	source_code_advance(source_code)
 | 
			
		||||
  end
 | 
			
		||||
@@ -432,11 +432,11 @@ var
 | 
			
		||||
begin
 | 
			
		||||
  trailing := 0u;
 | 
			
		||||
 | 
			
		||||
  while not source_code_empty(source_code) and trailing < 2u do
 | 
			
		||||
  while ~source_code_empty(source_code) & trailing < 2u do
 | 
			
		||||
    if source_code_head(source_code^) = '*' then
 | 
			
		||||
	  string_buffer_push(token_content, '*');
 | 
			
		||||
	  trailing := 1u
 | 
			
		||||
	elsif source_code_head(source_code^) = ')' and trailing = 1u then
 | 
			
		||||
	elsif source_code_head(source_code^) = ')' & trailing = 1u then
 | 
			
		||||
      string_buffer_pop(token_content, 1u);
 | 
			
		||||
	  trailing := 2u
 | 
			
		||||
	else
 | 
			
		||||
@@ -453,13 +453,13 @@ proc lex_character(source_code: ^SourceCode, token_content: ^Char) -> Bool;
 | 
			
		||||
var
 | 
			
		||||
  successful: Bool
 | 
			
		||||
begin
 | 
			
		||||
  successful := not source_code_empty(source_code);
 | 
			
		||||
  successful := ~source_code_empty(source_code);
 | 
			
		||||
 | 
			
		||||
  if successful then
 | 
			
		||||
    if source_code_head(source_code^) = '\\' then
 | 
			
		||||
      source_code_advance(source_code);
 | 
			
		||||
 | 
			
		||||
      successful := not source_code_empty(source_code) and escape_char(source_code_head(source_code^), token_content)
 | 
			
		||||
      successful := ~source_code_empty(source_code) & escape_char(source_code_head(source_code^), token_content)
 | 
			
		||||
	else
 | 
			
		||||
      token_content^ := source_code_head(source_code^);
 | 
			
		||||
	  successful := true
 | 
			
		||||
@@ -480,7 +480,7 @@ var
 | 
			
		||||
begin
 | 
			
		||||
  is_valid := true;
 | 
			
		||||
 | 
			
		||||
  while is_valid and not source_code_empty(source_code) and source_code_head(source_code^) <> '"' do
 | 
			
		||||
  while is_valid & ~source_code_empty(source_code) & source_code_head(source_code^) <> '"' do
 | 
			
		||||
    is_valid := lex_character(source_code, @next_char);
 | 
			
		||||
 | 
			
		||||
    if is_valid then
 | 
			
		||||
@@ -488,7 +488,7 @@ begin
 | 
			
		||||
    end
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
  if is_valid and source_code_expect(source_code, '"') then
 | 
			
		||||
  if is_valid & source_code_expect(source_code, '"') then
 | 
			
		||||
    source_code_advance(source_code)
 | 
			
		||||
  else
 | 
			
		||||
    is_valid := false
 | 
			
		||||
@@ -500,7 +500,7 @@ proc lex_number(source_code: ^SourceCode, token_content: ^Int);
 | 
			
		||||
begin
 | 
			
		||||
  token_content^ := 0;
 | 
			
		||||
 | 
			
		||||
  while not source_code_empty(source_code) and is_digit(source_code_head(source_code^)) do
 | 
			
		||||
  while ~source_code_empty(source_code) & is_digit(source_code_head(source_code^)) do
 | 
			
		||||
    token_content^ := token_content^ * 10 + (cast(source_code_head(source_code^): Int) - cast('0': Int));
 | 
			
		||||
 | 
			
		||||
    source_code_advance(source_code)
 | 
			
		||||
@@ -738,12 +738,12 @@ begin
 | 
			
		||||
 | 
			
		||||
  skip_spaces(@source_code);
 | 
			
		||||
 | 
			
		||||
  while not source_code_empty(@source_code) do
 | 
			
		||||
  while ~source_code_empty(@source_code) do
 | 
			
		||||
	tokens := cast(reallocarray(cast(tokens: ^Byte), tokens_size^ + 1u, #size(Token)): ^Token);
 | 
			
		||||
    current_token := tokens + tokens_size^;
 | 
			
		||||
	first_char := source_code_head(source_code);
 | 
			
		||||
 | 
			
		||||
    if is_alpha(first_char) or first_char = '_' then
 | 
			
		||||
    if is_alpha(first_char) | first_char = '_' then
 | 
			
		||||
      lex_identifier(@source_code, @token_buffer);
 | 
			
		||||
      current_token^ := categorize_identifier(string_buffer_clear(@token_buffer))
 | 
			
		||||
	elsif is_digit(first_char) then
 | 
			
		||||
@@ -778,7 +778,7 @@ begin
 | 
			
		||||
	elsif first_char = '\'' then
 | 
			
		||||
      source_code_advance(@source_code);
 | 
			
		||||
 | 
			
		||||
	  if lex_character(@source_code, @current_token^.value.char_value) and source_code_expect(@source_code, '\'') then
 | 
			
		||||
	  if lex_character(@source_code, @current_token^.value.char_value) & source_code_expect(@source_code, '\'') then
 | 
			
		||||
	  	current_token^.kind := TOKEN_CHARACTER;
 | 
			
		||||
	    source_code_advance(@source_code)
 | 
			
		||||
	  else
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user