~ubuntu-branches/ubuntu/warty/gnushogi/warty

« back to all changes in this revision

Viewing changes to xshogi/scanner.l

  • Committer: Bazaar Package Importer
  • Author(s): Javier Fernandez-Sanguino Pen~a
  • Date: 2004-01-09 16:06:59 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040109160659-n26nu7009llm247p
Tags: 1.3-3.1
* NMU
 - Minimal testing done and looks quite OK (even if I don't know
   how to play the game...)
 - Build-Depends move from libxaw-dev to libxaw6-dev (Closes: #169975)
 - Included errno.h in gnushogi which makes the binary build properly
   now (and is usable with xshogi) (Closes: #226319)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%{
 
2
/*
 
3
 * FILE: scanner.l
 
4
 *
 
5
 *     Lexer for xshogi.
 
6
 *
 
7
 * ------------------------------------------------------------------------
 
8
 * xshogi is based on XBoard -- an Xt/Athena user interface for GNU Chess.
 
9
 *
 
10
 * Original authors:                                Dan Sears, Chris Sears
 
11
 * Enhancements (Version 2.0 and following):        Tim Mann
 
12
 * Modifications to XShogi (Version 1.0):           Matthias Mutz
 
13
 * Enhancements to XShogi (Version 1.1):            Matthias Mutz
 
14
 * Modified implementation of ISS mode for XShogi:  Matthias Mutz
 
15
 * Current maintainer:                              Michael C. Vanier
 
16
 *
 
17
 * XShogi borrows its piece bitmaps from CRANES Shogi.
 
18
 *
 
19
 * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
 
20
 * Enhancements Copyright 1992 Free Software Foundation, Inc.
 
21
 * Enhancements for XShogi Copyright 1993, 1994, 1995 Matthias Mutz
 
22
 * Copyright (c) 1999 Michael Vanier and the Free Software Foundation
 
23
 *
 
24
 * The following terms apply to Digital Equipment Corporation's copyright
 
25
 * interest in XBoard:
 
26
 * ------------------------------------------------------------------------
 
27
 * All Rights Reserved
 
28
 *
 
29
 * Permission to use, copy, modify, and distribute this software and its
 
30
 * documentation for any purpose and without fee is hereby granted,
 
31
 * provided that the above copyright notice appear in all copies and that
 
32
 * both that copyright notice and this permission notice appear in
 
33
 * supporting documentation, and that the name of Digital not be
 
34
 * used in advertising or publicity pertaining to distribution of the
 
35
 * software without specific, written prior permission.
 
36
 *
 
37
 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 
38
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 
39
 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 
40
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 
41
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 
42
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 
43
 * SOFTWARE.
 
44
 * ------------------------------------------------------------------------
 
45
 *
 
46
 * This file is part of GNU shogi.
 
47
 *
 
48
 * GNU shogi is free software; you can redistribute it and/or modify
 
49
 * it under the terms of the GNU General Public License as published by
 
50
 * the Free Software Foundation.
 
51
 *
 
52
 * GNU shogi is distributed in the hope that it will be useful,
 
53
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
54
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
55
 * GNU General Public License for more details.
 
56
 *
 
57
 * You should have received a copy of the GNU General Public License
 
58
 * along with GNU shogi; see the file COPYING.  If not, write to
 
59
 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
 
60
 *
 
61
 * ------------------------------------------------------------------------
 
62
 *
 
63
 */
 
64
 
 
65
static int lines = 1, cols = 1;
 
66
%}
 
67
 
 
68
PIECE   [PLNSGBRK]               
 
69
SQUARE  [1-9][a-i]     
 
70
NUMBER  [1-9]([0-9])*
 
71
COMMENT ["#"]([^\n])*
 
72
 
 
73
%%
 
74
 
 
75
"\n"      { lines++; cols = 1; }
 
76
"+"       { cols++;  return PROMOTE; }
 
77
"*"       { cols++;  return DROPS; }
 
78
"'"       { cols++;  return DROPS; }
 
79
"."       { cols++;  return COLON; }
 
80
{PIECE}   { yylval.string = yytext; cols += strlen(yytext); return PIECE;  }
 
81
{SQUARE}  { yylval.string = yytext; cols += strlen(yytext); return SQUARE; }
 
82
{NUMBER}  { yylval.string = yytext; cols += strlen(yytext); return NUMBER; }
 
83
{COMMENT} { yylval.string = yytext; lines++; cols = 1; return COMMENT; }
 
84
.         { cols++; }
 
85
 
 
86
%%
 
87
 
 
88
/*
 
89
 * This is to avoid having to link in a lex library;
 
90
 * flex also allows the "%option noyywrap" option but
 
91
 * I don't think that's generally true of other lex
 
92
 * implementations.
 
93
 */
 
94
 
 
95
int
 
96
yywrap()
 
97
{
 
98
    return 1;
 
99
}
 
100
 
 
101
 
 
102