1 /*
2  * Copyright 1993, 1995 Christopher Seiwald.
3  *
4  * This file is part of Jam - see jam.c for Copyright information.
5  */
6 
7 /*
8  * scan.h - the jam yacc scanner
9  *
10  * External functions:
11  *  yyerror( char *s ) - print a parsing error message.
12  *  yyfparse( char *s ) - scan include file s.
13  *  yylex() - parse the next token, returning its type.
14  *  yymode() - adjust lexicon of scanner.
15  *  yyparse() - declaration for yacc parser.
16  *  yyanyerrors() - indicate if any parsing errors occurred.
17  *
18  * The yymode() function is for the parser to adjust the lexicon of the scanner.
19  * Aside from normal keyword scanning, there is a mode to handle action strings
20  * (look only for the closing }) and a mode to ignore most keywords when looking
21  * for a punctuation keyword. This allows non-punctuation keywords to be used in
22  * lists without quoting.
23  */
24 
25 #include "config.h"
26 #include "lists.h"
27 #include "object.h"
28 #include "parse.h"
29 
30 
31 /*
32  * YYSTYPE - value of a lexical token
33  */
34 
35 #define YYSTYPE YYSYMBOL
36 
37 typedef struct _YYSTYPE
38 {
39     int          type;
40     OBJECT     * string;
41     PARSE      * parse;
42     LIST       * list;
43     int          number;
44     OBJECT     * file;
45     int          line;
46     char const * keyword;
47 } YYSTYPE;
48 
49 extern YYSTYPE yylval;
50 
51 int yymode( int n );
52 void yyerror( char const * s );
53 int yyanyerrors();
54 void yyfparse( OBJECT * s );
55 void yyfdone( void );
56 void yysparse( OBJECT * name, const char * * lines );
57 int yyline();
58 int yylex();
59 int yyparse();
60 void yyinput_last_read_token( OBJECT * * name, int * line );
61 
62 #define SCAN_NORMAL  0  /* normal parsing */
63 #define SCAN_STRING  1  /* look only for matching } */
64 #define SCAN_PUNCT   2  /* only punctuation keywords */
65 #define SCAN_COND    3  /* look for operators that can appear in conditions. */
66 #define SCAN_PARAMS  4  /* The parameters of a rule "()*?+" */
67 #define SCAN_CALL    5  /* Inside a rule call. [].*/
68 #define SCAN_CASE    6  /* A case statement.  We only recognize ':' as special. */
69 #define SCAN_CONDB   7  /* The beginning of a condition (ignores leading comparison operators, so that if <x> in $(y) works.)*/
70 #define SCAN_ASSIGN  8  /* The list may be terminated by an assignment operator. */
71 #define SCAN_XASSIGN 9  /* The next token might be an assignment, but to token afterwards cannot. */
72