SlideShare a Scribd company logo
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
Deutsche Welle


/dw/0,,298,00.html


/dw/article/0,2144,3116297,00.html


/popups/popup_lupe/0,,1123341,00.html


/image/0,,1336753_1,00.jpg
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!
Ganz und Teil


uri








:
home









eof












|
division





eof












|
section






eof












|
article






eof
Ganz und Teil



word







:
/[a‐z0‐9_‐]+/i
ext








:
'.'
/[a‐z]+/
S










:
m{/+}
eof








:
/Z/
Definition

home







:
S
division



:
S
'worldservice'
S
















'languages'
S(?)












|
S
word
S(?)
section




:
division
word
S(?)
article




:
section
word
ext
Definition

home







:
S
division



:
S
'worldservice'
S
















'languages'
S(?)












|
S
word
S(?)
section




:
division
word
S(?)
article




:
section
word
ext
Gebrauch

use
Parse::RecDescent;
Gebrauch

use
Parse::RecDescent;
my
$parser
=
new
Parse::RecDescent($grammar);
Gebrauch

use
Parse::RecDescent;
my
$parser
=
new
Parse::RecDescent($grammar);


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

use
Parse::RecDescent;
my
$parser
=
new
Parse::RecDescent($grammar);


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



Drei Zeilen
Aktion
section




:
division
word
S(?)
{


















$::section
=
$item{word}














}

article




:
section
word
ext
{


















$::article
=
$item{word}














}
Aktion
section




:
division
word
S(?)
{


















$::section
=
$item{word}














}

article




:
section
word
ext
{


















$::article
=
$item{word}














}
Variablen
uri








:
home





eof
{


















$::type
=
'home'














}













|
division

eof
{


















$::type
=
'division'














}

Na endlich!



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


      de.rian.ru
Andrew Shitov
2008     andy@shitov.ru
Nächstes Mal


  Syntaxanalyse von URL
     mit die
Grammatik von Perl 6
Beweis


WWW = ∑ URI
#!/usr/bin/perl5.10
use
feature
‘say’;
use
strict;

$a
=
<>;















#
Eingabe
‘URI’
chomp
$a;

$b
^=
ord
for
split
//,
$a;

s//(chr
reverse
split
//,
$b)/e;
say
$_
x
length
$a;




#
Ausgabe
‘WWW’

More Related Content

More from Andrew Shitov

Perl6 one-liners
Perl6 one-linersPerl6 one-liners
Perl6 one-liners
Andrew Shitov
 
Creating a compiler in Perl 6
Creating a compiler in Perl 6Creating a compiler in Perl 6
Creating a compiler in Perl 6
Andrew Shitov
 
Fun with Raspberry PI (and Perl)
Fun with Raspberry PI (and Perl)Fun with Raspberry PI (and Perl)
Fun with Raspberry PI (and Perl)
Andrew Shitov
 
Perl6 in-production
Perl6 in-productionPerl6 in-production
Perl6 in-production
Andrew Shitov
 
Параллельные вычисления в Perl 6
Параллельные вычисления в Perl 6Параллельные вычисления в Perl 6
Параллельные вычисления в Perl 6
Andrew Shitov
 
AllPerlBooks.com
AllPerlBooks.comAllPerlBooks.com
AllPerlBooks.com
Andrew Shitov
 
Perl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel ComputingPerl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel Computing
Andrew Shitov
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of Smartmatch
Andrew Shitov
 
YAPC::Europe 2013
YAPC::Europe 2013YAPC::Europe 2013
YAPC::Europe 2013
Andrew Shitov
 
Perl 7, the story of
Perl 7, the story ofPerl 7, the story of
Perl 7, the story of
Andrew Shitov
 
Язык программирования Go для Perl-программистов
Язык программирования Go для Perl-программистовЯзык программирования Go для Perl-программистов
Язык программирования Go для Perl-программистов
Andrew Shitov
 
Как очистить массив
Как очистить массивКак очистить массив
Как очистить массив
Andrew Shitov
 
What's new in Perl 5.14
What's new in Perl 5.14What's new in Perl 5.14
What's new in Perl 5.14
Andrew Shitov
 
Что нового в Perl 5.14
Что нового в Perl 5.14Что нового в Perl 5.14
Что нового в Perl 5.14
Andrew Shitov
 
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammars
Andrew Shitov
 
Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6
Andrew Shitov
 
There's more than one way to empty it
There's more than one way to empty itThere's more than one way to empty it
There's more than one way to empty it
Andrew Shitov
 
Perl 6 by example
Perl 6 by examplePerl 6 by example
Perl 6 by example
Andrew Shitov
 
How to clean an array
How to clean an arrayHow to clean an array
How to clean an array
Andrew Shitov
 
Perl 5.10 и 5.12
Perl 5.10 и 5.12Perl 5.10 и 5.12
Perl 5.10 и 5.12
Andrew Shitov
 

More from Andrew Shitov (20)

Perl6 one-liners
Perl6 one-linersPerl6 one-liners
Perl6 one-liners
 
Creating a compiler in Perl 6
Creating a compiler in Perl 6Creating a compiler in Perl 6
Creating a compiler in Perl 6
 
Fun with Raspberry PI (and Perl)
Fun with Raspberry PI (and Perl)Fun with Raspberry PI (and Perl)
Fun with Raspberry PI (and Perl)
 
Perl6 in-production
Perl6 in-productionPerl6 in-production
Perl6 in-production
 
Параллельные вычисления в Perl 6
Параллельные вычисления в Perl 6Параллельные вычисления в Perl 6
Параллельные вычисления в Perl 6
 
AllPerlBooks.com
AllPerlBooks.comAllPerlBooks.com
AllPerlBooks.com
 
Perl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel ComputingPerl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel Computing
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of Smartmatch
 
YAPC::Europe 2013
YAPC::Europe 2013YAPC::Europe 2013
YAPC::Europe 2013
 
Perl 7, the story of
Perl 7, the story ofPerl 7, the story of
Perl 7, the story of
 
Язык программирования Go для Perl-программистов
Язык программирования Go для Perl-программистовЯзык программирования Go для Perl-программистов
Язык программирования Go для Perl-программистов
 
Как очистить массив
Как очистить массивКак очистить массив
Как очистить массив
 
What's new in Perl 5.14
What's new in Perl 5.14What's new in Perl 5.14
What's new in Perl 5.14
 
Что нового в Perl 5.14
Что нового в Perl 5.14Что нового в Perl 5.14
Что нового в Perl 5.14
 
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammars
 
Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6
 
There's more than one way to empty it
There's more than one way to empty itThere's more than one way to empty it
There's more than one way to empty it
 
Perl 6 by example
Perl 6 by examplePerl 6 by example
Perl 6 by example
 
How to clean an array
How to clean an arrayHow to clean an array
How to clean an array
 
Perl 5.10 и 5.12
Perl 5.10 и 5.12Perl 5.10 и 5.12
Perl 5.10 и 5.12
 

Syntaxanalyse von URL mit die Grammatik