Annotation of src/usr.bin/xlint/lint1/scan.l, Revision 1.138
1.1 cgd 1: %{
1.138 ! rillig 2: /* $NetBSD: scan.l,v 1.137 2023/01/08 22:46:00 rillig Exp $ */
1.2 cgd 3:
1.1 cgd 4: /*
1.9 cgd 5: * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
1.1 cgd 6: * Copyright (c) 1994, 1995 Jochen Pohl
7: * All Rights Reserved.
8: *
9: * Redistribution and use in source and binary forms, with or without
10: * modification, are permitted provided that the following conditions
11: * are met:
12: * 1. Redistributions of source code must retain the above copyright
13: * notice, this list of conditions and the following disclaimer.
14: * 2. Redistributions in binary form must reproduce the above copyright
15: * notice, this list of conditions and the following disclaimer in the
16: * documentation and/or other materials provided with the distribution.
17: * 3. All advertising materials mentioning features or use of this software
18: * must display the following acknowledgement:
19: * This product includes software developed by Jochen Pohl for
20: * The NetBSD Project.
21: * 4. The name of the author may not be used to endorse or promote products
22: * derived from this software without specific prior written permission.
23: *
24: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34: */
35:
1.11 christos 36: #include <sys/cdefs.h>
1.136 rillig 37: #if defined(__RCSID)
1.138 ! rillig 38: __RCSID("$NetBSD: scan.l,v 1.137 2023/01/08 22:46:00 rillig Exp $");
1.1 cgd 39: #endif
40:
41: #include "lint1.h"
1.12 tv 42: #include "cgram.h"
1.1 cgd 43:
44: %}
45:
1.62 christos 46:
1.138 ! rillig 47: HEX [0-9A-Fa-f]
! 48: EXP ([eE][+-]?[0-9]+)
! 49: PEXP (p[+-]?[0-9A-Fa-f]+)
! 50: FSUF ([fFlL]?[i]?)
1.1 cgd 51:
1.46 christos 52: %option nounput
53:
1.1 cgd 54: %%
55:
1.138 ! rillig 56: [_A-Za-z][_A-Za-z0-9]* return lex_name(yytext, yyleng);
! 57: 0[bB][01]+[lLuU]* return lex_integer_constant(yytext, yyleng, 2);
! 58: 0[0-7]*[lLuU]* return lex_integer_constant(yytext, yyleng, 8);
! 59: [1-9][0-9]*[lLuU]* return lex_integer_constant(yytext, yyleng, 10);
! 60: 0[xX]{HEX}+[lLuU]* return lex_integer_constant(yytext, yyleng, 16);
! 61: [0-9]+\.[0-9]*{EXP}?{FSUF} |
! 62: [0-9]+{EXP}{FSUF} |
! 63: 0[xX]{HEX}+\.{HEX}*{PEXP}{FSUF} |
! 64: 0[xX]{HEX}+{PEXP}{FSUF} |
! 65: \.[0-9]+{EXP}?{FSUF} return lex_floating_constant(yytext, yyleng);
1.132 rillig 66: "=" return T_ASSIGN;
1.130 rillig 67: "*=" return lex_operator(T_OPASSIGN, MULASS);
68: "/=" return lex_operator(T_OPASSIGN, DIVASS);
69: "%=" return lex_operator(T_OPASSIGN, MODASS);
70: "+=" return lex_operator(T_OPASSIGN, ADDASS);
71: "-=" return lex_operator(T_OPASSIGN, SUBASS);
72: "<<=" return lex_operator(T_OPASSIGN, SHLASS);
73: ">>=" return lex_operator(T_OPASSIGN, SHRASS);
74: "&=" return lex_operator(T_OPASSIGN, ANDASS);
75: "^=" return lex_operator(T_OPASSIGN, XORASS);
76: "|=" return lex_operator(T_OPASSIGN, ORASS);
1.132 rillig 77: "||" return T_LOGOR;
78: "&&" return T_LOGAND;
79: "|" return T_BITOR;
80: "&" return T_AMPER;
1.133 rillig 81: "^" return T_BITXOR;
1.130 rillig 82: "==" return lex_operator(T_EQUALITY, EQ);
83: "!=" return lex_operator(T_EQUALITY, NE);
84: "<" return lex_operator(T_RELATIONAL, LT);
85: ">" return lex_operator(T_RELATIONAL, GT);
86: "<=" return lex_operator(T_RELATIONAL, LE);
87: ">=" return lex_operator(T_RELATIONAL, GE);
88: "<<" return lex_operator(T_SHIFT, SHL);
89: ">>" return lex_operator(T_SHIFT, SHR);
90: "++" return lex_operator(T_INCDEC, INC);
91: "--" return lex_operator(T_INCDEC, DEC);
1.134 rillig 92: "->" return T_ARROW;
93: "." return T_POINT;
1.130 rillig 94: "+" return lex_operator(T_ADDITIVE, PLUS);
95: "-" return lex_operator(T_ADDITIVE, MINUS);
1.132 rillig 96: "*" return T_ASTERISK;
1.130 rillig 97: "/" return lex_operator(T_MULTIPLICATIVE, DIV);
98: "%" return lex_operator(T_MULTIPLICATIVE, MOD);
1.135 rillig 99: "!" return T_LOGNOT;
100: "~" return T_COMPLEMENT;
1.130 rillig 101: "\"" return lex_string();
1.131 rillig 102: "L\"" return lex_wide_string();
1.97 rillig 103: ";" return T_SEMI;
104: "{" return T_LBRACE;
105: "}" return T_RBRACE;
106: "," return T_COMMA;
107: ":" return T_COLON;
108: "?" return T_QUEST;
109: "[" return T_LBRACK;
110: "]" return T_RBRACK;
1.108 rillig 111: "(" return T_LPAREN;
112: ")" return T_RPAREN;
1.123 rillig 113: "..." return T_ELLIPSIS;
1.131 rillig 114: "'" return lex_character_constant();
115: "L'" return lex_wide_character_constant();
1.130 rillig 116: ^#.*$ lex_directive(yytext);
1.131 rillig 117: \n lex_next_line();
1.1 cgd 118: \t|" "|\f|\v ;
1.130 rillig 119: "/*" lex_comment();
1.131 rillig 120: "//" lex_slash_slash_comment();
121: . lex_unknown_character(yytext[0]);
1.1 cgd 122:
123: %%
124:
1.137 rillig 125: /*
126: * In the above list of regular expressions, the tokens for character
127: * constants, string literals and comments are incomplete; they only match
128: * a prefix. The remainder of these tokens is scanned by reading bytes
129: * directly from the input stream.
130: */
1.1 cgd 131: int
1.130 rillig 132: lex_input(void)
1.6 jpo 133: {
1.130 rillig 134: return input();
1.1 cgd 135: }
CVSweb <webmaster@jp.NetBSD.org>