Skip to content

Commit

Permalink
adicionando comentarios
Browse files Browse the repository at this point in the history
  • Loading branch information
ItaloCobains committed Nov 28, 2023
1 parent 9dba813 commit f2f682e
Show file tree
Hide file tree
Showing 31 changed files with 1,799 additions and 241 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 changes: 8 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ title: ItaloCobainsBlog
email: [email protected]
description: >- # this means to ignore newlines until "baseurl:"
Bem-vindo ao nosso blog, um espaço dedicado à exploração do fascinante mundo da programação, tecnologia, hacking ético e ciência da computação. Mergulhe conosco em uma jornada repleta de insights e novidades, enquanto compartilhamos nosso conhecimento e paixão por esses campos em constante evolução.
baseurl: "" # the subpath of your site, e.g. /blog
url: "" # the base hostname & protocol for your site, e.g. http://example.com
# Comentários do Disqus
disqus:
shortname: ItaloCobainsBlog
# Deixe o nome abreviado em branco para desativar os comentários em todo o site.
# Desative comentários para qualquer postagem adicionando `comments: false` ao YAML Front Matter dessa postagem.

url: "http://ItaloCobainsBlog.com" # the base hostname & protocol for your site, e.g. http://example.com
twitter_username: JustItalow
github_username: ItaloCobains

Expand All @@ -27,6 +32,7 @@ markdown: kramdown
theme: minima
plugins:
- jekyll-feed
- jekyll-seo-tag

# Exclude from processing.
# The following items will not be processed, by default. Create a custom list
Expand Down
18 changes: 18 additions & 0 deletions _includes/disqus_comments.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% if page.comments != false and jekyll.environment == "production" %}

