File: scanner.flex

package info (click to toggle)
xshogi 1.2p03-11
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,256 kB
  • ctags: 800
  • sloc: ansic: 7,843; makefile: 50; sh: 35
file content (22 lines) | stat: -rw-r--r-- 622 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
%{
static int lines=1,cols=1;
%}
PIECE  [PLNSGBRK]               
SQUARE [1-9][a-i]     
NUMBER [1-9]([0-9])*
COMMENT ["#"]([^\n])*
%%       
"\n"	  { lines++; cols=1; }
"+"	  { cols++;  return PROMOTE; }
"*"	  { cols++;  return DROPS; }
"'"	  { cols++;  return DROPS; }
"."	  { cols++;  return COLON; }
{PIECE}   { yylval.string = yytext; cols+=strlen(yytext); return PIECE; }
{SQUARE}  { yylval.string = yytext; cols+=strlen(yytext); return SQUARE; }
{NUMBER}  { yylval.string = yytext; cols+=strlen(yytext); return NUMBER; }
{COMMENT} { yylval.string = yytext; lines++; cols=1; return COMMENT; }
.	  { cols++; }
%%