Skip to content

CSS lexer as described in CSS Syntax Module Level 3 - Tokenization

License

Notifications You must be signed in to change notification settings

hooddanielc/yourcss

Repository files navigation

yourcss lexer

Build Status

A hand rolled lexer implemented as described in CSS Syntax Module Level 3 Tokenization.

Building

Dependencies

  • clang - c++ compiler
  • ib - c++ build tool
git submodule init
git submodule update

# run all tests
ib --test_all test

# build a single test
ib test/selector-test.cc

# run
../out/debug/test/selector-test

Example

#include <yourcss/lexer.h>

using namespace yourcss;

int main(int, char*[]) {
  const char *src = R"(
    .cool {
      something: 123;
      asdf: url(http://danielhood.com);
    }
  )";

  auto tokens = lexer_t(src).lex();
  for (const auto &token: tokens) {
    std::cout << "type: " << token->get_name() << std::endl;
    std::cout << "text: '" << token->get_text() << "'" << std::endl;
    std::cout << "---------------------------" << std::endl;
  }

  return 0;
}

About

CSS lexer as described in CSS Syntax Module Level 3 - Tokenization

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published