File : marks-scanners-opt.adb
-- Marks.Scanners.Opt (body)
--
-- Copyright (c) 2009 Tidorum Ltd.
--
-- This file is part of Find_Marks.
--
-- Find_Marks is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program 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
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Marks.Scanners.Opt is
Opt_Scanner : aliased Opt_Scanner_T := (
Comment_Prefix => null,
Mark_Prefix => null,
Mark_Suffix => new String'(""),
Option => null,
File_Suffix => null);
--
-- The option-controlled scanner.
--
-- The Comment_Prefix and Mark_Prefix will be set by options.
-- Mark_Suffix may be changed by options.
--
-- The Option and File_Suffix are irrelevant in our overriding
-- implementations of Option_Chooses_Me and Suffix_Chooses_Me.
-- overriding
procedure Handle_Option (
Option : in String;
Scanner : in out Opt_Scanner_T;
Valid : out Boolean;
Chosen : out Boolean)
is
use type Fixed.String_Ref;
procedure Set (Key : String; Param : in out Fixed.String_Ref)
--
-- If the Option begins with the Key, the Param is set to
-- the rest of Option and Valid is set True.
--
is
begin
if Begins_By (Key, Option) then
Param := new String'(
Option(Option'First + Key'Length .. Option'Last));
Valid := True;
end if;
end Set;
begin -- Handle_Option
Valid := False;
Set ("-com=", Scanner.Comment_Prefix);
Set ("-pre=", Scanner.Mark_Prefix);
Set ("-suf=", Scanner.Mark_Suffix);
Chosen := Valid
and Scanner.Comment_Prefix /= null
and Scanner.Mark_Prefix /= null
and Scanner.Mark_Suffix /= null;
end Handle_Option;
-- overriding
function Suffix_Chooses_Me (
Suffix : String;
Scanner : Opt_Scanner_T)
return Boolean
is
begin
return False;
end Suffix_Chooses_Me;
begin
Register (Opt_Scanner'Access);
end Marks.Scanners.Opt;