Re: character matching

From: Ludovic Brenta (ludovic.brenta_at_insalien.org)
Date: 08/15/04

  • Next message: Adrian Knoth: "Re: character matching"
    Date: Sun, 15 Aug 2004 16:52:49 +0200
    
    

    "John J" writes:
    > Thanks for the suggestions; however, I'm trying to learn a bit about
    > the syntax and capabilities of ADA. Would someone be kind enough to
    > give me some examples of how I can use ADA to character match. ie,
    > different ways I can use '*', '&' to successfully recognise words
    > and sentences.
    >
    > Thanks

    type Category is (Whitespace, Punctuation, Letter, Digit, Other);

    function Category_Of (C : in Character) return Category is
    begin
       case C is
          when ' ' | ASCII.TAB => return Whitespace;
          when ',' | '.' | '!' | ';' | ':' | '?' => return Punctuation;
          when 'a' .. 'z' | 'A' .. 'Z' => return Letter;
          when '0' .. '9' => return Digit;
          when others => return Other;
       end case;
    end Category_Of;

    I hope this helps you move forward. Is this a homework assignment?

    (note that in Ada, a "case" statement is required to process all
    possible values of the case_expression (here, C); the compiler will
    tell you if you forgot some values, unless as above you use "when
    others").

    -- 
    Ludovic Brenta.
    

  • Next message: Adrian Knoth: "Re: character matching"

    Relevant Pages

    • Re: Clause "with and use"
      ... Java have that Ada doesn't in so far as it covers some significant ... C++ has the STL - it would be worth trying to get ... capabilities - Ada ought to consider that as a possibility. ... objec->method syntax since it seems to at least be non-trivial (although ...
      (comp.lang.ada)
    • Re: character matching
      ... syntax and capabilities of ADA. ... examples of how I can use ADA to character match. ... '&' to successfully recognise words and sentences. ...
      (comp.lang.ada)
    • Re: How come Ada isnt more popular?
      ... I think that Ada *and* Haskell will make an interesting ... You wouldn't just use Haskell and monads for at least two reasons: ... Ada (or whatever your favourite imperative language is), ... obsessed with the "broken syntax". ...
      (comp.lang.ada)
    • Re: The Decline of C/C++, the rise of X
      ... VHDL syntax was derived from Ada syntax. ... C pointer syntax can be very nasty to read. ...
      (comp.programming)
    • Re: Ada.Command_Line and wildcards
      ... we did in fact design an Ada command language for our debugger. ... tries to build the shell expression incrementally. ... A just "pascalish/adaish" syntax of course is not a problem and indeed ...
      (comp.lang.ada)