aada

Alexis Ada Compiler written in Ada (my first attempt was in C++ which is not correct for an Ada compiler.)
27
Dec

AAda Compiler UCS4 Character to Uppercase

1
2
3
4
5
6
7
8
9
10
-- auto-generated by Generate Unicode Uppercase
-- see: http://aada.m2osw.com/compiler/compiler-tools/generate-unicode-uppercase
with aada_compiler_ucs4_character;
use aada_compiler_ucs4_character;
 
package aada_compiler_ucs4_character_to_uppercase is
  -- used by ucs4_string_to_normalized_uppercase()
  -- for any lone character
  function ucs4_to_upper(u: ucs4_character) return ucs4_character;
end aada_compiler_ucs4_character_to_uppercase;
27
Dec

AAda Compiler UCS4 Character to Uppercase

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
-- auto-generated by Generate Unicode Uppercase
-- see: http://aada.m2osw.com/compiler/compiler-tools/generate-unicode-uppercase
with aada_compiler_ucs4_character;
use aada_compiler_ucs4_character;
 
package body aada_compiler_ucs4_character_to_uppercase is
function ucs4_to_upper(u: ucs4_character) return ucs4_character is
  type ucs4_array is array(ucs4_character range <>) of ucs4_character;
begin
  -- return immediately if outside range
  if u not in 16#61# .. 16#E007F# then
    return u;
  end if;
  -- binary search of the 1646 characters with upper case
  -- with 108 groups
  ...</>
27
Dec

AAda Compiler UCS4 Character to CCC

1
2
3
4
5
6
7
8
9
10
11
12
13
-- auto-generated by Generate Unicode Uppercase
-- see: http://aada.m2osw.com/compiler/compiler-tools/generate-unicode-uppercase
with aada_compiler_ucs4_character;
use aada_compiler_ucs4_character;
 
package aada_compiler_ucs4_character_to_ccc is
  -- the range is really 0 to 255, but only 0 to 240
  -- are currently used so to detect potential errors...
  type ccc_type is range 0 .. 240;
 
  -- used by ucs4_string_to_normalized_uppercase()
  function ucs4_to_ccc(u: ucs4_character) return ccc_type;
end aada_compiler_ucs4_character_to_ccc;
27
Dec

AAda Compiler UCS4 Character to CCC

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
-- auto-generated by Generate Unicode Uppercase
-- see: http://aada.m2osw.com/compiler/compiler-tools/generate-unicode-uppercase
with aada_compiler_ucs4_character;
use aada_compiler_ucs4_character;
 
package body aada_compiler_ucs4_character_to_ccc is
function ucs4_to_ccc(u: ucs4_character) return ccc_type is
  -- array used for static tables for fast conversion
  type ccc_array is array(ucs4_character range <>) of ccc_type;
  pragma pack(ccc_array);
begin
  -- return immediately if outside range with possible CCC
  if u not in 16#300# .. 16#1D244# then
    return 0;
  end if;
  -- ...</>
27
Dec

AAda Compiler UCS4 String Normalized Uppercase

1
2
3
4
5
6
7
8
9
10
11
12
13
14
-- auto-generated by Generate Unicode Uppercase
-- see: http://aada.m2osw.com/compiler/compiler-tools/generate-unicode-uppercase
with aada_compiler_ucs4_character;
with aada_compiler_ucs4_character_to_ccc;
with aada_compiler_ucs4_character_to_uppercase;
use aada_compiler_ucs4_character;
use aada_compiler_ucs4_character_to_ccc;
use aada_compiler_ucs4_character_to_uppercase;
 
package body aada_compiler_ucs4_string_normalized_uppercase is
procedure ucs4_string_to_normalized_uppercase(s: in out ucs4_vstring) is
  sin: ucs4_vstring;
  empty: ucs4_string(1 .. 0);
  temp: ucs4_vstring;
27
Dec

AAda Compiler UCS4 String Normalized Uppercase

1
2
3
4
5
6
7
8
9
-- auto-generated by Generate Unicode Uppercase
-- see: http://aada.m2osw.com/compiler/compiler-tools/generate-unicode-uppercase
with aada_compiler_ucs4_character;
use aada_compiler_ucs4_character;
 
package aada_compiler_ucs4_string_normalized_uppercase is
  -- transform a ucs4_vstring to uppercase
  procedure ucs4_string_to_normalized_uppercase(s: in out ucs4_vstring);
end aada_compiler_ucs4_string_normalized_uppercase;
27
Dec

Generate Unicode Uppercase

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
-- 2049 characters have a transformation of ONE or TWO characters
-- 1016 characters are transformed to TWO characters
-- special case 16#0345# Iota
-- CCC /= 0 in plans: 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, 10, 13, 17, 18,
--                    19, 1A, 1B, 1C, 1D, 20, 2C, 2D, 30, A6, A8, A9, AA, AB,
--                    FB, FE, 101, 10A, 110, 1D1, 1D2
 
with interfaces;
with ada.characters.latin_1;
with ada.streams;
with ada.streams.stream_io;
with ada.text_io;
with ada.integer_text_io;
with ada.command_line;
with ada.strings.fixed;
with ada.strings.bounded;
 
use
25
Dec

AAda Compiler UCS4 Character

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
-- TODO: the memory allocation is very poor in this implementation
--       it would be better to allocate a larger buffer and grow it
--       only as required instead of each time the string changes
 
with unchecked_deallocation;
with text_io;
 
package body aada_compiler_ucs4_character is
  procedure free is new unchecked_deallocation(ucs4_string, ucs4_string_pointer);
  pempty: constant ucs4_string_pointer := new ucs4_string(1 .. 0);
 
  procedure vstr(s: in ucs4_string; v: in out ucs4_vstring) is
  begin
    if v.p /= pempty then
      free(v.p);
    end if;
    v.p := new
20
Mar

AAda Compiler UCS4 Character

1
2
3
4
5
6
7
8
9
10
11
-- UCS-4 characters are the base type in the AAda Compiler base
-- (i.e. the lexer) It is the most practical type to handle any
-- Unicode character since Unicode allows characters from 0 to
-- 16#0010_FFFF#. Once the lexer is done, the characters are
-- transformed to UTF-8 and most of the remainder of the compiler
-- handles "regular" strings
--
-- By default, the AAda compiler accepts the Unicode range of
-- characters, but it can support 31 bit characters; all characters
-- are accepted except NUL (0) and any character that end with
-- 16#FFFE# and 16#FFFF#. The ucs4_character
13
Mar

AAda Test Character Category

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
-- This test goes through all the UCS-4 characters and verify that
-- the category returned corresponds to what's expected by the
-- Ada 2005 specification.
with aada_test_package;
with aada_character_categories;
with aada_compiler_ucs4_character;
with aada_compiler_character_package;
with ada.command_line;
with ada.text_io;
with ada.unchecked_conversion;
with interfaces;
 
use aada_test_package;
use aada_compiler_ucs4_character;
use interfaces;
 
-- these are what we're testing (more specifically, the character category)
use aada_compiler_character_package;
use