Changeset 4517 for trunk/compiler

Show
Ignore:
Timestamp:
10/18/08 17:56:42 (3 months ago)
Author:
pmoura
Message:

Improved reporting of line numbers for syntax errors when using YAP or SWI-Prolog as the back-end compilers.

Added entity property lines(Start, End) for entities compiled and loaded from source files. This property is only available when using SWI-Prolog or YAP as the back-end compilers.

Added a customized version of the read_term/2 predicate to all config files that returns the line where a term starts for back-end Prolog compilers whose implementation of the read_term/2 predicate supports this information.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/compiler/logtalk.pl

    r4516 r4517  
    45684568        '$lgt_compiler_error_handler'(OpenError)), 
    45694569    catch( 
    4570         read_term(Input, Term, [singletons(Singletons)]), 
     4570        '$lgt_read_term'(Input, Term, [singletons(Singletons)], Line), 
    45714571        InputError, 
    45724572        '$lgt_compiler_error_handler'(Input, InputError)), 
     
    45784578        '$lgt_compiler_error_handler'(NewInput, Output, OpenError)), 
    45794579    catch( 
    4580         '$lgt_tr_file'(Term, Singletons, NewInput, Output), 
     4580        '$lgt_tr_file'(Term, Singletons, Line, NewInput, Output), 
    45814581        Error, 
    45824582        '$lgt_compiler_error_handler'(NewInput, Output, Error)), 
     
    46254625 
    46264626 
    4627 % '$lgt_tr_file'(+term, +list, @stream, @stream) 
    4628  
    4629 '$lgt_tr_file'(end_of_file, _, _, Output) :-                    % module definitions start with an opening 
     4627% '$lgt_tr_file'(+term, +list, +integer, @stream, @stream) 
     4628 
     4629'$lgt_tr_file'(end_of_file, _, _, _, Output) :-                 % module definitions start with an opening 
    46304630    '$lgt_pp_module_'(Module),                                  % module/1-2 directive and are assumed to 
    46314631    '$lgt_pp_object_'(Module, _, _, _, _, _, _, _, _, _, _),    % end at the end of a source file; there is 
     
    46344634    !. 
    46354635 
    4636 '$lgt_tr_file'(end_of_file, _, _, _) :- 
     4636'$lgt_tr_file'(end_of_file, _, _, _, _) :- 
    46374637    '$lgt_pp_object_'(Obj, _, _, _, _, _, _, _, _, _, _), 
    46384638    throw(entity_ending_directive_missing(object, Obj)). 
    46394639 
    4640 '$lgt_tr_file'(end_of_file, _, _, _) :- 
     4640'$lgt_tr_file'(end_of_file, _, _, _, _) :- 
    46414641    '$lgt_pp_protocol_'(Ptc, _, _, _, _), 
    46424642    throw(entity_ending_directive_missing(protocol, Ptc)). 
    46434643 
    4644 '$lgt_tr_file'(end_of_file, _, _, _) :- 
     4644'$lgt_tr_file'(end_of_file, _, _, _, _) :- 
    46454645    '$lgt_pp_category_'(Ctg, _, _, _, _, _), 
    46464646    throw(entity_ending_directive_missing(category, Ctg)). 
    46474647 
    4648 '$lgt_tr_file'(end_of_file, _, _, _) :- 
     4648'$lgt_tr_file'(end_of_file, _, _, _, _) :- 
    46494649    !. 
    46504650 
    4651 '$lgt_tr_file'(Term, Singletons, Input, Output) :- 
    4652     '$lgt_report_singletons'(Singletons, Term, Input), 
    4653     '$lgt_tr_term'(Term, Input, Output), 
    4654     read_term(Input, Next, [singletons(NextSingletons)]), 
    4655     '$lgt_tr_file'(Next, NextSingletons, Input, Output). 
    4656  
    4657  
    4658  
    4659 % '$lgt_add_entity_file_properties'(@entity_identifier, @stream) 
     4651'$lgt_tr_file'(Term, Singletons, Line, Input, Output) :- 
     4652    '$lgt_report_singletons'(Singletons, Term, Line, Input), 
     4653    '$lgt_tr_term'(Term, Line, Input, Output), 
     4654    '$lgt_read_term'(Input, Next, [singletons(NextSingletons)], NextLine), 
     4655    '$lgt_tr_file'(Next, NextSingletons, NextLine, Input, Output). 
     4656 
     4657 
     4658 
     4659% '$lgt_add_entity_file_properties'(@nonvar, @entity_identifier) 
    46604660% 
    46614661% adds entity properties related to the entity source file 
    46624662 
    4663 '$lgt_add_entity_file_properties'(Entity, _Input) :- 
    4664 %   (   catch('$lgt_stream_current_line_number'(Input, Line), _, fail) -> 
    4665 %       assertz('$lgt_pp_file_rclause_'('$lgt_entity_property_'(Entity, line_count(Line)))) 
    4666 %   ;   true 
    4667 %   ), 
    4668     '$lgt_pp_file_path_'(File, Path) -> 
    4669     assertz('$lgt_pp_rclause_'('$lgt_entity_property_'(Entity, file(File, Path)))). 
    4670  
    4671  
    4672  
    4673 % '$lgt_report_singletons'(+list, +term, @stream) 
     4663'$lgt_add_entity_file_properties'(start(Start), Entity) :- 
     4664    (   Start =:= -1 -> 
     4665        true 
     4666    ;   assertz('$lgt_pp_file_rclause_'('$lgt_entity_property_'(Entity, lines(Start, _)))) 
     4667    ), 
     4668    (   '$lgt_pp_file_path_'(File, Path) -> 
     4669        assertz('$lgt_pp_rclause_'('$lgt_entity_property_'(Entity, file(File, Path)))) 
     4670    ;   true 
     4671    ). 
     4672 
     4673'$lgt_add_entity_file_properties'(end(End), Entity) :- 
     4674    (   End =:= -1 -> 
     4675        true 
     4676    ;   retract('$lgt_pp_file_rclause_'('$lgt_entity_property_'(Entity, lines(Start, _)))) -> 
     4677        assertz('$lgt_pp_file_rclause_'('$lgt_entity_property_'(Entity, lines(Start, End)))) 
     4678    ). 
     4679 
     4680 
     4681 
     4682% '$lgt_report_singletons'(+list, +term, +integer, @stream) 
    46744683% 
    46754684% reports the singleton variables found while compiling an entity term 
    46764685 
    4677 '$lgt_report_singletons'(Singletons, Term, Input) :- 
     4686'$lgt_report_singletons'(Singletons, Term, Line, Input) :- 
    46784687    (   '$lgt_compiler_flag'(singletons, warning), 
    46794688        '$lgt_compiler_flag'(report, on) -> 
    46804689        '$lgt_filter_singletons'(Singletons, Names), 
    4681         '$lgt_report_singleton_names'(Names, Term, Input) 
     4690        '$lgt_report_singleton_names'(Names, Term, Line, Input) 
    46824691    ;   true 
    46834692    ). 
    46844693 
    46854694 
    4686 '$lgt_report_singleton_names'([], _, _) :- 
     4695'$lgt_report_singleton_names'([], _, _, _) :- 
    46874696    !.  % cut needed to prevent problems with compilers with broken read_term/3 implementations 
    46884697 
    4689 '$lgt_report_singleton_names'([Name| Names], Term, Stream) :- 
     4698'$lgt_report_singleton_names'([Name| Names], Term, Line, Input) :- 
    46904699    '$lgt_inc_compile_warnings_counter', 
    46914700    (   '$lgt_pp_entity'(_, _, _, _, _) -> 
     
    46994708    'lgt_report_singletons_term'(Term), 
    47004709    '$lgt_write_list'([Name| Names]), 
    4701     nl, '$lgt_report_compiler_error_line_number'(Stream), 
     4710    nl, '$lgt_report_compiler_error_line_number'(Line, Input), 
    47024711    (   '$lgt_pp_entity'(_, _, _, _, _) -> 
    47034712        true 
     
    48224831'$lgt_report_compiler_error'(Stream, Error) :- 
    48234832    '$lgt_report_compiler_error_message'(Error), 
    4824     '$lgt_report_compiler_error_line_number'(Stream), 
     4833    (   catch('$lgt_stream_current_line_number'(Stream, Line), _, fail) -> 
     4834        write('                  above line: '), write(Line) 
     4835    ;   true 
     4836    ), 
    48254837    nl. 
    48264838 
     
    48614873 
    48624874 
    4863 '$lgt_report_compiler_error_line_number'(Stream) :- 
    4864     (   catch('$lgt_stream_current_line_number'(Stream, Line), _, fail) -> 
    4865         write('                  above line: '), write(Line) 
    4866     ;   true 
     4875'$lgt_report_compiler_error_line_number'(Line, Stream) :- 
     4876    (   Line =:= -1 -> 
     4877        (   catch('$lgt_stream_current_line_number'(Stream, Next), _, fail) -> 
     4878            write('                  above line: '), write(Next) 
     4879        ;   true 
     4880        ) 
     4881    ;   write('                  in line: '), write(Line) 
    48674882    ). 
    48684883 
     
    51285143 
    51295144 
    5130 % '$lgt_tr_term'(+term, @stream, @stream) 
     5145% '$lgt_tr_term'(+term, +integer, @stream, @stream) 
    51315146% 
    51325147% translates a source file term (clauses, directives, and grammar rules) 
    51335148 
    5134 '$lgt_tr_term'(Term, Input, Output) :- 
     5149'$lgt_tr_term'(Term, Line, Input, Output) :- 
    51355150    (   % source-file specific compiler hook: 
    51365151        '$lgt_pp_hook_term_expansion_'(Term, Terms) -> 
    5137         '$lgt_tr_expanded_terms'(Terms, Input, Output) 
     5152        '$lgt_tr_expanded_terms'(Terms, Line, Input, Output) 
    51385153    ;   % default compiler hook: 
    51395154        '$lgt_hook_term_expansion_'(Term, Terms) -> 
    5140         '$lgt_tr_expanded_terms'(Terms, Input, Output) 
     5155        '$lgt_tr_expanded_terms'(Terms, Line, Input, Output) 
    51415156    ;   % no compiler hook defined: 
    5142         '$lgt_tr_expanded_term'(Term, Input, Output) 
    5143     ). 
    5144  
    5145  
    5146  
    5147 % '$lgt_tr_expanded_terms'(+list, @stream, @stream) 
     5157        '$lgt_tr_expanded_term'(Term, Line, Input, Output) 
     5158    ). 
     5159 
     5160 
     5161 
     5162% '$lgt_tr_expanded_terms'(+list, +integer, @stream, @stream) 
    51485163% 
    51495164% translates a list of source file terms 
    51505165 
    5151 '$lgt_tr_expanded_terms'([], _, _). 
    5152  
    5153 '$lgt_tr_expanded_terms'([Term| Terms], Input, Output) :- 
    5154     '$lgt_tr_expanded_term'(Term, Input, Output), 
    5155     '$lgt_tr_expanded_terms'(Terms, Input, Output). 
    5156  
    5157  
    5158  
    5159 % '$lgt_tr_expanded_term'(+list, @stream, @stream) 
     5166'$lgt_tr_expanded_terms'([], _, _, _). 
     5167 
     5168'$lgt_tr_expanded_terms'([Term| Terms], Line, Input, Output) :- 
     5169    '$lgt_tr_expanded_term'(Term, Line, Input, Output), 
     5170    '$lgt_tr_expanded_terms'(Terms, Line, Input, Output). 
     5171 
     5172 
     5173 
     5174% '$lgt_tr_expanded_term'(+term, +integer, @stream, @stream) 
    51605175% 
    51615176% translates a source file term (clauses, directives, and grammar rules) 
    51625177 
    5163 '$lgt_tr_expanded_term'((Head :- Body), Input, _) :- 
    5164     !, 
    5165     '$lgt_tr_clause'((Head :- Body), Input). 
    5166  
    5167 '$lgt_tr_expanded_term'((:- Directive), Input, Output) :- 
    5168     !, 
    5169     '$lgt_tr_directive'(Directive, Input, Output). 
    5170  
    5171 '$lgt_tr_expanded_term'((Head --> Body), Input, _) :- 
     5178'$lgt_tr_expanded_term'((Head :- Body), Line, Input, _) :- 
     5179    !, 
     5180    '$lgt_tr_clause'((Head :- Body), Line, Input). 
     5181 
     5182'$lgt_tr_expanded_term'((:- Directive), Line, Input, Output) :- 
     5183    !, 
     5184    '$lgt_tr_directive'(Directive, Line, Input, Output). 
     5185 
     5186'$lgt_tr_expanded_term'((Head --> Body), Line, Input, _) :- 
    51725187    !, 
    51735188    '$lgt_dcgrule_to_clause'((Head --> Body), Clause), 
    5174     '$lgt_tr_clause'(Clause, Input). 
    5175  
    5176 '$lgt_tr_expanded_term'(Fact, Input, _) :- 
    5177     '$lgt_tr_clause'(Fact, Input). 
     5189    '$lgt_tr_clause'(Clause, Line, Input). 
     5190 
     5191'$lgt_tr_expanded_term'(Fact, Line, Input, _) :- 
     5192    '$lgt_tr_clause'(Fact, Line, Input). 
    51785193 
    51795194 
     
    51865201 
    51875202'$lgt_tr_directives'([Dir| Dirs], Input, Output) :- 
    5188     '$lgt_tr_directive'(Dir, Input, Output), 
     5203    '$lgt_tr_directive'(Dir, -1, Input, Output), 
    51895204    '$lgt_tr_directives'(Dirs, Input, Output). 
    51905205 
    51915206 
    51925207 
    5193 % '$lgt_tr_directive'(+term, @stream, @stream) 
     5208% '$lgt_tr_directive'(+term, +integer, @stream, @stream) 
    51945209% 
    51955210% translates a directive 
    51965211 
    5197 '$lgt_tr_directive'(Dir, _, _) :- 
     5212'$lgt_tr_directive'(Dir, _, _, _) :- 
    51985213    var(Dir), 
    51995214    throw(error(instantiantion_error, directive(Dir))). 
    52005215 
    5201 '$lgt_tr_directive'(Dir, _, _) :-               % closing entity directive occurs before the opening 
     5216'$lgt_tr_directive'(Dir, _, _, _) :-            % closing entity directive occurs before the opening 
    52025217    \+ '$lgt_pp_entity'(_, _, _, _, _),         % entity directive; the opening directive is probably 
    52035218    functor(Dir, Functor, Arity),               % missing or misspelt 
     
    52055220    throw(error(unmatched_directive, directive(Dir))). 
    52065221 
    5207 '$lgt_tr_directive'(Dir, _, _) :- 
     5222'$lgt_tr_directive'(Dir, _, _, _) :- 
    52085223    \+ '$lgt_pp_entity'(_, _, _, _, _),         % directive occurs before opening entity directive 
    52095224    functor(Dir, Functor, Arity), 
     
    52125227    '$lgt_tr_file_directive'(Dir).              % translate it as a source file-level directive 
    52135228 
    5214 '$lgt_tr_directive'(Dir, Input, Output) :-      % entity closing directive 
     5229'$lgt_tr_directive'(Dir, Line, Input, Output) :-    % entity closing directive 
    52155230    functor(Dir, Functor, Arity), 
    52165231    '$lgt_lgt_closing_directive'(Functor, Arity), 
    52175232    Dir =.. [Functor| Args], 
    52185233    catch( 
    5219         '$lgt_tr_directive'(Functor, Args, Input, Output), 
     5234        '$lgt_tr_directive'(Functor, Args, Line, Input, Output), 
    52205235        Error, 
    52215236        (   '$lgt_pp_entity'(Type, Entity, _, _, _) -> 
     
    52255240    !. 
    52265241 
    5227 '$lgt_tr_directive'(Dir, Input, Output) :-      % entity opening directive or entity directive 
     5242'$lgt_tr_directive'(Dir, Line, Input, Output) :-    % entity opening directive or entity directive 
    52285243    functor(Dir, Functor, Arity), 
    52295244    '$lgt_lgt_directive'(Functor, Arity), 
    52305245    Dir =.. [Functor| Args], 
    52315246    catch( 
    5232         '$lgt_tr_directive'(Functor, Args, Input, Output), 
     5247        '$lgt_tr_directive'(Functor, Args, Line, Input, Output), 
    52335248        Error, 
    52345249        throw(error(Error, directive(Dir)))), 
    52355250    !. 
    52365251 
    5237 '$lgt_tr_directive'(Dir, Input, _) :- 
    5238     '$lgt_ignore_pl_directive'(Dir),                        % defined in the Prolog config files 
     5252'$lgt_tr_directive'(Dir, Line, Input, _) :- 
     5253    '$lgt_ignore_pl_directive'(Dir),                    % defined in the Prolog config files 
    52395254    !, 
    52405255    (   '$lgt_compiler_flag'(portability, warning) -> 
    52415256        nl, write('        WARNING!  Ignoring Prolog directive: '), writeq(Dir), 
    5242         nl, '$lgt_report_compiler_error_line_number'(Input) 
     5257        nl, '$lgt_report_compiler_error_line_number'(Line, Input) 
    52435258    ;   true 
    52445259    ). 
    52455260 
    5246 '$lgt_tr_directive'(Dir, Input, _) :- 
    5247     '$lgt_rewrite_and_copy_pl_directive'(Dir, RWDir),       % defined in the Prolog config files 
     5261'$lgt_tr_directive'(Dir, Line, Input, _) :- 
     5262    '$lgt_rewrite_and_copy_pl_directive'(Dir, RWDir),   % defined in the Prolog config files 
    52485263    assertz('$lgt_pp_directive_'(RWDir)), 
    52495264    !, 
     
    52515266        nl, write('        WARNING!  Rewriting Prolog directive:         '), writeq(Dir), 
    52525267        nl, write('                  Copying resulting Prolog directive: '), writeq(RWDir), 
    5253         nl, '$lgt_report_compiler_error_line_number'(Input) 
     5268        nl, '$lgt_report_compiler_error_line_number'(Line, Input) 
    52545269    ;   true 
    52555270    ). 
    52565271 
    5257 '$lgt_tr_directive'(Dir, Input, Output) :- 
     5272'$lgt_tr_directive'(Dir, Line, Input, Output) :- 
    52585273    '$lgt_rewrite_and_recompile_pl_directive'(Dir, RWDir),  % defined in the Prolog config files 
    52595274    !, 
     
    52615276        nl, write('        WARNING!  Rewriting Prolog directive:             '), writeq(Dir), 
    52625277        nl, write('                  Recompiling resulting Prolog directive: '), writeq(RWDir), 
    5263         nl, '$lgt_report_compiler_error_line_number'(Input) 
     5278        nl, '$lgt_report_compiler_error_line_number'(Line, Input) 
    52645279    ;   true 
    52655280    ), 
    5266     '$lgt_tr_directive'(RWDir, Input, Output).  % try to translate the rewritten directive 
    5267  
    5268 '$lgt_tr_directive'(Dir, _, _) :- 
     5281    '$lgt_tr_directive'(RWDir, Line, Input, Output).    % try to translate the rewritten directive 
     5282 
     5283'$lgt_tr_directive'(Dir, _, _, _) :- 
    52695284    functor(Dir, Functor, Arity), 
    52705285    throw(error(domain_error(directive, Functor/Arity), directive(Dir))). 
     
    53125327 
    53135328 
    5314 % '$lgt_tr_directive'(+atom, +list, @stream, @stream) 
     5329% '$lgt_tr_directive'(+atom, +list, @nonvar, @stream, @stream) 
    53155330% 
    53165331% translates a directive and its (possibly empty) list of arguments 
    53175332 
    5318 '$lgt_tr_directive'(object, [Obj| _], _, _) :- 
     5333'$lgt_tr_directive'(object, [Obj| _], _, _, _) :- 
    53195334    var(Obj), 
    53205335    throw(instantiation_error). 
    53215336 
    5322 '$lgt_tr_directive'(object, [Obj| _], _, _) :- 
     5337'$lgt_tr_directive'(object, [Obj| _], _, _, _) :- 
    53235338    \+ callable(Obj), 
    53245339    throw(type_error(object_identifier, Obj)). 
    53255340 
    5326 '$lgt_tr_directive'(object, [Obj| _], _, _) :- 
     5341'$lgt_tr_directive'(object, [Obj| _], _, _, _) :- 
    53275342    (   '$lgt_built_in_object'(Obj) -> 
    53285343        throw(permission_error(modify, object, Obj)) 
     
    53335348    ). 
    53345349 
    5335 '$lgt_tr_directive'(object, [Obj| Rels], Input, _) :- 
     5350'$lgt_tr_directive'(object, [Obj| Rels], Line, _, _) :- 
    53365351    '$lgt_report_compiling_entity'(object, Obj), 
    5337     '$lgt_add_entity_file_properties'(Obj, Input), 
     5352    '$lgt_add_entity_file_properties'(start(Line), Obj), 
    53385353    '$lgt_save_file_op_table', 
    53395354    '$lgt_tr_object_id'(Obj, static),                           % assume static object 
    53405355    '$lgt_tr_object_relations'(Rels, Obj). 
    53415356 
    5342 '$lgt_tr_directive'(end_object, [], _, Output) :- 
     5357'$lgt_tr_directive'(end_object, [], Line, _, Output) :- 
    53435358    (   '$lgt_pp_object_'(Obj, _, _, _, _, _, _, _, _, _, _) -> 
    53445359        '$lgt_tr_entity'(object, Obj, Output), 
    53455360        '$lgt_restore_file_op_table', 
    5346         '$lgt_report_compiled_entity'(object, Obj) 
     5361        '$lgt_report_compiled_entity'(object, Obj), 
     5362        '$lgt_add_entity_file_properties'(end(Line), Obj) 
    53475363    ;   throw(closing_directive_mismatch) 
    53485364    ). 
    53495365 
    5350 '$lgt_tr_directive'(protocol, [Ptc| _], _, _) :- 
     5366'$lgt_tr_directive'(protocol, [Ptc| _], _, _, _) :- 
    53515367    var(Ptc), 
    53525368    throw(instantiation_error). 
    53535369 
    5354 '$lgt_tr_directive'(protocol, [Ptc| _], _, _) :- 
     5370'$lgt_tr_directive'(protocol, [Ptc| _], _, _, _) :- 
    53555371    \+ atom(Ptc), 
    53565372    throw(type_error(protocol_identifier, Ptc)). 
    53575373 
    5358 '$lgt_tr_directive'(protocol, [Ptc| _], _, _) :- 
     5374'$lgt_tr_directive'(protocol, [Ptc| _], _, _, _) :- 
    53595375    (   '$lgt_built_in_object'(Ptc) -> 
    53605376        throw(permission_error(modify, object, Ptc)) 
     
    53655381    ). 
    53665382 
    5367 '$lgt_tr_directive'(protocol, [Ptc| Rels], Input, _) :- 
     5383'$lgt_tr_directive'(protocol, [Ptc| Rels], Line, _, _) :- 
    53685384    '$lgt_report_compiling_entity'(protocol, Ptc), 
    5369     '$lgt_add_entity_file_properties'(Ptc, Input), 
     5385    '$lgt_add_entity_file_properties'(start(Line), Ptc), 
    53705386    '$lgt_save_file_op_table', 
    53715387    '$lgt_tr_protocol_id'(Ptc, static),                         % assume static protocol 
    53725388    '$lgt_tr_protocol_relations'(Rels, Ptc). 
    53735389 
    5374 '$lgt_tr_directive'(end_protocol, [], _, Output) :- 
     5390'$lgt_tr_directive'(end_protocol, [], Line, _, Output) :- 
    53755391    (   '$lgt_pp_protocol_'(Ptc, _, _, _, _) -> 
    53765392        '$lgt_tr_entity'(protocol, Ptc, Output), 
    53775393        '$lgt_restore_file_op_table', 
    5378         '$lgt_report_compiled_entity'(protocol, Ptc) 
     5394        '$lgt_report_compiled_entity'(protocol, Ptc), 
     5395        '$lgt_add_entity_file_properties'(end(Line), Ptc) 
    53795396    ;   throw(closing_directive_mismatch) 
    53805397    ). 
    53815398 
    53825399 
    5383 '$lgt_tr_directive'(category, [Ctg| _], _, _) :- 
     5400'$lgt_tr_directive'(category, [Ctg| _], _, _, _) :- 
    53845401    var(Ctg), 
    53855402    throw(instantiation_error). 
    53865403 
    5387 '$lgt_tr_directive'(category, [Ctg| _], _, _) :- 
     5404'$lgt_tr_directive'(category, [Ctg| _], _, _, _) :- 
    53885405    \+ atom(Ctg), 
    53895406    throw(type_error(category_identifier, Ctg)). 
    53905407 
    5391 '$lgt_tr_directive'(category, [Ctg| _], _, _) :- 
     5408'$lgt_tr_directive'(category, [Ctg| _], _, _, _) :- 
    53925409    (   '$lgt_built_in_object'(Ctg) -> 
    53935410        throw(permission_error(modify, object, Ctg)) 
     
    53985415    ). 
    53995416 
    5400 '$lgt_tr_directive'(category, [Ctg| Rels], Input, _) :- 
     5417'$lgt_tr_directive'(category, [Ctg| Rels], Line, _, _) :- 
    54015418    '$lgt_report_compiling_entity'(category, Ctg), 
    5402     '$lgt_add_entity_file_properties'(Ctg, Input), 
     5419    '$lgt_add_entity_file_properties'(start(Line), Ctg), 
    54035420    '$lgt_save_file_op_table', 
    54045421    '$lgt_tr_category_id'(Ctg, static),                         % assume static category 
    54055422    '$lgt_tr_category_relations'(Rels, Ctg). 
    54065423 
    5407 '$lgt_tr_directive'(end_category, [], _, Output) :- 
     5424'$lgt_tr_directive'(end_category, [], Line, _, Output) :- 
    54085425    (   '$lgt_pp_category_'(Ctg, _, _, _, _, _) -> 
    54095426        '$lgt_tr_entity'(category, Ctg, Output), 
    54105427        '$lgt_restore_file_op_table', 
    5411         '$lgt_report_compiled_entity'(category, Ctg) 
     5428        '$lgt_report_compiled_entity'(category, Ctg), 
     5429        '$lgt_add_entity_file_properties'(end(Line), Ctg) 
    54125430    ;   throw(closing_directive_mismatch) 
    54135431    ). 
     
    54165434% compile modules as objects 
    54175435 
    5418 '$lgt_tr_directive'(module, [Module], Input, Output) :- 
    5419     !, 
    5420     '$lgt_tr_directive'(module, [Module, []], Input, Output).   % empty export list 
    5421  
    5422 '$lgt_tr_directive'(module, [Module, ExportList], _, _) :- 
     5436'$lgt_tr_directive'(module, [Module], Line, Input, Output) :- 
     5437    !, 
     5438    '$lgt_tr_directive'(module, [Module, []], Line, Input, Output). % empty export list 
     5439 
     5440'$lgt_tr_directive'(module, [Module, ExportList], _, _, _) :- 
    54235441    (var(Module); var(ExportList)), 
    54245442    throw(instantiation_error). 
    54255443 
    5426 '$lgt_tr_directive'(module, [Module, _], _, _) :- 
     5444'$lgt_tr_directive'(module, [Module, _], _, _, _) :- 
    54275445    \+ atom(Module), 
    54285446    throw(type_error(module_identifier, Module)). 
    54295447 
    5430 '$lgt_tr_directive'(module, [Module, ExportList], Input, Output) :- 
     5448'$lgt_tr_directive'(module, [Module, ExportList], Line, Input, Output) :- 
    54315449    assertz('$lgt_pp_module_'(Module)),                         % remeber we are compiling a module 
    54325450    '$lgt_report_compiling_entity'(module, Module), 
    54335451    '$lgt_tr_object_id'(Module, static),                        % assume static module/object 
    5434     '$lgt_tr_directive'((public), ExportList, Input, Output),   % make the export list public predicates 
     5452    '$lgt_tr_directive'((public), ExportList, Line, Input, Output), % make the export list public predicates 
    54355453    '$lgt_save_file_op_table'. 
    54365454 
     
    54385456% create a message queue at object initialization 
    54395457 
    5440 '$lgt_tr_directive'(threaded, [], _, _) :- 
    5441     \+ '$lgt_pp_object_'(_, _, _, _, _, _, _, _, _, _, _), 
    5442     throw(domain_error(object_directive, threaded/0)). 
    5443  
    5444 '$lgt_tr_directive'(threaded, [], _, _) :- 
     5458'$lgt_tr_directive'(threaded, [], _, _, _) :- 
    54455459    \+ '$lgt_compiler_flag'(threads, on), 
    54465460    throw(error(resource_error(threads), threaded/0)). 
    54475461 
    5448 '$lgt_tr_directive'(threaded, [], _, _) :- 
    5449     !, 
    5450     assertz('$lgt_pp_threaded_'), 
    5451     '$lgt_pp_object_'(Obj, _, _, _, _, _, _, _, _, _, _), 
    5452     assertz('$lgt_pp_rclause_'('$lgt_entity_property_'(Obj, threaded))). 
     5462'$lgt_tr_directive'(threaded, [], _, _, _) :- 
     5463    !, 
     5464    (   '$lgt_pp_object_'(Obj, _, _, _, _, _, _, _, _, _, _) -> 
     5465        assertz('$lgt_pp_threaded_'), 
     5466        assertz('$lgt_pp_rclause_'('$lgt_entity_property_'(Obj, threaded))) 
     5467    ;   throw(domain_error(object_directive, threaded/0)) 
     5468    ). 
    54535469 
    54545470 
    54555471% make all object (or category) predicates synchronized using the same mutex 
    54565472 
    5457 '$lgt_tr_directive'(synchronized, [], _, _) :- 
     5473'$lgt_tr_directive'(synchronized, [], _, _, _) :- 
    54585474    \+ '$lgt_pp_object_'(_, _, _, _, _, _, _, _, _, _, _), 
    54595475    \+ '$lgt_pp_category_'(_, _, _, _, _, _), 
    54605476    throw(domain_error(directive, synchronized/0)). 
    54615477 
    5462 '$lgt_tr_directive'(synchronized, [], _, _) :- 
     5478'$lgt_tr_directive'(synchronized, [], _, _, _) :- 
    54635479    !, 
    54645480    (   '$lgt_default_flag'(threads, on) -> 
     
    54745490% dynamic entity directive 
    54755491 
    5476 '$lgt_tr_directive'((dynamic), [], _, _) :- 
     5492'$lgt_tr_directive'((dynamic), [], _, _, _) :- 
    54775493    !, 
    54785494    '$lgt_update_entity_comp_mode'. 
    54795495 
    54805496 
    5481 '$lgt_tr_directive'(initialization, [Goal], _, _) :- 
     5497'$lgt_tr_directive'(initialization, [Goal], _, _, _) :- 
    54825498    var(Goal), 
    54835499    throw(instantiation_error). 
    54845500 
    5485 '$lgt_tr_directive'(initialization, [Goal], _, _) :- 
     5501'$lgt_tr_directive'(initialization, [Goal], _, _, _) :- 
    54865502    \+ callable(Goal), 
    54875503    throw(type_error(callable, Goal)). 
    54885504 
    5489 '$lgt_tr_directive'(initialization, [Goal], _, _) :- 
     5505'$lgt_tr_directive'(initialization, [Goal], _, _, _) :- 
    54905506    '$lgt_pp_entity'(_, Entity, Prefix, _, _), 
    54915507    '$lgt_ctx_ctx'(Ctx, _, Entity, Entity, Entity, Prefix, [], _), 
     
    54945510 
    54955511 
    5496 '$lgt_tr_directive'(op, [Pr, Spec, Ops], _, _) :- 
     5512'$lgt_tr_directive'(op, [Pr, Spec, Ops], _, _, _) :- 
    54975513    (var(Pr); var(Spec); var(Ops)), 
    54985514    throw(instantiation_error). 
    54995515 
    5500 '$lgt_tr_directive'(op, [Pr, _, _], _, _) :- 
     5516'$lgt_tr_directive'(op, [Pr, _, _], _, _, _) :- 
    55015517    \+ '$lgt_valid_op_priority'(Pr), 
    55025518    throw(type_error(operator_priority, Pr)). 
    55035519 
    5504 '$lgt_tr_directive'(op, [_, Spec, _], _, _) :- 
     5520'$lgt_tr_directive'(op, [_, Spec, _], _, _, _) :- 
    55055521    \+ '$lgt_valid_op_specifier'(Spec), 
    55065522    throw(type_error(operator_specifier, Spec)). 
    55075523 
    5508 '$lgt_tr_directive'(op, [_, _, Ops], _, _) :- 
     5524'$lgt_tr_directive'(op, [_, _, Ops], _, _, _) :- 
    55095525    \+ '$lgt_valid_op_names'(Ops), 
    55105526    throw(type_error(operator_name, Ops)). 
    55115527 
    5512 '$lgt_tr_directive'(op, [Pr, Spec, Ops], _, _) :- 
     5528'$lgt_tr_directive'(op, [Pr, Spec, Ops], _, _, _) :- 
    55135529    op(Pr, Spec, Ops), 
    55145530    '$lgt_assert_entity_ops'(Pr, Spec, Ops). 
    55155531 
    55165532 
    5517 '$lgt_tr_directive'(uses, [Obj, Preds], _, _) :- 
     5533'$lgt_tr_directive'(uses, [Obj, Preds], _, _, _) :- 
    55185534    (var(Obj); var(Preds)), 
    55195535    throw(instantiation_error). 
    55205536 
    5521 '$lgt_tr_directive'(uses, [Obj, _], _, _) :- 
     5537'$lgt_tr_directive'(uses, [Obj, _], _, _, _) :- 
    55225538    \+ callable(Obj), 
    55235539    throw(type_error(object_identifier, Obj)). 
    55245540 
    5525 '$lgt_tr_directive'(uses, [_, Preds], _, _) :- 
     5541'$lgt_tr_directive'(uses, [_, Preds], _, _, _) :- 
    55265542    \+ '$lgt_is_proper_list'(Preds), 
    55275543    throw(type_error(list, Preds)). 
    55285544 
    5529 '$lgt_tr_directive'(uses, [Obj, Preds], _, _) :- 
     5545'$lgt_tr_directive'(uses, [Obj, Preds], _, _, _) :- 
    55305546    !, 
    55315547    assertz('$lgt_pp_referenced_object_'(Obj)), 
     
    55345550 
    55355551 
    5536 '$lgt_tr_directive'(uses, [Obj], _, _) :- 
     5552'$lgt_tr_directive'(uses, [Obj], _, _, _) :- 
    55375553    var(Obj), 
    55385554    throw(instantiation_error). 
    55395555 
    5540 '$lgt_tr_directive'(uses, [Obj], _, _) :- 
     5556'$lgt_tr_directive'(uses, [Obj], _, _, _) :- 
    55415557    \+ callable(Obj), 
    55425558    throw(type_error(object_identifier, Obj)). 
    55435559 
    5544 '$lgt_tr_directive'(uses, [Obj], _, _) :- 
     5560'$lgt_tr_directive'(uses, [Obj], _, _, _) :- 
    55455561    assertz('$lgt_pp_referenced_object_'(Obj)), 
    55465562    assertz('$lgt_pp_uses_'(Obj)). 
    55475563 
    55485564 
    5549 '$lgt_tr_directive'(use_module, [Module, _], _, _) :- 
     5565'$lgt_tr_directive'(use_module, [Module, _], _, _, _) :- 
    55505566    var(Module), 
    55515567    throw(instantiation_error). 
    55525568