1 /*
2 *   Copyright (c) 2003-2004, Ascher Stefan <stievie@utanet.at>
3 *   Copyright (c) 2020, Masatake YAMATO
4 *   Copyright (c) 2020, Red Hat, Inc.
5 *
6 *   This source code is released for free distribution under the terms of the
7 *   GNU General Public License version 2 or (at your option) any later version.
8 */
9 
10 #ifndef CTAGS_PARSER_R_H
11 #define CTAGS_PARSER_R_H
12 
13 /*
14 *   INCLUDE FILES
15 */
16 
17 #include "general.h"  /* must always come first */
18 
19 #include "subparser.h"
20 #include "tokeninfo.h"
21 #include "entry.h"
22 
23 
24 /*
25 *   DATA DECLARATIONS
26 */
27 
28 typedef struct sRSubparser rSubparser;
29 
30 enum RTokenType {
31 	/* 0..255 are the byte's values */
32 	TOKEN_R_EOF = 256,
33 	TOKEN_R_UNDEFINED,
34 	TOKEN_R_KEYWORD,
35 	TOKEN_R_NEWLINE,
36 	TOKEN_R_NUMBER,				/* 1, 1L */
37 	TOKEN_R_SYMBOL,				/* [0-9a-zA-Z._] */
38 	TOKEN_R_STRING,
39 	TOKEN_R_OPERATOR,				/* - + ! ~ ? : * / ^ %...%, <, > ==
40 								 * >=, <=, &, &&, |, || */
41 	TOKEN_R_DOTS,					/* ... */
42 	TOKEN_R_DOTS_N,				/* ..1, ..2, etc */
43 	TOKEN_R_LASSIGN,				/* <-, <<- */
44 	TOKEN_R_RASSIGN,				/* ->, ->> */
45 	TOKEN_R_SCOPE,				/* ::, ::: */
46 };
47 
48 enum eRKeywordId
49 {
50 	KEYWORD_R_C,
51 	KEYWORD_R_DATAFRAME,
52 	KEYWORD_R_FUNCTION,
53 	KEYWORD_R_IF,
54 	KEYWORD_R_ELSE,
55 	KEYWORD_R_FOR,
56 	KEYWORD_R_WHILE,
57 	KEYWORD_R_REPEAT,
58 	KEYWORD_R_IN,
59 	KEYWORD_R_NEXT,
60 	KEYWORD_R_BREAK,
61 	KEYWORD_R_TRUE,
62 	KEYWORD_R_FALSE,
63 	KEYWORD_R_NULL,
64 	KEYWORD_R_INF,
65 	KEYWORD_R_LIST,
66 	KEYWORD_R_NAN,
67 	KEYWORD_R_NA,
68 	KEYWORD_R_SOURCE,
69 	KEYWORD_R_LIBRARY,
70 };
71 
72 struct sRSubparser {
73 	subparser subparser;
74 	int (* readRightSideSymbol) (rSubparser *s,
75 								 tokenInfo *const symbol,
76 								 const char *const assignmentOperator,
77 								 int parent,
78 								 tokenInfo *const token);
79 	int (* makeTagWithTranslation) (rSubparser *s,
80 									tokenInfo *const token,
81 									int parent,
82 									bool in_func,
83 									int kindInR,
84 									const char *const assignmentOperator);
85 	bool (* askTagAcceptancy) (rSubparser *s, tagEntryInfo *pe);
86 	bool (* hasFunctionAlikeKind) (rSubparser *s, tagEntryInfo *pe);
87 	int (* readFuncall) (rSubparser *s,
88 						 tokenInfo *const func,
89 						 tokenInfo *const token,
90 						 int parent);
91 };
92 
93 extern void rSetupCollectingSignature (tokenInfo *const token,
94 									   vString   *signature);
95 extern void rTeardownCollectingSignature (tokenInfo *const token);
96 
97 /*
98  * FUNCTION PROTOTYPES
99  */
100 
101 extern tokenInfo *rNewToken (void);
102 
103 extern void rTokenReadNoNewline (tokenInfo *const token);
104 
105 /* This function returns true if a new token is read.
106  * EOF is exception. If EOF is read, this function returns FALSE. */
107 extern bool rParseStatement (tokenInfo *const token, int parentIndex, bool inArgList);
108 
109 extern vString *rExtractNameFromString (vString* str);
110 
111 #endif	/* CTAGS_PARSER_TEX_H */
112