开发者

Lex : line with one character but spaces

开发者 https://www.devze.com 2023-01-17 01:51 出处:网络
I have sentences like : \"a\" \"a\" \"a\" 开发者_如何学Go I would like to catch all this examples (with lex), but I don\'t how to say the beginning of the lineI\'m not totally sure what exactly you\

I have sentences like :

"      a"
"a    "
"      a         "
开发者_如何学Go

I would like to catch all this examples (with lex), but I don't how to say the beginning of the line


I'm not totally sure what exactly you're looking for, but the regex symbol to specify matching the beginning of a line in a lex definition is the caret:

^


If I understand correctly, you're trying to pull the "a" out as the token, but you don't want to grab any of the whitespace? If this is the case, then you just need something like the following:

[\n\t\r ]+ {
  // do nothing
}

"a" {
  assignYYText( yylval );
  return aToken;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消