source: code/trunk/vendor/modernc.org/cc/v3/lexer.l@ 822

Last change on this file since 822 was 822, checked in by yakumo.izuru, 22 months ago

Prefer immortal.run over runit and rc.d, use vendored modules
for convenience.

Signed-off-by: Izuru Yakumo <yakumo.izuru@…>

File size: 2.6 KB
Line 
1%{
2// Copyright 2019 The CC Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style
4// license that can be found in the LICENSE file.
5%}
6
7%yyc c
8%yyn c = s.next()
9%yym s.mark = len(s.charBuf)
10
11%{
12package cc // import "modernc.org/cc/v3"
13
14func (s *scanner) scan() (r rune) {
15%}
16
17c-char [^'\n\x80\\]|{escape-sequence}
18c-char-sequence {c-char}+
19character-constant '{c-char-sequence}'
20comment "/*"([^*\x80]|\*+[^*/\x80])*\*+\/
21comment-not-terminated "/*"([^*\x80]|\*+[^*/\x80])*(\*+)?\n\x80
22digit [0-9]
23escape-sequence {simple-sequence}|{octal-escape-sequence}|{hexadecimal-escape-sequence}|{universal-character-name}
24hex-quad {hexadecimal-digit}{hexadecimal-digit}{hexadecimal-digit}{hexadecimal-digit}
25hexadecimal-digit [0-9a-fA-F]
26hexadecimal-escape-sequence \\x{hexadecimal-digit}+
27identifier {identifier-nondigit}({identifier-nondigit}|{digit}|"$")*
28identifier-nondigit {nondigit}|"$"|{universal-character-name}
29line-comment "//"[^\n\x80]*
30nondigit [_a-zA-Z\x81]
31octal-digit [0-7]
32octal-escape-sequence \\{octal-digit}{octal-digit}?{octal-digit}?
33pp-number ({digit}|\.{digit})({digit}|{identifier-nondigit}|[eEpP]{sign}|\.)*
34s-char [^\x22\n\x80\\]|{escape-sequence}
35s-char-sequence {s-char}+
36sign [-+]
37simple-sequence \\['\x22?\\abefnrtv]
38string-literal \x22{s-char-sequence}?\x22
39universal-character-name \\u{hex-quad}|\\U{hex-quad}{hex-quad}
40white-space [ \t\f\v]
41
42%%
43 c := s.initScan()
44
45({white-space}|{comment})*{line-comment} |
46({white-space}|{comment})+{line-comment}?
47 return ' '
48
49(({white-space}|{comment})*{comment-not-terminated})+
50 return s.unterminatedComment()
51
52"!=" return NEQ
53"##" return PPPASTE
54"%:" return '#'
55"%:%:" return PPPASTE
56"%=" return MODASSIGN
57"%>" return '}'
58"&&" return ANDAND
59"&=" return ANDASSIGN
60"*=" return MULASSIGN
61"++" return INC
62"+=" return ADDASSIGN
63"--" return DEC
64"-=" return SUBASSIGN
65"->" return ARROW
66"..." return DDD
67"/=" return DIVASSIGN
68":>" return ']'
69"<%" return '{'
70"<:" return '['
71"<<" return LSH
72"<<=" return LSHASSIGN
73"<=" return LEQ
74"==" return EQ
75">=" return GEQ
76">>" return RSH
77">>=" return RSHASSIGN
78"^=" return XORASSIGN
79"|=" return ORASSIGN
80"||" return OROR
81
82L{string-literal} return LONGSTRINGLITERAL
83L{character-constant} return LONGCHARCONST
84{character-constant} return CHARCONST
85{identifier} return IDENTIFIER
86{pp-number} return PPNUMBER
87{string-literal} return STRINGLITERAL
88
89\r?\n return '\n'
90
91%%
92 if c, ok := s.abort(); ok {
93 return rune(c)
94 }
95
96 goto yyAction
97}
Note: See TracBrowser for help on using the repository browser.