Changeset 362


Ignore:
Timestamp:
Dec 26, 2014, 12:22:18 PM (6 years ago)
Author:
Maxim Reznik
Message:

Change list expansion

Traverse of list was changed in prev commit. Now lists are processed in
depth-first order left-to-right. So corresponding list representation is
LIST ::= item LIST<tail>; instead of previous
LIST ::= LIST<head> item;

So change AG generator and AG rules.
Construction and iteration of symbol list is changed also.

Location:
trunk/ada-2012
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/ada-2012/src/ag/env_in.ag

    r361 r362  
    310310Rules for Aborted_Tasks.name :
    311311(.
    312       ${head.env_in} := ${Aborted_Tasks.env_in};
     312      ${tail.env_in} := ${Aborted_Tasks.env_in};
    313313.)
    314314Rules for Accept_Body_Exception_Handlers.exception_handler :
    315315(.
    316       ${head.env_in} := ${Accept_Body_Exception_Handlers.env_in};
     316      ${tail.env_in} := ${Accept_Body_Exception_Handlers.env_in};
    317317.)
    318318Rules for Accept_Body_Statements.statement :
    319319(.
    320       ${head.env_in} := ${Accept_Body_Statements.env_in};
     320      ${tail.env_in} := ${Accept_Body_Statements.env_in};
    321321.)
    322322Rules for Accept_Parameters.parameter_specification :
    323323(.
    324       ${head.env_in} := ${Accept_Parameters.env_in};
     324      ${tail.env_in} := ${Accept_Parameters.env_in};
    325325.)
    326326Rules for Access_To_Subprogram_Parameter_Profile.parameter_specification :
    327327(.
    328       ${head.env_in} := ${Access_To_Subprogram_Parameter_Profile.env_in};
     328      ${tail.env_in} := ${Access_To_Subprogram_Parameter_Profile.env_in};
    329329.)
    330330Rules for Array_Component_Choices.discrete_choice :
    331331(.
    332       ${head.env_in} := ${Array_Component_Choices.env_in};
     332      ${tail.env_in} := ${Array_Component_Choices.env_in};
    333333.)
    334334Rules for Aspect_Specifications.aspect_specification :
    335335(.
    336       ${head.env_in} := ${Aspect_Specifications.env_in};
     336      ${tail.env_in} := ${Aspect_Specifications.env_in};
    337337.)
    338338Rules for Associations.association :
    339339(.
    340       ${head.env_in} := ${Associations.env_in};
     340      ${tail.env_in} := ${Associations.env_in};
    341341.)
    342342Rules for Asynchronous_Statement_Paths.select_then_abort_path :
    343343(.
    344       ${head.env_in} := ${Asynchronous_Statement_Paths.env_in};
     344      ${tail.env_in} := ${Asynchronous_Statement_Paths.env_in};
    345345.)
    346346Rules for Block_Declarative_Items.declarative_item :
    347347(.
    348       ${head.env_in} := ${Block_Declarative_Items.env_in};
     348      ${tail.env_in} := ${Block_Declarative_Items.env_in};
    349349.)
    350350Rules for Block_Exception_Handlers.exception_handler :
    351351(.
    352       ${head.env_in} := ${Block_Exception_Handlers.env_in};
     352      ${tail.env_in} := ${Block_Exception_Handlers.env_in};
    353353.)
    354354Rules for Block_Statements.statement :
    355355(.
    356       ${head.env_in} := ${Block_Statements.env_in};
     356      ${tail.env_in} := ${Block_Statements.env_in};
    357357.)
    358358Rules for Body_Declarative_Items.declarative_item :
    359359(.
    360       ${head.env_in} := ${Body_Declarative_Items.env_in};
     360      ${tail.env_in} := ${Body_Declarative_Items.env_in};
    361361.)
    362362Rules for Body_Exception_Handlers.exception_handler :
    363363(.
    364       ${head.env_in} := ${Body_Exception_Handlers.env_in};
     364      ${tail.env_in} := ${Body_Exception_Handlers.env_in};
    365365.)
    366366Rules for Body_Statements.statement :
    367367(.
    368       ${head.env_in} := ${Body_Statements.env_in};
     368      ${tail.env_in} := ${Body_Statements.env_in};
    369369.)
    370370Rules for Case_Expression_Paths.case_expression_path :
    371371(.
    372       ${head.env_in} := ${Case_Expression_Paths.env_in};
     372      ${tail.env_in} := ${Case_Expression_Paths.env_in};
    373373.)
    374374Rules for Case_Path_Alternative_Choices.discrete_choice :
    375375(.
    376       ${head.env_in} := ${Case_Path_Alternative_Choices.env_in};
     376      ${tail.env_in} := ${Case_Path_Alternative_Choices.env_in};
    377377.)
    378378Rules for Case_Statement_Alternative_Choices.discrete_choice :
    379379(.
    380       ${head.env_in} := ${Case_Statement_Alternative_Choices.env_in};
     380      ${tail.env_in} := ${Case_Statement_Alternative_Choices.env_in};
    381381.)
    382382Rules for Case_Statement_Paths.case_path :
    383383(.
    384       ${head.env_in} := ${Case_Statement_Paths.env_in};
     384      ${tail.env_in} := ${Case_Statement_Paths.env_in};
    385385.)
    386386Rules for Clause_Names.program_unit_name :
    387387(.
    388       ${head.env_in} := ${Clause_Names.env_in};
     388      ${tail.env_in} := ${Clause_Names.env_in};
    389389.)
    390390Rules for Compilation_Pragmas.context_item :
    391391(.
    392       ${head.env_in} := ${Compilation_Pragmas.env_in};
     392      ${tail.env_in} := ${Compilation_Pragmas.env_in};
    393393.)
    394394Rules for Component_Clauses.clause_or_pragma :
    395395(.
    396       ${head.env_in} := ${Component_Clauses.env_in};
     396      ${tail.env_in} := ${Component_Clauses.env_in};
    397397.)
    398398Rules for Context_Clause_Elements.context_item :
    399399(.
    400       ${head.env_in} := ${Context_Clause_Elements.env_in};
     400      ${tail.env_in} := ${Context_Clause_Elements.env_in};
    401401.)
    402402Rules for Discrete_Subtype_Definitions.discrete_subtype_definition :
    403403(.
    404       ${head.env_in} := ${Discrete_Subtype_Definitions.env_in};
     404      ${tail.env_in} := ${Discrete_Subtype_Definitions.env_in};
    405405.)
    406406Rules for Discriminants.discriminant_specification :
    407407(.
    408       ${head.env_in} := ${Discriminants.env_in};
     408      ${tail.env_in} := ${Discriminants.env_in};
    409409.)
    410410Rules for Enumeration_Literal_Declarations.enumeration_literal_specification :
    411411(.
    412       ${head.env_in} := ${Enumeration_Literal_Declarations.env_in};
     412      ${tail.env_in} := ${Enumeration_Literal_Declarations.env_in};
    413413.)
    414414Rules for Exception_Choices.exception_choice :
    415415(.
    416       ${head.env_in} := ${Exception_Choices.env_in};
     416      ${tail.env_in} := ${Exception_Choices.env_in};
    417417.)
    418418Rules for Expression_Paths.if_else_expression_path :
    419419(.
    420       ${head.env_in} := ${Expression_Paths.env_in};
     420      ${tail.env_in} := ${Expression_Paths.env_in};
    421421.)
    422422Rules for Extended_Return_Exception_Handlers.exception_handler :
    423423(.
    424       ${head.env_in} := ${Extended_Return_Exception_Handlers.env_in};
     424      ${tail.env_in} := ${Extended_Return_Exception_Handlers.env_in};
    425425.)
    426426Rules for Extended_Return_Statements.statement :
    427427(.
    428       ${head.env_in} := ${Extended_Return_Statements.env_in};
     428      ${tail.env_in} := ${Extended_Return_Statements.env_in};
    429429.)
    430430Rules for Generic_Actual_Part.generic_association :
    431431(.
    432       ${head.env_in} := ${Generic_Actual_Part.env_in};
     432      ${tail.env_in} := ${Generic_Actual_Part.env_in};
    433433.)
    434434Rules for Generic_Formal_Part.generic_formal :
    435435(.
    436       ${head.env_in} := ${Generic_Formal_Part.env_in};
     436      ${tail.env_in} := ${Generic_Formal_Part.env_in};
    437437.)
    438438Rules for Handler_Statements.statement :
    439439(.
    440       ${head.env_in} := ${Handler_Statements.env_in};
     440      ${tail.env_in} := ${Handler_Statements.env_in};
    441441.)
    442442Rules for Index_Subtype_Definitions.subtype_mark :
    443443(.
    444       ${head.env_in} := ${Index_Subtype_Definitions.env_in};
     444      ${tail.env_in} := ${Index_Subtype_Definitions.env_in};
    445445.)
    446446Rules for Label_Names.defining_identifier :
    447447(.
    448       ${head.env_in} := ${Label_Names.env_in};
     448      ${tail.env_in} := ${Label_Names.env_in};
    449449.)
    450450Rules for Loop_Statements.statement :
    451451(.
    452       ${head.env_in} := ${Loop_Statements.env_in};
     452      ${tail.env_in} := ${Loop_Statements.env_in};
    453453.)
    454454Rules for Membership_Test_Choices.membership_choice :
    455455(.
    456       ${head.env_in} := ${Membership_Test_Choices.env_in};
     456      ${tail.env_in} := ${Membership_Test_Choices.env_in};
    457457.)
    458458Rules for Names.defining_identifier :
    459459(.
    460       ${head.env_in} := ${Names.env_in};
     460      ${tail.env_in} := ${Names.env_in};
    461461.)
    462462Rules for Parameter_Profile.parameter_specification :
    463463(.
    464       ${head.env_in} := ${Parameter_Profile.env_in};
     464      ${tail.env_in} := ${Parameter_Profile.env_in};
    465465.)
    466466Rules for Pragma_Argument_Associations.pragma_argument_association :
    467467(.
    468       ${head.env_in} := ${Pragma_Argument_Associations.env_in};
     468      ${tail.env_in} := ${Pragma_Argument_Associations.env_in};
    469469.)
    470470Rules for Private_Part_Declarative_Items.basic_declarative_item :
    471471(.
    472       ${head.env_in} := ${Private_Part_Declarative_Items.env_in};
     472      ${tail.env_in} := ${Private_Part_Declarative_Items.env_in};
    473473.)
    474474Rules for Private_Protected_Items.protected_element_declaration :
    475475(.
    476       ${head.env_in} := ${Private_Protected_Items.env_in};
     476      ${tail.env_in} := ${Private_Protected_Items.env_in};
    477477.)
    478478Rules for Private_Task_Items.task_item :
    479479(.
    480       ${head.env_in} := ${Private_Task_Items.env_in};
     480      ${tail.env_in} := ${Private_Task_Items.env_in};
    481481.)
    482482Rules for Progenitor_List.subtype_mark :
    483483(.
    484       ${head.env_in} := ${Progenitor_List.env_in};
     484      ${tail.env_in} := ${Progenitor_List.env_in};
    485485.)
    486486Rules for Protected_Operation_Items.protected_operation_item :
    487487(.
    488       ${head.env_in} := ${Protected_Operation_Items.env_in};
     488      ${tail.env_in} := ${Protected_Operation_Items.env_in};
    489489.)
    490490Rules for Record_Component_Associations.association :
    491491(.
    492       ${head.env_in} := ${Record_Component_Associations.env_in};
     492      ${tail.env_in} := ${Record_Component_Associations.env_in};
    493493.)
    494494Rules for Record_Components.component_item :
    495495(.
    496       ${head.env_in} := ${Record_Components.env_in};
     496      ${tail.env_in} := ${Record_Components.env_in};
    497497.)
    498498Rules for Selective_Statement_Paths.select_or_else_path :
    499499(.
    500       ${head.env_in} := ${Selective_Statement_Paths.env_in};
     500      ${tail.env_in} := ${Selective_Statement_Paths.env_in};
    501501.)
    502502Rules for Sequence_Of_Statements.statement :
    503503(.
    504       ${head.env_in} := ${Sequence_Of_Statements.env_in};
     504      ${tail.env_in} := ${Sequence_Of_Statements.env_in};
    505505.)
    506506Rules for Statement_Paths.if_elsif_else_path :
    507507(.
    508       ${head.env_in} := ${Statement_Paths.env_in};
     508      ${tail.env_in} := ${Statement_Paths.env_in};
    509509.)
    510510Rules for Type_Clause_Names.subtype_mark :
    511511(.
    512       ${head.env_in} := ${Type_Clause_Names.env_in};
     512      ${tail.env_in} := ${Type_Clause_Names.env_in};
    513513.)
    514514Rules for Variant_Choices.discrete_choice :
    515515(.
    516       ${head.env_in} := ${Variant_Choices.env_in};
     516      ${tail.env_in} := ${Variant_Choices.env_in};
    517517.)
    518518Rules for Variants.variant :
    519519(.
    520       ${head.env_in} := ${Variants.env_in};
     520      ${tail.env_in} := ${Variants.env_in};
    521521.)
    522522Rules for Visible_Part_Declarative_Items.basic_declarative_item :
    523523(.
    524       ${head.env_in} := ${Visible_Part_Declarative_Items.env_in};
     524      ${tail.env_in} := ${Visible_Part_Declarative_Items.env_in};
    525525.)
    526526Rules for Visible_Protected_Items.protected_operation_declaration :
    527527(.
    528       ${head.env_in} := ${Visible_Protected_Items.env_in};
     528      ${tail.env_in} := ${Visible_Protected_Items.env_in};
    529529.)
    530530Rules for Visible_Task_Items.task_item :
    531531(.
    532       ${head.env_in} := ${Visible_Task_Items.env_in};
     532      ${tail.env_in} := ${Visible_Task_Items.env_in};
    533533.)
    534534Rules for With_Clause_Names.program_unit_name :
    535535(.
    536       ${head.env_in} := ${With_Clause_Names.env_in};
     536      ${tail.env_in} := ${With_Clause_Names.env_in};
    537537.)
    538538
     
    554554Rules for Accept_Parameters.parameter_specification :
    555555(.
    556       ${parameter_specification.env_in} := ${head.env_out};
     556      ${parameter_specification.env_in} := ${tail.env_out};
    557557.)
    558558
    559559Rules for Access_To_Subprogram_Parameter_Profile.parameter_specification :
    560560(.
    561       ${parameter_specification.env_in} := ${head.env_out};
     561      ${parameter_specification.env_in} := ${tail.env_out};
    562562.)
    563563
     
    584584Rules for Block_Declarative_Items.declarative_item :
    585585(.
    586       ${declarative_item.env_in} := ${head.env_out};
     586      ${declarative_item.env_in} := ${tail.env_out};
    587587.)
    588588
     
    599599Rules for Body_Declarative_Items.declarative_item :
    600600(.
    601       ${declarative_item.env_in} := ${head.env_out};
     601      ${declarative_item.env_in} := ${tail.env_out};
    602602.)
    603603
     
    639639Rules for Compilation_Pragmas.context_item :
    640640(.
    641       ${context_item.env_in} := ${head.env_out};
     641      ${context_item.env_in} := ${tail.env_out};
    642642.)
    643643
     
    649649Rules for Context_Clause_Elements.context_item :
    650650(.
    651       ${context_item.env_in} := ${head.env_out};
     651      ${context_item.env_in} := ${tail.env_out};
    652652.)
    653653
     
    659659Rules for Discriminants.discriminant_specification :
    660660(.
    661       ${discriminant_specification.env_in} := ${head.env_out};
     661      ${discriminant_specification.env_in} := ${tail.env_out};
    662662.)
    663663
    664664Rules for Enumeration_Literal_Declarations.enumeration_literal_specification :
    665665(.
    666       ${enumeration_literal_specification.env_in} := ${head.env_out};
     666      ${enumeration_literal_specification.env_in} := ${tail.env_out};
    667667.)
    668668
     
    694694Rules for Generic_Formal_Part.generic_formal :
    695695(.
    696       ${generic_formal.env_in} := ${head.env_out};
     696      ${generic_formal.env_in} := ${tail.env_out};
    697697.)
    698698
     
    729729Rules for Parameter_Profile.parameter_specification :
    730730(.
    731       ${parameter_specification.env_in} := ${head.env_out};
     731      ${parameter_specification.env_in} := ${tail.env_out};
    732732.)
    733733
     
    739739Rules for Private_Part_Declarative_Items.basic_declarative_item :
    740740(.
    741       ${basic_declarative_item.env_in} := ${head.env_out};
     741      ${basic_declarative_item.env_in} := ${tail.env_out};
    742742.)
    743743
    744744Rules for Private_Protected_Items.protected_element_declaration :
    745745(.
    746       ${protected_element_declaration.env_in} := ${head.env_out};
     746      ${protected_element_declaration.env_in} := ${tail.env_out};
    747747.)
    748748
    749749Rules for Private_Task_Items.task_item :
    750750(.
    751       ${task_item.env_in} := ${head.env_out};
     751      ${task_item.env_in} := ${tail.env_out};
    752752.)
    753753
     
    759759Rules for Protected_Operation_Items.protected_operation_item :
    760760(.
    761       ${protected_operation_item.env_in} := ${head.env_out};
     761      ${protected_operation_item.env_in} := ${tail.env_out};
    762762.)
    763763
     
    769769Rules for Record_Components.component_item :
    770770(.
    771       ${component_item.env_in} := ${head.env_out};
     771      ${component_item.env_in} := ${tail.env_out};
    772772.)
    773773
     
    799799Rules for Variants.variant :
    800800(.
    801       ${variant.env_in} := ${head.env_out};
     801      ${variant.env_in} := ${tail.env_out};
    802802.)
    803803
    804804Rules for Visible_Part_Declarative_Items.basic_declarative_item :
    805805(.
    806       ${basic_declarative_item.env_in} := ${head.env_out};
     806      ${basic_declarative_item.env_in} := ${tail.env_out};
    807807.)
    808808
    809809Rules for Visible_Protected_Items.protected_operation_declaration :
    810810(.
    811       ${protected_operation_declaration.env_in} := ${head.env_out};
     811      ${protected_operation_declaration.env_in} := ${tail.env_out};
    812812.)
    813813
    814814Rules for Visible_Task_Items.task_item :
    815815(.
    816       ${task_item.env_in} := ${head.env_out};
     816      ${task_item.env_in} := ${tail.env_out};
    817817.)
    818818
  • trunk/ada-2012/src/ag/name_list.ag

    r292 r362  
    1212(.
    1313      Self.Compilation.Context.Symbols.Create_List
    14         (${head.name_list}, ${program_unit_name.full_name}, ${Clause_Names.name_list});
     14        (${program_unit_name.full_name}, ${tail.name_list}, ${Clause_Names.name_list});
    1515.)
    1616
     
    2323(.
    2424      Self.Compilation.Context.Symbols.Create_List
    25         (${head.name_list}, ${defining_identifier.full_name}, ${Names.name_list});
     25        (${defining_identifier.full_name}, ${tail.name_list}, ${Names.name_list});
    2626.)
    2727
     
    3434(.
    3535      Self.Compilation.Context.Symbols.Create_List
    36         (${head.name_list}, ${program_unit_name.full_name}, ${With_Clause_Names.name_list});
     36        (${program_unit_name.full_name}, ${tail.name_list}, ${With_Clause_Names.name_list});
    3737.)
  • trunk/ada-2012/src/ag/static_value.ag

    r356 r362  
    3838(.
    3939           Self.Compilation.Context.Values.List
    40              (Head  => ${head.static_value},
    41           Tail  => ${association.static_value},
    42           Value => ${Record_Component_Associations.static_value});
     40             (Tail  => ${tail.static_value},
     41        Head  => ${association.static_value},
     42        Value => ${Record_Component_Associations.static_value});
    4343.)
    4444
  • trunk/ada-2012/src/ag/with_list.ag

    r268 r362  
    7373(.
    7474      Self.Compilation.Context.Symbols.Create_List
    75         (${head.with_list}, ${context_item.with_list}, ${Context_Clause_Elements.with_list});
     75        (${context_item.with_list}, ${tail.with_list}, ${Context_Clause_Elements.with_list});
    7676.)
    7777
     
    8484(.
    8585      Self.Compilation.Context.Symbols.Create_List
    86         (${head.limited_with_list}, ${context_item.limited_with_list}, ${Context_Clause_Elements.limited_with_list});
     86        (${context_item.limited_with_list}, ${tail.limited_with_list}, ${Context_Clause_Elements.limited_with_list});
    8787.)
  • trunk/ada-2012/src/api/gela-symbol_sets.ads

    r293 r362  
    6565   not overriding procedure Create_List
    6666     (Self  : in out Symbol_Set;
    67       Head  : Gela.Lexical_Types.Symbol_List :=
     67      Head  : Gela.Lexical_Types.Symbol;
     68      Tail  : Gela.Lexical_Types.Symbol_List :=
    6869        Gela.Lexical_Types.Empty_Symbol_List;
    69       Tail  : Gela.Lexical_Types.Symbol;
    7070      Value : out Gela.Lexical_Types.Symbol_List) is abstract;
    7171   --  Get new symbol list as join of Head and Tail.
     
    8181     (Self  : Symbol_Set;
    8282      Value : Gela.Lexical_Types.Symbol_List)
    83       return Gela.Lexical_Types.Symbol_List is abstract;
     83      return Gela.Lexical_Types.Symbol is abstract;
    8484   --  Return head of Value.
    8585
     
    8787     (Self  : Symbol_Set;
    8888      Value : Gela.Lexical_Types.Symbol_List)
    89       return Gela.Lexical_Types.Symbol is abstract;
     89      return Gela.Lexical_Types.Symbol_List is abstract;
    9090   --  Return tail symbol of Value.
    9191
  • trunk/ada-2012/src/comp/gela-plain_compilation_managers.adb

    r322 r362  
    660660               Cursor.Element.Visit (Self);
    661661               Comp.Context.Symbols.Create_List
    662                  (Head  => Self.Withed,
    663                   Tail  => Self.Symbol,
     662                 (Head  => Self.Symbol,
     663                  Tail  => Self.Withed,
    664664                  Value => Self.Withed);
    665665
  • trunk/ada-2012/src/comp/gela-plain_dependency_lists.adb

    r307 r362  
    7777         --  Check if withed units are ordered
    7878         while Withed /= Gela.Lexical_Types.Empty_Symbol_List loop
    79             Index := (Unit_Declaration, Set.Tail (Withed));
     79            Index := (Unit_Declaration, Set.Head (Withed));
    8080
    8181            if Self.No_Spec.Contains (Index) then
     
    9595            end if;
    9696
    97             Withed := Set.Head (Withed);
     97            Withed := Set.Tail (Withed);
    9898         end loop;
    9999
  • trunk/ada-2012/src/grammars/ag.y

    r129 r362  
    217217   procedure Read
    218218     (Self : in out Parser;
    219       Text : League.Strings.Universal_String);
     219      Text : League.Strings.Universal_String;
     220      Tail_List : Boolean := False);
    220221
    221222   function Grammar (Self : in out Parser) return Gela.Grammars.Grammar;
     
    243244   procedure Read
    244245     (Self : in out Parser;
    245       Text : League.Strings.Universal_String)
     246      Text : League.Strings.Universal_String;
     247      Tail_List : Boolean := False)
    246248   is
    247249      Scanner     : aliased Gela.Grammars.Scanners.Scanner;
     
    270272      Scanner.Set_Handler (Handler'Unchecked_Access);
    271273      YYParse;
    272       Context.Complete (Self.Constructor);
     274      Context.Complete (Self.Constructor, Tail_List);
    273275   end Read;
  • trunk/ada-2012/src/grammars/gela-grammars-parser_utils.adb

    r162 r362  
    277277   procedure Complete
    278278     (Self        : in out Context_Node;
    279       Constructor : in out Gela.Grammars.Constructors.Constructor)
     279      Constructor : in out Gela.Grammars.Constructors.Constructor;
     280      Tail_List   : Boolean := False)
    280281   is
    281282      function To_Production_List
     
    288289        (Production : Production_Access;
    289290         Result : in out Gela.Grammars.Constructors.Production);
     291
     292      Head : constant League.Strings.Universal_String :=
     293        League.Strings.To_Universal_String ("head");
     294
     295      Tail : constant League.Strings.Universal_String :=
     296        League.Strings.To_Universal_String ("tail");
    290297
    291298      -------------------
     
    340347         for Production of List.Productions loop
    341348            declare
    342                Head : constant League.Strings.Universal_String :=
    343                  League.Strings.To_Universal_String ("head");
    344349               Item : Gela.Grammars.Constructors.Production :=
    345350                 Constructor.Create_Production (Production.Name);
    346351            begin
    347                if not Inside.Is_Empty then
     352               if not Tail_List and then not Inside.Is_Empty then
    348353                  Item.Add
    349354                    (Constructor.Create_List_Reference
     
    353358
    354359               To_Production (Production.Data, Item);
     360
     361               if Tail_List and then not Inside.Is_Empty then
     362                  Item.Add
     363                    (Constructor.Create_List_Reference
     364                       (Name => Tail,
     365                        Denote => Inside));
     366               end if;
     367
    355368               Result.Add (Item);
    356369            end;
  • trunk/ada-2012/src/grammars/gela-grammars-parser_utils.ads

    r100 r362  
    177177   procedure Complete
    178178     (Self        : in out Context_Node;
    179       Constructor : in out Gela.Grammars.Constructors.Constructor);
     179      Constructor : in out Gela.Grammars.Constructors.Constructor;
     180      Tail_List   : Boolean := False);
    180181
    181182private
  • trunk/ada-2012/src/grammars/gela-grammars-reader.adb

    r80 r362  
    4747   end Read_File;
    4848
    49    function Read (File_Name : String) return Grammar is
     49   function Read
     50     (File_Name : String;
     51      Tail_List : Boolean := False) return Grammar
     52   is
    5053      Parser : Ag.Parser;
    5154   begin
    52       Parser.Read (Read_File (File_Name));
     55      Parser.Read (Read_File (File_Name), Tail_List);
    5356      return Parser.Grammar;
    5457   end Read;
  • trunk/ada-2012/src/grammars/gela-grammars-reader.ads

    r80 r362  
    1010package Gela.Grammars.Reader is
    1111
    12    function Read (File_Name : String) return Gela.Grammars.Grammar;
     12   function Read
     13     (File_Name : String;
     14      Tail_List : Boolean := False) return Gela.Grammars.Grammar;
     15   --  If Tail_List is False then a list expanded as
     16   --  LIST ::= [LIST] <head> Item
     17   --  If Tail_List is True then a list expanded as
     18   --  LIST ::= Item [LIST] <tail>
    1319
    1420end Gela.Grammars.Reader;
  • trunk/ada-2012/src/grammars/generated/ag.adb

    r100 r362  
    2323   procedure Read
    2424     (Self : in out Parser;
    25       Text : League.Strings.Universal_String)
     25      Text : League.Strings.Universal_String;
     26      Tail_List : Boolean := False)
    2627   is
    2728      Scanner     : aliased Gela.Grammars.Scanners.Scanner;
     
    471472      Scanner.Set_Handler (Handler'Unchecked_Access);
    472473      YYParse;
    473       Context.Complete (Self.Constructor);
     474      Context.Complete (Self.Constructor, Tail_List);
    474475   end Read;
    475476end Ag;
  • trunk/ada-2012/src/grammars/generated/ag.ads

    r93 r362  
    99   procedure Read
    1010     (Self : in out Parser;
    11       Text : League.Strings.Universal_String);
     11      Text : League.Strings.Universal_String;
     12      Tail_List : Boolean := False);
    1213
    1314   function Grammar (Self : in out Parser) return Gela.Grammars.Grammar;
  • trunk/ada-2012/src/lexer/gela-plain_symbol_sets.adb

    r356 r362  
    5959   overriding procedure Create_List
    6060     (Self  : in out Symbol_Set;
    61       Head  : Gela.Lexical_Types.Symbol_List :=
     61      Head  : Gela.Lexical_Types.Symbol;
     62      Tail  : Gela.Lexical_Types.Symbol_List :=
    6263        Gela.Lexical_Types.Empty_Symbol_List;
    63       Tail  : Gela.Lexical_Types.Symbol;
    6464      Value : out Gela.Lexical_Types.Symbol_List)
    6565   is
    66       Node   : constant List_Node := (Gela.Lexical_Types.Symbol (Head), Tail);
     66      Node   : constant List_Node := (Head, Gela.Lexical_Types.Symbol (Tail));
    6767      Cursor : List_Maps.Cursor;
    6868   begin
    69       if Head = Gela.Lexical_Types.Empty_Symbol_List then
     69      if Tail = Gela.Lexical_Types.Empty_Symbol_List then
    7070         --  Symbol and Symbol_List have the same encoding, just cast.
    71          Value := Gela.Lexical_Types.Symbol_List (Tail);
     71         Value := Gela.Lexical_Types.Symbol_List (Head);
    7272         return;
    7373      end if;
     
    9494      Value : out Gela.Lexical_Types.Symbol_List) is
    9595   begin
    96       if Tail = Empty_Symbol_List then
    97          Value := Head;
    98       else
    99          Self.Create_List (Head  => Head,
    100                            Tail  => Self.Head (Tail),
     96      if Head = Empty_Symbol_List then
     97         Value := Tail;
     98      else
     99         Self.Create_List (Head  => Self.Tail (Head),
     100                           Tail  => Tail,
    101101                           Value => Value);
    102102
    103          Self.Create_List (Head  => Value,
    104                            Tail  => Self.Tail (Tail),
     103         Self.Create_List (Head  => Self.Head (Head),
     104                           Tail  => Value,
    105105                           Value => Value);
    106106      end if;
     
    309309     (Self  : Symbol_Set;
    310310      Value : Gela.Lexical_Types.Symbol_List)
    311       return Gela.Lexical_Types.Symbol_List is
     311      return Gela.Lexical_Types.Symbol is
    312312   begin
    313313      if Value in List_Symbol then
     
    316316            Node  : constant List_Node := Self.Lists.Element (Index);
    317317         begin
     318            return Node.Left;
     319         end;
     320      else
    318321         --  Symbol and Symbol_List have the same encoding, just cast.
    319             return Gela.Lexical_Types.Symbol_List (Node.Left);
    320          end;
    321       else
    322          return Gela.Lexical_Types.Empty_Symbol_List;
     322         return Gela.Lexical_Types.Symbol (Value);
    323323      end if;
    324324   end Head;
     
    639639     (Self  : Symbol_Set;
    640640      Value : Gela.Lexical_Types.Symbol_List)
    641       return Gela.Lexical_Types.Symbol is
     641      return Gela.Lexical_Types.Symbol_List is
    642642   begin
    643643      if Value in List_Symbol then
     
    646646            Node  : constant List_Node := Self.Lists.Element (Index);
    647647         begin
    648             return Node.Right;
     648            --  Symbol and Symbol_List have the same encoding, just cast.
     649            return Gela.Lexical_Types.Symbol_List (Node.Right);
    649650         end;
    650651      else
    651          --  Symbol and Symbol_List have the same encoding, just cast.
    652          return Gela.Lexical_Types.Symbol (Value);
     652         return Gela.Lexical_Types.Empty_Symbol_List;
    653653      end if;
    654654   end Tail;
  • trunk/ada-2012/src/lexer/gela-plain_symbol_sets.ads

    r283 r362  
    6363   overriding procedure Create_List
    6464     (Self  : in out Symbol_Set;
    65       Head  : Gela.Lexical_Types.Symbol_List :=
     65      Head  : Gela.Lexical_Types.Symbol;
     66      Tail  : Gela.Lexical_Types.Symbol_List :=
    6667        Gela.Lexical_Types.Empty_Symbol_List;
    67       Tail  : Gela.Lexical_Types.Symbol;
    6868      Value : out Gela.Lexical_Types.Symbol_List);
    6969   --  Get new symbol list as join of Head and Tail.
     
    7979     (Self  : Symbol_Set;
    8080      Value : Gela.Lexical_Types.Symbol_List)
    81       return Gela.Lexical_Types.Symbol_List;
     81      return Gela.Lexical_Types.Symbol;
    8282   --  Return head of Value.
    8383
     
    8585     (Self  : Symbol_Set;
    8686      Value : Gela.Lexical_Types.Symbol_List)
    87       return Gela.Lexical_Types.Symbol;
     87      return Gela.Lexical_Types.Symbol_List;
    8888   --  Return tail symbol of Value.
    8989
  • trunk/ada-2012/src/semantic/gela-pass_utils.adb

    r356 r362  
    210210               Env := Set.Add_With_Clause
    211211                 (Index  => Env,
    212                   Symbol => Comp.Context.Symbols.Tail (List));
    213                List := Comp.Context.Symbols.Head (List);
     212                  Symbol => Comp.Context.Symbols.Head (List));
     213               List := Comp.Context.Symbols.Tail (List);
    214214            end loop;
    215215         end With_Clause;
     
    287287      return Gela.Semantic_Types.Env_Index
    288288   is
    289       Head   : Gela.Lexical_Types.Symbol_List := List;
     289      Tail   : Gela.Lexical_Types.Symbol_List := List;
    290290      Env_1  : Gela.Semantic_Types.Env_Index := Env;
    291291      Symbol : Gela.Lexical_Types.Symbol;
     
    298298      while Cursor.Has_Element loop
    299299         Name := Cursor.Element;
    300          Symbol := Set.Tail (Head);
    301          Head := Set.Head (Head);
     300         Symbol := Set.Head (Tail);
     301         Tail := Set.Tail (Tail);
    302302         Cursor.Next;
    303303
  • trunk/ada-2012/tools/ag/ag_tools-generator_factories.adb

    r260 r362  
    1212package body AG_Tools.Generator_Factories is
    1313
    14    Head : constant League.Strings.Universal_String :=
    15      League.Strings.To_Universal_String ("head");
     14   Tail : constant League.Strings.Universal_String :=
     15     League.Strings.To_Universal_String ("tail");
    1616
    1717   ---------
     
    4646      G    : Gela.Grammars.Grammar renames Self.Context.Grammar.all;
    4747   begin
    48       if Part.Name = Head then
     48      if Part.Name = Tail then
    4949         return Self.Head'Access;
    5050      elsif not Part.Is_Terminal_Reference
  • trunk/ada-2012/tools/ag/ag_tools-input.adb

    r361 r362  
    6363      Parent : Gela.Grammars.Non_Terminal_Index;
    6464      Done   : in out League.String_Vectors.Universal_String_Vector);
    65 
    66    procedure Copy_Head_Attr
    67      (G      : Gela.Grammars.Grammar;
    68       V      : in out Gela.Grammars.Constructors.Constructor;
    69       Parent : Gela.Grammars.Non_Terminal_Index);
    7065
    7166   procedure Copy_Productions
     
    231226      end loop;
    232227   end Copy_Attr;
    233 
    234    --------------------
    235    -- Copy_Head_Attr --
    236    --------------------
    237 
    238    procedure Copy_Head_Attr
    239      (G      : Gela.Grammars.Grammar;
    240       V      : in out Gela.Grammars.Constructors.Constructor;
    241       Parent : Gela.Grammars.Non_Terminal_Index)
    242    is
    243    begin
    244       null;
    245    end Copy_Head_Attr;
    246228
    247229   ----------------------
     
    354336
    355337      F : constant Gela.Grammars.Grammar :=
    356         Gela.Grammars.Reader.Read (File_Name);
     338        Gela.Grammars.Reader.Read (File_Name, Tail_List => True);
    357339   begin
    358340      Concrete := new NT_List'(F.Non_Terminal'Range => False);
     
    407389               end if;
    408390            end loop;
    409 
    410             if F.Non_Terminal (Parent).Is_List then
    411                Copy_Head_Attr (F, V, Parent);
    412             end if;
    413391         end loop;
    414392
     
    460438            NT   : Gela.Grammars.Non_Terminal renames
    461439              G.Non_Terminal (Part.Denote);
    462             Prod : Gela.Grammars.Production renames
    463               G.Production (NT.First);
    464             Part : Gela.Grammars.Part renames G.Part (Prod.Last);
    465440         begin
    466             return Part.Denote;
     441            return List_Item (G, NT);
    467442         end;
    468443      end if;
  • trunk/ada-2012/tools/ag/ag_tools-nt_generators.adb

    r361 r362  
    271271      Impl.P ("      is");
    272272
    273       Self.Context.Factory.Get (G.Part (Prod.Last)).
    274          Make_Local_Variable (Prod.Last);
     273      Self.Context.Factory.Get (G.Part (Prod.First)).
     274         Make_Local_Variable (Prod.First);
    275275
    276276      Write_Rules (Self.Context, NT, NT.First, Pass, Pos);
  • trunk/ada-2012/tools/ag/ag_tools-part_generators.adb

    r361 r362  
    1313package body AG_Tools.Part_Generators is
    1414
    15    Head : constant League.Strings.Universal_String :=
    16      League.Strings.To_Universal_String ("head");
     15   Tail : constant League.Strings.Universal_String :=
     16     League.Strings.To_Universal_String ("tail");
    1717   This : constant League.Strings.Universal_String :=
    1818     League.Strings.To_Universal_String ("This");
     
    204204        G.Declaration (Attribute.Declaration);
    205205   begin
    206       Self.Make_Local_Variable (Head, D);
    207       Code.P ("         --  Make_Get HEAD");
     206      Self.Make_Local_Variable (Tail, D);
     207      Code.P ("         --  Make_Get tail");
    208208   end Make_Get;
    209209
     
    381381        G.Declaration (Attribute.Declaration);
    382382   begin
    383       Self.Make_Local_Variable (Head, D);
    384       Code.P ("         --  Make_Set HEAD");
     383      Self.Make_Local_Variable (Tail, D);
     384      Code.P ("         --  Make_Set tail");
    385385   end Make_Set;
    386386
  • trunk/ada-2012/tools/ag/ag_tools.adb

    r254 r362  
    3737   is
    3838      Prod : Gela.Grammars.Production renames G.Production (NT.First);
    39       Part : Gela.Grammars.Part renames G.Part (Prod.Last);
     39      Part : Gela.Grammars.Part renames G.Part (Prod.First);
    4040   begin
    4141      return Part.Denote;
     
    160160   begin
    161161      if NT.Is_List or Is_Converted_List (G, NT) then
    162          Result := Return_Type (G, G.Part (Prod.First + 1));
     162         Result := Return_Type (G, G.Part (Prod.First));
    163163         Result.Append ("_Sequence");
    164164      else
Note: See TracChangeset for help on using the changeset viewer.