http://dinosaur.compilertools.net/yacc/index.html
それぞれの、グラマーに対してアクションを指定することができる。
A: '(' B ')'
{hello( 1, "abc" );}
and
XXX : YYY ZZZ
{ printf("a message\n");
flag = 25;}
1を返すだけ。
{ $$ = 1; }
$1,$2... という変数で、値を取ることが出来る。以下のような式の場合こんなかんじ。
A : B C D ; $1 = B $2 = C $3 = D
デフォルトは $1 ドス。
間にアクションもいれれるよ。
A :B
{ $$ = 1; }
C
{ x = $2; y = $3; }
;
http://dinosaur.compilertools.net/yacc/index.html
declarations
%%
rules
%%
programs
%%
rules
A : BODY ;
'\n' newline
'\r' return
'\'' single quote ``'''
'\\' backslash ``\''
'\t' tab
'\b' backspace
'\f' form feed
'\xxx' ``xxx'' in octal
A : B C D ;
A : E F ;
A : G ;
こう書ける。
A : B C D
| E F
| G
;
empty : ;
Names representing tokens must be declared; this is most simply done by writing
%token name1 name2 . . .
in the declarations section.
Every name not defined in the declarations section is assumed to represent a nonterminal symbol. Every nonterminal symbol must appear on the left side of at least one rule.
%start symbol
もしくは、最初に定義されてグラマー。
emailとかpasswordとかなくても認証できるようになるしくみ。すげー。ユーザは、自分の Openid Providerを自由に選択できるよ。http(s)だけで実装だから、いい感じだよ的がかかれてる。