Syntaxanalyse von URL mit die Grammatik

Post on 25-May-2015

1.314 views 1 download

Tags:

Transcript of Syntaxanalyse von URL mit die Grammatik

Syntaxanalyse von URL

Syntaxanalyse von URL

mit die Grammatik

WWW = ∑ URI

0 files,

N DBs

British Broadcasting Corporation

//radio//radio

/tv//weather/

/worldservice/news//worldservice/languages//worldservice/programmes/newshour.shtml

British Broadcasting Corporation

//radio//radio

/tv//weather/

/worldservice/news//worldservice/languages//worldservice/programmes/newshour.shtml

British Broadcasting Corporation

//radio//radio

/tv//weather/

/worldservice/news//worldservice/languages//worldservice/programmes/newshour.shtml

Kontrollstrukturen

mit if?

Kontrollstrukturen

mit if?

split/\//?

split/\//?/\/\/\/\/

Reguläären

Ausdrücken?

BNF-Grammatik!

uri:homeeof|divisioneof|sectioneof|articleeof

Ganz und Teil

word:/[a‐z0‐9_‐]+/iext:'.'/[a‐z]+/S:m{/+}eof:/\Z/

Ganz und Teil

home:Sdivision:S'worldservice'S'languages'S(?)|SwordS(?)section:divisionwordS(?)article:sectionwordext

Definition

home:Sdivision:S'worldservice'S'languages'S(?)|SwordS(?)section:divisionwordS(?)article:sectionwordext

Definition

useParse::RecDescent;

Gebrauch

useParse::RecDescent;my$parser=newParse::RecDescent($grammar);

Gebrauch

useParse::RecDescent;my$parser=newParse::RecDescent($grammar);

my$parsed=$parser‐>uri($uri);

Gebrauch

useParse::RecDescent;my$parser=newParse::RecDescent($grammar);

my$parsed=$parser‐>uri($uri);

Gebrauch

Drei Zeilen

section:divisionwordS(?){$::section=$item{word}}

article:sectionwordext{$::article=$item{word}}

Aktion

section:divisionwordS(?){$::section=$item{word}}

article:sectionwordext{$::article=$item{word}}

Aktion

uri:homeeof{$::type='home'}

|divisioneof{$::type='division'}

Variablen

my$page=PageFactory($::type);

Na endlich!

de.rian.ru

Wo?

Andrew Shitov

2008 andy@shitov.ru

Syntaxanalyse von URL

mit die

Grammatik von Perl 6

Nächstes Mal

WWW = ∑ URI

Beweis

#!/usr/bin/perl5.10usefeature‘say’;usestrict;

$a=<>;#Eingabe‘URI’chomp$a;

$b^=ordforsplit//,$a;

s//(chrreversesplit\/\/,$b)/e;say$_xlength$a;#Ausgabe‘WWW’