File: demo_tokens.pl

package info (click to toggle)
libparse-recdescent-perl 1.967015%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 764 kB
  • sloc: perl: 6,797; makefile: 13; ansic: 9
file content (26 lines) | stat: -rwxr-xr-x 559 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#! /usr/local/bin/perl -w

use Parse::RecDescent;
use Data::Dumper;

my $lexer = new Parse::RecDescent q
{
	lex:	token(s)

  	token:	/(I|you|he)\b/i	<token:PRON>
 	     |	/(is|are)\b/	<token:VERB>
	     |	'dumbest'	<token:ADJ>
	     |	'Bill-loving'	<token:ADJ>
	     |	'clearly'	<token:ADJ>
	     |	/the\b|a\b/	<token:ARTICLE>
	     |	/\w+/		<token:WORD>
	     |  /\S+/		<token:PUNCT,OTHER>
};

my $tokens = $lexer->lex(join "", <DATA>);

print  Data::Dumper->Dump($tokens);

__DATA__

You are clearly the dumbest, Bill-loving script-kiddie I have ever seen!