Programing > part2.yaccˤWebץȸ

Part1.JavascriptǤΤǡϴñʥץȸäƤߤޤץȸγȯɬפʴŪʵѤǧ뤿ˡΤñʥץȸޤ

ΥڡǤϡkmyaccġȤơJavascriptưΤޤʸڤʤɤϺʤǡ̤Υץߥ󥰸Ѵޤ

ȤꤢSaruMane Script(ץ)Ȥ̾դ뤳Ȥˤޤ

ʡ

ץȸǤϡȰäơʸ䥳Ȥʤɤ򰷤Τǡޤʡ()ľޤ ʸϤΩäơɤʸڤФʬԤΤΥʡϤȤ쥭륢ʥ饤(Lexical analyzer)ȸƤФޤ

ǤϡyaccΥץեˡʡΥɤޤƤޤ򺹤ؤޤ

ȤꤢǤϡʡư륵ץڡѰդޤ

ʸȽ̤ˤϡɽȤäƤޤ

ѥʡyaccμ˹碌ơХѿ(!)ȤäƤޤ

ʡư

ʤϡɤ򼡤Τ褦ʬषƹʸϤޤ

  • IDENT
    • :̻(ѿ̾ؿ̾)
    • §:ǽʸʸ(a-zA-Z)˥С(_)θ˱ѿ
  • NUMBER
    • :
    • §:Ȥ롣
  • STRING
    • §:֥륯ơ(")󥰥륯ơ(')ǰϤ
  • COMMENT
    • :Υ()
    • §://
    • ׻䥫åʤ

Τ褦Ϥ

123abc"xyz"//comment

Τ褦ɽޤ

-1 : 123abc"xyz"//comment,token : 123,yylex : 257
-1 : abc"xyz"//comment,token : abc,yylex : 258
-1 : "xyz"//comment,token : xyz,yylex : 259
-1 : //comment,token : //comment,yylex : COMMENT1

Ƭϲ԰(Ե椬ʤϡ-1)Τȡ߲ϤƤʸڤФ̡ʬ̤³ޤ

ʤʸȽ̤Ǥ褦ˤƤޤ̾ʸ̵뤷ƼΤƤ뤱ɡδʰץץȸѴʤΤǻĤ褦ˤƤޤ

ʡȥѡȤ߹碌

ưǧΤᡢʡʬष̤̤褦ʹʸϴ(parser:ѡ)äƤߤޤ

program:	/* empty */
       | program stmt { setAnswer(outputs); }
       ;

stmt	: NUMBER  { outputs += "NUMBER: " + yylval + "<br>";}
	| IDENT { outputs += "IDENT: " + yylval + "<br>";}
	| STRING { outputs += "STRING: " + yylval + "<br>";}
	| COMMENT { outputs += "COMMENT: " + yylval + "<br>";}
	| '\n' { outputs += "(CR)<br>"; }
	| error { $$ = ""; }
	;

ʡʬष̤ϡʸ¦ȽǤơʬȥǡɽޤ

Ȥ

123abc"xyz"//456

Ϥȡ

NUMBER: 123
IDENT: abc
STRING: xyz
COMMENT: //456

ɽޤ

ץäݤΤ񤱤褦ˤ

ϡѡĥơʸȴؿȰ񤱤褦ˤޤ ǡץäݤΤҤǤ褦ˤʤޤ

ȤСΤ褦Ϥ

a=200
x()
y(100)
z(1,2,3,4)
a=1*(2+3)
b=x(100)
c=200 //comment

Τ褦ˡΤޤɽޤ

a=200
x()
y(100)
z(1,2,3,4)
a=1*(2+3)
b=x(100)
c=200
//comment

Ϥץ򡢤ä󥹥ʡǥХХˤơѡȤΩƤʤƤΤǤ

ޤǤʳбƤΤϡιʸǤ

  • ؿƤӽФ funcall
    • ؿ̾()//
    • ؿ̾()//ʤ
  • ʸ assign
    • ѿ̾=
  • ʸ //פޤ
  • args
    • 1, 23
    • 1
  • expr
    • ­, , ݤ, 껻, ;
    • åˤͥդ, ؿƤӽФ
  • ܥǡ¤ primary
    • ̻(ѿ̾, ؿ̾)
    • ʸ󡡡֡ɡɡפ' 'פǰϤΡ׵Ȥʤ

ʸ롼˹פʤϡsyntax errorפɽޤ

ȤСΤ褦ˡʸ񤤤Ƥ⡢ؿƤӽФǤʸǤ⥳ʸǤʤᡢsyntax errorפɽޤ

abc

ޤǤΡեϼΤ褦ˤʤäƤޤ

Processing.jsäݤ񤱤褦ˤ

ǺäƤʰץץȸϡåȸProcessing.jsˤƤޤProcessing.jsϡӥ奢ǥѥץߥ󥰸Processing(ץå󥰡ˤWebǤǤ(Javascript١Processing)եå˥᡼桼ˤ갷䤹ʤäƤޤ

Processing.jsˤ롢˥᡼󥵥ץϤʴǤ

ץ mouse_move

ʰץץȸμʵǽϡΤ褦ʴˤޤ

  • ̿ؿʤɤProcessing.jsȤʤ
  • Υߥ(;)ס
  • IfʸȤForʸȤWhileʸȤ⡢(Ȥꤢ)ʤProcessing.jsȡʤǤ⤽餷ץबΤǡ
  • 饹Ϥ뤱ɡ饹(ΤȤ)ʤ

ǡʤդΥߥʤΥץѴ

void setup() {
  size(250, 250)
  frameRate(20)
}
void draw() {
  background(0)
  ellipse(width/2, height/2, mouseX, mouseY)
}

ʤդˡProcessinng.jsѴޤ

void setup() { size(250, 250);
  frameRate(20);
}
void draw() { background(0);
  ellipse(width/2, height/2, mouseX, mouseY);
}

ץڡȥեϼΤ褦ˤʤäƤޤ

ǤϡǽŪˤ̤줷ȤϤޤ󤬡ȼʸˡΥץȸκȤˤʤϤ

Processing.jsѴƼ¹Ԥ

ĤˡǤޤ

ѴɤProcessing.jsϤƼ¹Ԥޤ

ȤꤢץڡRunܥ򥯥å줫顢¦ιꥢ˥ޥݥ󥿤碌ȡΰ֤˹碌ʱߤޤΤˤϡѴΥץȤɽޤ

ư

˴ʰŪʥץȸʤΤǡΤ褦դɬפǤ

֥åȤб

/* */פȤäʣԤˤޤ륳ȤϡΤȤȤޤ

ǥХåġˤǥХå

ץȤϡѴľܼ¹ԤƤΤǡǥХåġŬѤǤޤ

ѴΥץȤProcessing.jsľŽդȤ⤦䤹ʤ뤫⡣

ХѿξͲ

SaruMane ScriptϡĤХѿȤäƤޤ(yyyBufferyyyTokenyylval)̤̾ˤƤΤǡͤ뤳ȤϡۤȤɤʤȻפޤǰΤդƤ

ХѿȤäƤȡ¾ΥץȾͤΤǡJavascriptξѴץ򥯥㡼ˤȤкʤʤʤʡȻפäƤɡĴ٤Ƥߤ顢äȼ֤Τǡ󤷤ˤޤ


Part1.yaccˤJavascript

Part3.ܸäݤWebץȸ˿ʤ

ͻ


  ȥå   ʬ Хåå   ñ측 ǽ   إ   ǽRSS
Last-modified: 2014-02-17 () 16:28:31 (1761d)