/yourcss

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

Primary LanguageC++MIT LicenseMIT

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;
}