source: trunk/minix/commands/yap/machine.h@ 10

Last change on this file since 10 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 1.8 KB
RevLine 
[9]1/* Copyright (c) 1985 Ceriel J.H. Jacobs */
2
3/* $Header: /cvsup/minix/src/commands/yap/machine.h,v 1.1.1.1 2005/04/21 14:55:40 beng Exp $ */
4
5# ifndef _MACHINE_
6# define PUBLIC extern
7# else
8# define PUBLIC
9# endif
10
11/*
12 * Simple minded finite state machine implementation to recognize
13 * strings.
14 */
15
16struct state {
17 char s_char; /* character to match with */
18 char s_endstate; /* flag, 1 if this state is an endstate */
19 struct state *s_match; /* new state if matched */
20 struct state *s_next; /* other characters to match with */
21 short s_cnt; /* if an endstate, this field is filled with
22 * some info, dependant on the machine.
23 */
24};
25
26# define FSM_OKE 0
27# define FSM_ISPREFIX -1 /* Must be < 0 */
28# define FSM_HASPREFIX 1
29
30int addstring();
31/*
32 * int addstring(str,cnt,mach)
33 * char *str; The string to be recognized
34 * int cnt; Attribute of the string.
35 * struct state **mach; The finite state machine
36 *
37 * This routine adds a string to a finite state automaton.
38 * It returns FSM_ISPREFIX if the added string is a prefix of a string already
39 * in the automaton, FSM_HASPREFIX if a string, already recognized by the
40 * automaton, is a prefix of the added string.
41 * Otherwise it returns FSM_OKE.
42 */
43
44int match();
45/*
46 * int match(str,p_int,mach)
47 * char *str; pointer to string
48 * int *p_int; Pointer to an integer
49 * struct state *mach; The finite state machine
50 *
51 * A match of the string indicated by "str" is tried. If a head of "str"
52 * is recognized by the finite state automaton, a machine dependant number
53 * is put in the integer pointed to by "p_int".
54 * The number of characters that match is returned, so a return value of 0
55 * means no match.
56 * A return value of FSM_PREFIX means that the string "str" was a prefix of a
57 * matched string.
58 */
59
60# undef PUBLIC
Note: See TracBrowser for help on using the repository browser.