diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-10-20 22:48:31 +0300 | 
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-10-23 18:25:23 +0300 | 
| commit | fe66fcdb1549b380fad440320e50e332f409efd3 (patch) | |
| tree | 0720135965905d8416f045ef61f260c9e76c01b3 /src | |
| parent | 4cf7c8bacfc836cff5278317cb32dc029cb87273 (diff) | |
| download | lyn-fe66fcdb1549b380fad440320e50e332f409efd3.tar.gz lyn-fe66fcdb1549b380fad440320e50e332f409efd3.zip | |
clear some warnings
Diffstat (limited to 'src')
| -rw-r--r-- | src/parser.y | 108 | 
1 files changed, 0 insertions, 108 deletions
| diff --git a/src/parser.y b/src/parser.y index 7b49eb8..a87b6c6 100644 --- a/src/parser.y +++ b/src/parser.y @@ -69,21 +69,6 @@  YY_DECL;  /** - * Gobble tokens until we reach the next interesting feature. - * Interesting features are generally new statements. - * Mainly intended for trying to get to a sensible - * location to continue parser after an error has occured. - * - * @param yylval Current parser value. - * @param yylloc Parser location info. - * @param scanner Lex scanner. - * @param parser Current parser. - * @return \c 0 on success, non-zero otherwise. - */ -static int next_interesting_feature(YYSTYPE *yylval, YYLTYPE *yylloc, -                             void *scanner, struct parser *parser); - -/**   * Convert bison location info to our own source location info.   *   * @param yylloc Bison location info. @@ -103,25 +88,6 @@ static struct src_loc src_loc(YYLTYPE yylloc);  static void yyerror(YYLTYPE *yylloc, void *lexer,  		struct parser *parser, const char *msg); -/** - * Try to convert escape code to its actual value. - * I.e. '\n' -> 0x0a. - * - * @param c Escape character without backslash. - * @return Corresponding value. - */ -static char match_escape(char c); - -/** - * Similar to strdup() but skips quotation marks that would - * otherwise be included. - * I.e. "something" -> something. - * - * @param s String to clone, with quotation marks surrounding it. - * @return Identical string but without quotation marks around it. - */ -static char *strip(const char *s); -  %}  %start input; @@ -170,35 +136,6 @@ input  #include "gen_lexer.inc" -/* I'm not convinced this is foolproof quite yet, more testing would be nice. */ -static int next_interesting_feature(YYSTYPE *yylval, YYLTYPE *yylloc, -				void *scanner, struct parser *parser) -{ -	size_t depth = 0; -	while (1) { -		int ret = yylex(yylval, yylloc, scanner, parser); -		if (ret == LBRACE) { -			depth++; -			continue; -		} - -		if (ret == RBRACE && depth > 0) -			depth--; - -		if (ret == RBRACE && depth == 0) -			return 0; - -		if (ret == SEMICOLON && depth == 0) -			return 0; - -		/* return fatal error and parser should abort */ -		if (ret == YYEOF) -			/* some error for unmatched braces would be cool I think */ -			return 1; -	} -} - -  static struct src_loc src_loc(YYLTYPE yylloc)  {  	struct src_loc loc; @@ -222,51 +159,6 @@ static void yyerror(YYLTYPE *yylloc, void *lexer,  	src_issue(issue, msg);  } -static char match_escape(char c) -{ -	switch (c) { -	case '\'': return '\''; -	case '\\': return '\\'; -	case 'a': return '\a'; -	case 'b': return '\b'; -	case 'f': return '\f'; -	case 'n': return '\n'; -	case 'r': return '\r'; -	case 't': return '\t'; -	case 'v': return '\v'; -	} - -	return c; -} - -static char *strip(const char *str) -{ -	const size_t len = strlen(str) + 1; -	char *buf = malloc(len); -	if (!buf) { -		/* should probably try to handle the error in some way... */ -		error("failed allocating buffer for string clone"); -		free((void *)str); -		return NULL; -	} - -	/* skip quotation marks */ -	size_t j = 0; -	for (size_t i = 1; i < len - 2; ++i) { -		char c = str[i]; - -		if (c == '\\') -			c = match_escape(str[++i]); - -		buf[j++] = c; -	} - -	buf[j] = 0; -	free((void *)str); -	return buf; - -} -  struct parser *create_parser()  {  	return calloc(1, sizeof(struct parser)); | 