<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
this.page.url = '{{ page.url | absolute_url }}';
this.page.identifier = '{{ page.url | absolute_url }}';
};
(function () {
var d = document, s = d.createElement('script');
s.src = 'https://{{ site.disqus.shortname }}.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments
powered by Disqus.</a></noscript>
{% endif %}
3 changes: 3 additions & 0 deletions _posts/2023-11-28-Nada-é-real.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
---
layout: post
comments: true
title: "nothing's real"
date: 2023-11-28 09:30:00 -0300
categories: world mind
---

# Nada é real ?

![Imagem](/assets/nothing_is_real.jpg)

Isso é um sobra dos meus pensamentos referente a o mundo em que vivemos hoje em dia, aparentemente nada é real, seus ganhos,
seus bens, sua casa nova, suas conquistas nada disso é real, tudo que vc tem é apenas um parcela de felicidade. O que eu vou falar parece estranho
mas isso é so um fruto do meu pensamento "Bens são sentimentos". Não estou generalizando obvio porem grande parte de nos humanos
Expand Down
107 changes: 107 additions & 0 deletions _site/2023/11/23/O-que-é-um-lex.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<h1 id="o-que-é-um-lex-ou-avaliador-lexico-">O que é um <code class="language-plaintext highlighter-rouge">lex</code> ou <code class="language-plaintext highlighter-rouge">avaliador lexico</code> ?</h1>

<p><code class="language-plaintext highlighter-rouge">Lexical analyzer</code> ou <code class="language-plaintext highlighter-rouge">lex</code> ou <code class="language-plaintext highlighter-rouge">avaliador léxico</code> é um processo fundamental na arquitetura de qualquer interpretador ou compilador. Ele é responsável por analisar o <code class="language-plaintext highlighter-rouge">codigo fonte</code> ou <code class="language-plaintext highlighter-rouge">entrada de texto</code> iterando sobre cada caractere é gerando <code class="language-plaintext highlighter-rouge">tokens</code> ou <code class="language-plaintext highlighter-rouge">simbolos</code> que vão ser importante para os próximos passos de um compilador/interpretador.</p>

<h2 id="como-escrever-um-lex-">Como escrever um lex ?</h2>

<p>Exemplo: LexEstupido.js</p>
<div class="language-js highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">class</span> <span class="nx">Token</span> <span class="p">{</span>
<span class="kd">constructor</span><span class="p">(</span><span class="nx">type</span><span class="p">,</span> <span class="nx">value</span><span class="p">)</span> <span class="p">{</span>
<span class="k">this</span><span class="p">.</span><span class="nx">type</span> <span class="o">=</span> <span class="nx">type</span><span class="p">;</span>
<span class="k">this</span><span class="p">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">value</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>

<span class="kd">class</span> <span class="nx">Lexer</span> <span class="p">{</span>
<span class="kd">constructor</span><span class="p">(</span><span class="nx">code</span><span class="p">)</span> <span class="p">{</span>
<span class="k">this</span><span class="p">.</span><span class="nx">code</span> <span class="o">=</span> <span class="nx">code</span><span class="p">;</span>
<span class="k">this</span><span class="p">.</span><span class="nx">position</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>

<span class="nx">isWhitespace</span><span class="p">(</span><span class="nx">char</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="sr">/</span><span class="se">\s</span><span class="sr">/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">char</span><span class="p">);</span>
<span class="p">}</span>

<span class="nx">isDigit</span><span class="p">(</span><span class="nx">char</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="sr">/</span><span class="se">\d</span><span class="sr">/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">char</span><span class="p">);</span>
<span class="p">}</span>

<span class="nx">isAlpha</span><span class="p">(</span><span class="nx">char</span><span class="p">)</span> <span class="p">{</span>
<span class="k">return</span> <span class="sr">/</span><span class="se">[</span><span class="sr">a-zA-Z_</span><span class="se">]</span><span class="sr">/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">char</span><span class="p">);</span>
<span class="p">}</span>

<span class="nx">getNextToken</span><span class="p">()</span> <span class="p">{</span>
<span class="k">while</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">position</span> <span class="o">&lt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">code</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">const</span> <span class="nx">char</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">code</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">position</span><span class="p">];</span>

<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">isWhitespace</span><span class="p">(</span><span class="nx">char</span><span class="p">))</span> <span class="p">{</span>
<span class="k">this</span><span class="p">.</span><span class="nx">position</span><span class="o">++</span><span class="p">;</span>
<span class="k">continue</span><span class="p">;</span>
<span class="p">}</span>

<span class="k">switch</span> <span class="p">(</span><span class="kc">true</span><span class="p">)</span> <span class="p">{</span>
<span class="k">case</span> <span class="k">this</span><span class="p">.</span><span class="nx">isDigit</span><span class="p">(</span><span class="nx">char</span><span class="p">):</span>
<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">parseNumber</span><span class="p">();</span>
<span class="k">case</span> <span class="k">this</span><span class="p">.</span><span class="nx">isAlpha</span><span class="p">(</span><span class="nx">char</span><span class="p">):</span>
<span class="k">return</span> <span class="k">this</span><span class="p">.</span><span class="nx">parseIdentifier</span><span class="p">();</span>
<span class="k">case</span> <span class="sr">/</span><span class="se">[\+\-\*\/\(\)]</span><span class="sr">/</span><span class="p">.</span><span class="nx">test</span><span class="p">(</span><span class="nx">char</span><span class="p">):</span>
<span class="k">this</span><span class="p">.</span><span class="nx">position</span><span class="o">++</span><span class="p">;</span>
<span class="k">return</span> <span class="k">new</span> <span class="nx">Token</span><span class="p">(</span><span class="nx">char</span><span class="p">,</span> <span class="nx">char</span><span class="p">);</span>
<span class="k">case</span> <span class="nx">char</span> <span class="o">===</span> <span class="dl">'</span><span class="s1">=</span><span class="dl">'</span><span class="p">:</span>
<span class="k">this</span><span class="p">.</span><span class="nx">position</span><span class="o">++</span><span class="p">;</span>
<span class="k">return</span> <span class="k">new</span> <span class="nx">Token</span><span class="p">(</span><span class="dl">'</span><span class="s1">EQUALS</span><span class="dl">'</span><span class="p">,</span> <span class="dl">'</span><span class="s1">=</span><span class="dl">'</span><span class="p">);</span>
<span class="nl">default</span><span class="p">:</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">error</span><span class="p">(</span><span class="s2">`Erro léxico: Caractere inesperado '</span><span class="p">${</span><span class="nx">char</span><span class="p">}</span><span class="s2">' na posição </span><span class="p">${</span><span class="k">this</span><span class="p">.</span><span class="nx">position</span><span class="p">}</span><span class="s2">`</span><span class="p">);</span>
<span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>

<span class="c1">// Fim do código</span>
<span class="k">return</span> <span class="kc">null</span><span class="p">;</span>
<span class="p">}</span>

<span class="nx">parseNumber</span><span class="p">()</span> <span class="p">{</span>
<span class="kd">let</span> <span class="nx">value</span> <span class="o">=</span> <span class="dl">''</span><span class="p">;</span>

<span class="k">while</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">position</span> <span class="o">&lt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">code</span><span class="p">.</span><span class="nx">length</span> <span class="o">&amp;&amp;</span> <span class="k">this</span><span class="p">.</span><span class="nx">isDigit</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">code</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">position</span><span class="p">]))</span> <span class="p">{</span>
<span class="nx">value</span> <span class="o">+=</span> <span class="k">this</span><span class="p">.</span><span class="nx">code</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">position</span><span class="p">];</span>
<span class="k">this</span><span class="p">.</span><span class="nx">position</span><span class="o">++</span><span class="p">;</span>
<span class="p">}</span>

<span class="k">return</span> <span class="k">new</span> <span class="nx">Token</span><span class="p">(</span><span class="dl">'</span><span class="s1">NUMBER</span><span class="dl">'</span><span class="p">,</span> <span class="nb">parseInt</span><span class="p">(</span><span class="nx">value</span><span class="p">,</span> <span class="mi">10</span><span class="p">));</span>
<span class="p">}</span>

<span class="nx">parseIdentifier</span><span class="p">()</span> <span class="p">{</span>
<span class="kd">let</span> <span class="nx">value</span> <span class="o">=</span> <span class="dl">''</span><span class="p">;</span>

<span class="k">while</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">position</span> <span class="o">&lt;</span> <span class="k">this</span><span class="p">.</span><span class="nx">code</span><span class="p">.</span><span class="nx">length</span> <span class="o">&amp;&amp;</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">isAlpha</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">code</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">position</span><span class="p">])</span> <span class="o">||</span> <span class="k">this</span><span class="p">.</span><span class="nx">isDigit</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">code</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">position</span><span class="p">])))</span> <span class="p">{</span>
<span class="nx">value</span> <span class="o">+=</span> <span class="k">this</span><span class="p">.</span><span class="nx">code</span><span class="p">[</span><span class="k">this</span><span class="p">.</span><span class="nx">position</span><span class="p">];</span>
<span class="k">this</span><span class="p">.</span><span class="nx">position</span><span class="o">++</span><span class="p">;</span>
<span class="p">}</span>

