From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,de5afb9e2776aabb X-Google-Attributes: gid103376,public From: mfb@mbunix.mitre.org (Michael F Brenner) Subject: Re: String to Integer conversion. Date: 1997/03/31 Message-ID: <5hoqre$6sk@top.mitre.org>#1/1 X-Deja-AN: 229665859 References: <333FEBF5.2143@mersinet.co.uk> Organization: The MITRE Corporation Newsgroups: comp.lang.ada Summary: FSA Date: 1997-03-31T00:00:00+00:00 List-Id: Bazza asks: > Does anyone know how to convert something such as: 223 + 4234 > from a string, to 3 seperate variables, 223, + and 4234. Yes, there are several ways of doing it, including (a) using a shell tool with regular expressions (like awk, perl, Snobol, gnat, turbo pascal, SQL PLUS, or Refine), (b) using a table-driven finite state automaton (FSA), (c) using a FSA implemented in code, (d) writing ad hoc code which would be hopefully equivalent to the FSA, (e) enhancing the FSA to automatically generate the output according to a table in which case we may call it a finite state transducer (FST), (f) enhancing the FST with a stack to permit nesting of expressions and parentheses, (g) using a semi-Thue string rewriting system to cause the transduction, (h) enhancing the FST with a staging mechanism to control parallel execution which we may call a Petri Net, (i) writing a genetic algorithm to learn the typical patterns of expressions used by programmers and from that table of patterns constructing a neural net to do the conversion, (j) congealing in an electrophoresis vat a set of DNA molecules whose amino sequences encode all possible valid strings in the desired grammar for the potential algebraic expressions being recognized, (k) building an optical computer using lenses - prisms - collators - mirrors - inferometers - and various control mechanisms to do the recognition combined with computer generated holographic output devices like those at the MIT optics lab, (l) using the RS-232 interface to a TI calculator with an optical scanner reading the display, (m) using a human computer comprising a sighted person responsible for seeing and perceiving the inputs and a parser theory student responsible for lexically processing the inputs and a Votrex chip board to speak the outputs from the lexical processing stage, (n) assign it to your students, (o) ask on comp.lang.ada. The following FSA would perform the transduction you requested, subject to your interpretation of the words , using the techniques in Epstein, Word Processing in Groups, or Ullman, the Dragon book. > 223 + 4234 from a string, to 3 seperate variables, 223, + and 4234 type classes is (blank, end_of_file, all_others); type states is (start, got_blank, got_blank_2, error, done); type transition_rows is array (classes) of states; type transition_matrices is array (states) of transition_rows; transition_matrix: constant transition_matrices := (start => (got_blank, error, start, error, error), got_blank => (got_blank, error, got_blank, error, error), got_blank_2 => (got_blank_2, done, got_blank_2, error, error), error => (error, error, error, error, error), done => (error, error, error, error, error));