SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Humanista w twoim Linuksie, czyli nie tylko
     o jądrach ale i języku słów kilka




           Adam Przybyła <adam@ertel.com.pl>
                        (mail i JID)
              (Creative Commons CC-by-nd)
        Dni Wolnego Oprogramowania - Bielsko 2012
Gandhi i jego Swaradż

Monopol solny obcych kor ... kompanii
Marsze solne
Rodzime tkactwo – własne narzędzia
Bierny opór
Czy to nie brzmi znajomo?
Swaradź, swaraj (z sanskrytu swaradźia ­ 
 "panowanie, rząd, samorząd"), hasło 
 wysunięte 1906 na sesji Indyjskiego 
 Kongresu Narodowego, 1920 wpisane do jego 
 programu. Wolność ale także w sensie 
 ekonomicznym. 
Jądro ciemności czyli co tkwi w systemach 
               Linuksowych

Jądro – czyli system
Interpretery
  Python, Perl, Php
Filtry
  Awk, Sed, Tr, Grep,
 Translatory
  Flex, Bison, ANTLR, M4
[adam@tao ~]$ file {/usr,}/bin/*|cut ­f2­ ­d: |awk '{print $1,$2}'|sort |uniq ­c|sort 
   ­rn

   2008 ELF 32­bit
    315 POSIX shell

    311 symbolic link

    105 a /usr/bin/python

     95 a /usr/bin/perl

     21 Bourne­Again shell

     16 a python

     13 setuid ELF

      5 setuid executable,

      4 setgid ELF

      3 setgid executable,

      3 a perl

[adam@tao ~]$
 Pliki weryfikowalne ­ XML
SAX
DOM
PULL
Opis CSV w EBNF
CSV file
­­­­­­­­
file         ::= [ header ] { line }
header       ::= [ { entry separator } entry ] newline
line         ::= [ { entry separator } entry ] newline
entry        ::= character+ | { character* " separator " } | " entry 
  newline entry "
newline      ::= n
separator    ::= ,
character    ::= a|b|..|A|B|..|0|1|..
escapedQuote ::= ""
Flex i Bison
Flex – analizator leksykalny
Rozszerzona wersja programu lex
Generuje tablice przejść
Parsery LR i LL
Gramatyka pliku definicji
{definicje}
%%
{reguły}
%%
{procedury użytkownika}
Plik konfiguracyjny analizatora 
%%         leksylalnego

,                     {return COMMA;}
n                    {return NEWLINE;}
rn                  {return NEWLINE;}
[^,nr]+             {return ITEM;}
Kod Bisona
%token COMMA NEWLINE ITEM

%%
csv_file : line_list | line_list line;
line_list : line_list line newline | line newline | 
  line_list newline | newline;
line : line comma | line item | item | comma;
comma : COMMA ;
newline : NEWLINE;
item : ITEM ;
Program wynikowy we Flex
static yyconst flex_int32_t yy_ec[256] =
   {   0,

        1,    1,    1,    1,    1,    1,    1,    1,    1,    2,

        1,    1,    3,    1,    1,    1,    1,    1,    1,    1,

        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,

        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,

        1,    1,    1,    4,    1,    1,    1,    1,    1,    1,

        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,

[ciach]
Program wynikowy we Bison
static const yytype_uint8 yytranslate[] =

{

       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,

       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,

       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,

       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,

       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,

       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,

                                                                   
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,

       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,

       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
Problemy analizy
Shift/Reduce
Reduce/reduce
Stany początkowe
Semantyczne predykaty a[i] (Ruby)
Flex z kernelem
Filtr klasyfikujący do kernela
https://github.com/AdamPrzybyla/layer7­flex
Kilka razy szybsze rozwiązanie niż wyrażenia 
 regularne niż oryginalne rozwiązanie
Analizator leksykalny ANTLR
PCTTS
Dla leniwych
Analizator LL(*)
Przejrzysty kod
Generacja kodu Java,c#,Python,C++
Tryby pracy ANTLR
Analizator leksykalny
Tworzenie AST
Walker AST
Generowanie plików graphviz
Przetwarzanie AST
Język template
Przetwarzanie drzew AST


Kompilator c kiedyś:
  Źródło w C
  C z rozwiniętymi makrami
  Asembler
  Plik .o + linkowanie
Kompilator C teraz:
  Kolejne modyfikacje drzew AST
Przepływ w parserze ANTLR
Język dziedzinowy ­ DSL
Graphviz ­ DOT
Yacc
SQL
HTML
VHDL
Edytor ANTLRWorks
Gramatyka CSV w ANTLR
grammar csv;

options {    language=Python; }

file : record (NEWLINE record)* EOF ;

record : (quoted_field | unquoted_field) (COMMA (quoted_field | unquoted_field))* ;

quoted_field : DQUOTE ( CHAR | COMMA | DQUOTE DQUOTE | NEWLINE)* 
   DQUOTE ;

unquoted_field : CHAR* ;

CHAR : 'u0000' .. 'u0009' | 'u000b' .. 'u000c' | 'u000e' .. 'u0021' | 'u0023' .. 
  'u002b'     | 'u002d' .. 'uffff' ;

COMMA : 'u002c' ;

DQUOTE : 'u0022' ;

NEWLINE : 'u000d'? 'u000a' | 'u000d' ;
Zrozumiały kod (Java)

case CHAR:

                    {  alt5=1;                     }

                    break;

                case COMMA:

                    {   alt5=2;                     }

                    break;

                case NEWLINE:

                    {  alt5=4;                    }

                    break;
Wywołanie funkcji – jak w 
                ręcznych parserach
if alt2 == 1:

                 # csv.g:26:8: quoted_field

                    pass

                    self._state.following.append(self.FOLLOW_quoted_field_in_record57)

                    self.quoted_field()



                    self._state.following.pop()
Innowacja wg Kalama
Kto to jest Abdul Kalam?
Open Source
Prace nad językiem
Technologie satelitarne
Pytania?

Weitere ähnliche Inhalte

Empfohlen

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 

Empfohlen (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

Humanista w twoim linuksie