<span class="k">return</span> <span class="k">new</span> <span class="nx">Token</span><span class="p">(</span><span class="dl">'</span><span class="s1">ID</span><span class="dl">'</span><span class="p">,</span> <span class="nx">value</span><span class="p">);</span>
<span class="p">}</span>

<span class="nx">tokenize</span><span class="p">()</span> <span class="p">{</span>
<span class="kd">const</span> <span class="nx">tokens</span> <span class="o">=</span> <span class="p">[];</span>

<span class="kd">let</span> <span class="nx">token</span><span class="p">;</span>
<span class="k">while</span> <span class="p">((</span><span class="nx">token</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">getNextToken</span><span class="p">())</span> <span class="o">!==</span> <span class="kc">null</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">tokens</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">token</span><span class="p">);</span>
<span class="p">}</span>

<span class="k">return</span> <span class="nx">tokens</span><span class="p">;</span>
<span class="p">}</span>
<span class="p">}</span>

<span class="c1">// Exemplo de uso</span>
<span class="kd">const</span> <span class="nx">codigoFonte</span> <span class="o">=</span> <span class="dl">"</span><span class="s2">x = 10 + 20 * (30 - 5)</span><span class="dl">"</span><span class="p">;</span>
<span class="kd">const</span> <span class="nx">lexer</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Lexer</span><span class="p">(</span><span class="nx">codigoFonte</span><span class="p">);</span>
<span class="kd">const</span> <span class="nx">tokensResultantes</span> <span class="o">=</span> <span class="nx">lexer</span><span class="p">.</span><span class="nx">tokenize</span><span class="p">();</span>
<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">tokensResultantes</span><span class="p">);</span>

