zoukankan      html  css  js  c++  java
  • 找到一个非常好用的Css Parser,和大家分享

    是C#写的

    原文地址:http://www.codeproject.com/KB/recipes/CSSParser.aspx

    A Quick Note on the Downloads

    If you have previously seen this article, the v2 downloads contain a complete rewrite of the parser, which required a completely new model. The v1 downloads are provided for those who are dependant on the previous model (the v1 parser was last updated on 11/25/2008). If this is the first time you are seeing this article, use the v2 downloads that this article now describes.

    Introduction

    My motivation for this project came from an interest in importing color information. I needed to import from CSS files into an application I was working on for managing color sets of Web and other projects. However, on import I didn't just want the color, but the elements it is associated with as well. So, Regex was out. This left me with the need for a full CSS parser that could be used for lots of things, not just my nutty little color manager. So all I need is a grammar that describes the structure of the CSS 2.1 language. Unfortunately, the only grammar definition for CSS I could find was the W3C grammar written for Lex/Yacc. Due to my inexperience with Yacc, and my apathy towards learning it, I had to write a grammar from scratch. Ultimately, I chose to write a Coco/R attributed grammar. With version 2, the parser is now based on the 2.1 spec, with support for some 3.0 elements. Because it now handles "@" rules generically, most browser specific extensions should also now be supported. The object model was changed completely for the 2nd version of this parser. Hopefully this will cover most uses you may have for a CSS parser. If you have further requirements, it may be a good base to work from.

    Parsers

    I don't claim to be an expert in the fine arts of deterministic finite automaton. Having said that, the basic concept of parsing text, interpreting the contents and building some useful result from it can be understood without a deep understanding of the nitty gritty of how it is accomplished. When working with a parser generator like Coco, it's important to understand the basic concepts.

    作者: 火地晋
    出处: http://yelaiju.cnblogs.com
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    CLR via C#(04) 本是同根生
    CLR via C#(01).NET平台下代码是怎么跑起来的
    CLR via C#(02)基元类型、引用类型、值类型
    Mysql定期自动备份
    Extjs4 图片上传 预览
    inno setup打包应用程序
    bat批处理学习
    localhost/127.0.0.1/本机IP的区别以及端口号
    VirtualBox虚拟机上安装windows7系统
    Linux系统中Oracle11g数据库的安装与验证
  • 原文地址:https://www.cnblogs.com/yelaiju/p/1895206.html
Copyright © 2011-2022 走看看