---------------------------------------------------------- ---------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- O C A R I N A . A A D L . T O K E N S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2004-2006, GET-Telecom Paris. -- -- -- -- Ocarina is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 2, or (at your option) any -- -- later version. Ocarina is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- -- Public License for more details. You should have received a copy of the -- -- GNU General Public License distributed with Ocarina; see file COPYING. -- -- If not, write to the Free Software Foundation, 51 Franklin Street, Fifth -- -- Floor, Boston, MA 02111-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- Ocarina is maintained by the Ocarina team -- -- (ocarina-users@listes.enst.fr) -- -- -- ------------------------------------------------------------------------------ with Namet; with Charset; package body Ocarina.AADL.Tokens is use Namet; use Charset; Token_Image : array (token_type) of name_id; procedure New_Token (Token : token_type; Image : String); -- Compute token image and store it in Token_Image table. When -- Token is a reserved word, embrace its image between double -- quotes. Enter the lower-case form of a reserved word image into -- the name table and set name table byte to its token position in -- order to resolve it easily. ----------- -- Image -- ----------- function Image (T : token_type) return String is begin return Get_Name_String (Token_Image (T)); end Image; ----------------- -- Init_Tokens -- ----------------- procedure Init_Tokens is begin New_Token (t_error, "[ERROR]"); New_Token (t_identifier, ""); New_Token (t_quotation_mark, """"); New_Token (t_number_sign, "#"); New_Token (t_underline, "_"); New_Token (t_comma, ","); New_Token (t_plus, "+"); New_Token (t_minus, "-"); New_Token (t_multiply, "*"); New_Token (t_divide, "/"); New_Token (t_dot, "."); New_Token (t_colon, ":"); New_Token (t_semicolon, ";"); New_Token (t_less_than_sign, "<"); New_Token (t_equals_sign, "="); New_Token (t_greater_than_sign, ">"); New_Token (t_association, "=>"); New_Token (t_additive_association, "+=>"); New_Token (t_connection, "->"); New_Token (t_delayed_connection, "->>"); New_Token (t_interval, ".."); New_Token (t_colon_colon, "::"); New_Token (t_left_parenthesis, "("); New_Token (t_right_parenthesis, ")"); New_Token (t_left_square_bracket, "["); New_Token (t_right_square_bracket, "]"); New_Token (t_left_curly_bracket, "{"); New_Token (t_right_curly_bracket, "}"); New_Token (t_left_step_bracket, "-["); New_Token (t_right_step_bracket, "]->"); New_Token (t_begin_annex, "{**"); New_Token (t_end_annex, "**}"); New_Token (t_aadlboolean, "aadlboolean"); New_Token (t_aadlinteger, "aadlinteger"); New_Token (t_aadlreal, "aadlreal"); New_Token (t_aadlstring, "aadlstring"); New_Token (t_access, "access"); New_Token (t_all, "all"); New_Token (t_and, "and"); New_Token (t_annex, "annex"); New_Token (t_applies, "applies"); New_Token (t_binding, "binding"); New_Token (t_bus, "bus"); New_Token (t_calls, "calls"); New_Token (t_classifier, "classifier"); New_Token (t_connections, "connections"); New_Token (t_constant, "constant"); New_Token (t_data, "data"); New_Token (t_delta, "delta"); New_Token (t_device, "device"); New_Token (t_end, "end"); New_Token (t_enumeration, "enumeration"); New_Token (t_event, "event"); New_Token (t_extends, "extends"); New_Token (t_false, "false"); New_Token (t_true, "true"); New_Token (t_features, "features"); New_Token (t_flow, "flow"); New_Token (t_flows, "flows"); New_Token (t_group, "group"); New_Token (t_implementation, "implementation"); New_Token (t_in, "in"); New_Token (t_inherit, "inherit"); New_Token (t_initial, "initial"); New_Token (t_inverse, "inverse"); New_Token (t_is, "is"); New_Token (t_list, "list"); New_Token (t_memory, "memory"); New_Token (t_mode, "mode"); New_Token (t_modes, "modes"); New_Token (t_none, "none"); New_Token (t_not, "not"); New_Token (t_of, "of"); New_Token (t_or, "or"); New_Token (t_out, "out"); New_Token (t_package, "package"); New_Token (t_parameter, "parameter"); New_Token (t_path, "path"); New_Token (t_port, "port"); New_Token (t_private, "private"); New_Token (t_process, "process"); New_Token (t_processor, "processor"); New_Token (t_properties, "properties"); New_Token (t_property, "property"); New_Token (t_provides, "provides"); New_Token (t_public, "public"); New_Token (t_range, "range"); New_Token (t_reference, "reference"); New_Token (t_refined, "refined"); New_Token (t_refines, "refines"); New_Token (t_requires, "requires"); New_Token (t_server, "server"); New_Token (t_set, "set"); New_Token (t_sink, "sink"); New_Token (t_source, "source"); New_Token (t_subcomponents, "subcomponents"); New_Token (t_subprogram, "subprogram"); New_Token (t_system, "system"); New_Token (t_thread, "thread"); New_Token (t_to, "to"); New_Token (t_type, "type"); New_Token (t_units, "units"); New_Token (t_value, "value"); New_Token (t_real_literal, ""); New_Token (t_integer_literal, ""); New_Token (t_string_literal, ""); New_Token (t_comment, ""); New_Token (t_eof, "[EOF]"); end Init_Tokens; --------------- -- New_Token -- --------------- procedure New_Token (Token : token_type; Image : String) is begin Set_Str_To_Name_Buffer (Image); Token_Image (Token) := Name_Find; if Token in reserved_word_type then To_Lower (Name_Buffer (1 .. Name_Len)); Set_Name_Table_Byte (Name_Find, byte (token_type'pos (Token))); end if; end New_Token; ------------------ -- Quoted_Image -- ------------------ function Quoted_Image (T : token_type) return String is begin case T is when t_identifier | t_integer_literal | t_real_literal | t_string_literal => return Image (T); when others => return "'" & Image (T) & "'"; end case; end Quoted_Image; end Ocarina.AADL.Tokens;