</code></pre></div></div>

<p>Primeiramente, criamos um ‘Token’, uma estrutura que armazena a identidade de cada caractere. É importante observar que um ‘Token’ pode conter mais atributos do que os exemplificados aqui; meu exemplo é simplificado.</p>

<p>Em seguida, começamos com a classe que recebe o código no construtor. Posteriormente, o método ‘tokenize’ é implementado como o principal da classe, responsável por percorrer o código fonte. O método ‘getNextToken’ é encarregado de identificar o caractere atual e atribuí-lo a um ‘Token’. Os demais métodos servem apenas como validadores de strings. Ao final, o vetor de ‘Tokens’ é retornado.”</p>
8 changes: 4 additions & 4 deletions _site/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
<meta property="og:locale" content="en_US" />
<meta name="description" content="Bem-vindo ao nosso blog, um espaço dedicado à exploração do fascinante mundo da programação, tecnologia, hacking ético e ciência da computação. Mergulhe conosco em uma jornada repleta de insights e novidades, enquanto compartilhamos nosso conhecimento e paixão por esses campos em constante evolução." />
<meta property="og:description" content="Bem-vindo ao nosso blog, um espaço dedicado à exploração do fascinante mundo da programação, tecnologia, hacking ético e ciência da computação. Mergulhe conosco em uma jornada repleta de insights e novidades, enquanto compartilhamos nosso conhecimento e paixão por esses campos em constante evolução." />
<link rel="canonical" href="http://localhost:4000/404.html" />
<meta property="og:url" content="http://localhost:4000/404.html" />
<link rel="canonical" href="http://italocobainsblog.com/404.html" />
<meta property="og:url" content="http://italocobainsblog.com/404.html" />
<meta property="og:site_name" content="ItaloCobainsBlog" />
<meta property="og:type" content="website" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="ItaloCobainsBlog" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"WebPage","description":"Bem-vindo ao nosso blog, um espaço dedicado à exploração do fascinante mundo da programação, tecnologia, hacking ético e ciência da computação. Mergulhe conosco em uma jornada repleta de insights e novidades, enquanto compartilhamos nosso conhecimento e paixão por esses campos em constante evolução.","headline":"ItaloCobainsBlog","url":"http://localhost:4000/404.html"}</script>
{"@context":"https://schema.org","@type":"WebPage","description":"Bem-vindo ao nosso blog, um espaço dedicado à exploração do fascinante mundo da programação, tecnologia, hacking ético e ciência da computação. Mergulhe conosco em uma jornada repleta de insights e novidades, enquanto compartilhamos nosso conhecimento e paixão por esses campos em constante evolução.","headline":"ItaloCobainsBlog","url":"http://italocobainsblog.com/404.html"}</script>
<!-- End Jekyll SEO tag -->
<link rel="stylesheet" href="/assets/main.css"><link type="application/atom+xml" rel="alternate" href="http://localhost:4000/feed.xml" title="ItaloCobainsBlog" /></head>
<link rel="stylesheet" href="/assets/main.css"><link type="application/atom+xml" rel="alternate" href="http://italocobainsblog.com/feed.xml" title="ItaloCobainsBlog" /></head>
<body><header class="site-header" role="banner">

<div class="wrapper"><a class="site-title" rel="author" href="/">ItaloCobainsBlog</a><nav class="site-nav">
Expand Down
Loading

0 comments on commit f2f682e

Please sign in to comment.