File: phraser.jison

package info (click to toggle)
node-jison 0.4.17%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 348 kB
  • ctags: 57
  • sloc: yacc: 32; makefile: 16; sh: 3
file content (46 lines) | stat: -rw-r--r-- 837 bytes parent folder | download | duplicates (3)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* description: Parses words out of html, ignoring html in the parse, but returning it in the end */

/* lexical grammar */
%lex
%%
"<"(.|\n)*?">"						return 'TAG'
[a-zA-Z0-9]+						return 'WORD'
(.|\n)								return 'CHAR'
<<EOF>>								return 'EOF'


/lex

%start html

%% /* language grammar */

html
 : contents EOF
     {return $1;}
 ;

contents
 : content
	{$$ = $1;}
 | contents content
	{$$ =  $1 + $2;}
 ;

content
	: TAG
		{
			if (!yy.lexer.tagHandler) yy.lexer.tagHandler = function(tag) {return tag;};
			$$ = yy.lexer.tagHandler(yytext);
		}
	| WORD
		{
			if (!yy.lexer.wordHandler) yy.lexer.wordHandler = function(word) {return word;};
			$$ = yy.lexer.wordHandler(yytext);
		}
	| CHAR
		{
			if (!yy.lexer.charHandler) yy.lexer.charHandler = function(char) {return char;};
			$$ = yy.lexer.charHandler(yytext);
		}
 ;