]> git.sesse.net Git - pgn-extract/blob - lex.h
Push through a computer/human flag to the binary output.
[pgn-extract] / lex.h
1 /*
2  *  Program: pgn-extract: a Portable Game Notation (PGN) extractor.
3  *  Copyright (C) 1994-2014 David Barnes
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 1, or (at your option)
7  *  any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17  *
18  *  David Barnes may be contacted as D.J.Barnes@kent.ac.uk
19  *  http://www.cs.kent.ac.uk/people/staff/djb/
20  *
21  */
22
23         /* Define a type to make it easy to return where we are
24          * in the input line.  This type is returned from those functions
25          * that may modify the line/linep pair in next_token().
26          */
27 typedef struct{
28     /* Start of the malloc'ed line. */
29     char *line;
30     /* The next char to access in line, if line is not NULL. */
31     unsigned char *linep;
32     /* What token resulted. */
33     TokenType token;
34 } LinePair;
35
36 /* Define a type to hold a list of input files. */
37 typedef struct {
38     /* The list should have a (char *)NULL on the end. */
39     const char **files;
40     SourceFileType *file_type;
41     /* Keep track of the number of files in the list. */
42     unsigned num_files;
43     /* Keep track of how many the list may hold. */
44     unsigned max_files;
45 } FILE_LIST;
46
47 #if 1
48 #define RUSSIAN_KNIGHT_OR_KING (0x008a)
49 #define RUSSIAN_KING_SECOND_LETTER (0x00e0)
50 #define RUSSIAN_QUEEN (0x0094)
51 #define RUSSIAN_ROOK (0x008b)
52 #define RUSSIAN_BISHOP (0x0091)
53 #define RUSSIAN_PAWN (0x00af)
54 #else
55 #define RUSSIAN_KNIGHT_OR_KING (0x00eb)
56 #define RUSSIAN_KING_SECOND_LETTER (0x00d2)
57 #define RUSSIAN_QUEEN (0x00e6)
58 #define RUSSIAN_ROOK (0x00ec)
59 #define RUSSIAN_BISHOP (0x00f3)
60 #endif
61 /* Define a macro for checking the value of a char against
62  * one of the Russian piece letters.
63  */
64 #define RUSSIAN_PIECE_CHECK(c) ((c) & 0x00ff)
65
66     /* Shared prototypes for the non-static functions in the
67      * lexical analyser.
68      */
69 void yyerror(const char *s);
70 void save_assessment(const char *assess);
71 void restart_lex_for_new_game(void);
72 void free_move_list(Move *move_list);
73 void print_error_context(FILE *fp);
74 void init_lex_tables(void);
75 TokenType next_token(void);
76 TokenType skip_to_next_game(TokenType token);
77 const char *tag_header_string(TagName tag);
78 Boolean open_first_file(void);
79 const char *input_file_name(unsigned file_number);
80 unsigned current_file_number(void);
81 Boolean seek_to_begin(void);
82 Boolean at_end_of_input(void);
83 Boolean open_eco_file(const char *eco_file);
84 int yywrap(void);
85 void add_filename_to_source_list(const char *filename,SourceFileType file_type);
86 void add_filename_list_from_file(FILE *fp,SourceFileType file_type);
87 void reset_line_number(void);
88 char *next_input_line(FILE *fp);
89 LinePair gather_tag(char *line, unsigned char *linep);
90 LinePair gather_string(char *line, unsigned char *linep);
91 Boolean is_character_class(unsigned char ch, TokenType character_class);
92 long get_position(void);