Coder Social home page Coder Social logo

html-basic-parser's Introduction

HTML Basic parser

The idea of this little project is to simply create a lexer and an HTML parser and eventually lead to the creation of a template engine able to make transformations on the fly.

This allows me to learn, gradually, how the tools around me work.

Lexer

For now, the operation of the Lexer is rather simple: it simply splits the input string into tokens :

  • OpenDoubleBrace : Represents the characters {{
  • CloseDoubleBrace: Represents the characters }}
  • StrIdentifier: Represents a string Hello
  • OpenAngleBracket: Represents the characters <
  • CloseAngleBracket: Represents the characters >

Parser

I'm still working on this part. The goal is to convert the tokens into an AST tree.

Template engine

I want to focus on very simple things for now :

  • Control structures
    • @if() / @endif()
    • @foreach() / @endforeach()
  • Variables
    • @var() / {{ var }}

Usage could be something like this :

<html lang='en'>
  <head>
    <title>@var(title)</title>
  </head>
  
  <body>
    @if(isAuthenticated)
      <h1>You are authenticated !</h1>
    
    @foreach(friend of friends)
      <p>{{ friend.name }}</p>
    @endforeach
    
    @endif
  </body>
</html>

html-basic-parser's People

Contributors

sirmishaa avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.