#include "sass.hpp"
#include "parser.hpp"
#include "file.hpp"
#include "inspect.hpp"
#include "constants.hpp"
#include "util.hpp"
#include "prelexer.hpp"
#include "color_maps.hpp"
#include "sass/functions.h"
#include "error_handling.hpp"
// Notes about delayed: some ast nodes can have delayed evaluation so
// they can preserve their original semantics if needed. This is most
// prominently exhibited by the division operation, since it is not
// only a valid operation, but also a valid css statement (i.e. for
// fonts, as in `16px/24px`). When parsing lists and expression we
// unwrap single items from lists and other operations. A nested list
// must not be delayed, only the items of the first level sometimes
// are delayed (as with argument lists). To achieve this we need to
// pass status to the list parser, so this can be set correctly.
// Another case with delayed values are colors. In compressed mode
// only processed values get compressed (other are left as written).
#include <cstdlib>
#include <iostream>
#include <vector>
#include <typeinfo>
namespace Sass {
using namespace Constants;
using namespace Prelexer;
Parser Parser::from_c_str(const char* beg, Context& ctx, Backtraces traces, ParserState pstate, const char* source)
{
pstate.offset.column = 0;
pstate.offset.line = 0;
Parser p(ctx, pstate, traces);
p.source = source ? source : beg;
p.position = beg ? beg : p.source;
p.end = p.position + strlen(p.position);
Block_Obj root = SASS_MEMORY_NEW(Block, pstate);
p.block_stack.push_back(root);
root->is_root(true);
return p;
}
Parser Parser::from_c_str(const char* beg, const char* end, Context& ctx, Backtraces traces, ParserState pstate, const char* source)
{
pstate.offset.column = 0;
pstate.offset.line = 0;
Parser p(ctx, pstate, traces);
p.source = source ? source : beg;
p.position = beg ? beg : p.source;
p.end = end ? end : p.position + strlen(p.position);
Block_Obj root = SASS_MEMORY_NEW(Block, pstate);
p.block_stack.push_back(root);
root->is_root(true);
return p;
}
void Parser::advanceToNextToken() {
lex < css_comments >(false);
// advance to position
pstate += pstate.offset;
pstate.offset.column = 0;
pstate.offset.line = 0;
}
Selector_List_Obj Parser::parse_selector(const char* beg, Context& ctx, Backtraces traces, ParserState pstate, const char* source)
{
Parser p = Parser::from_c_str(beg, ctx, traces, pstate, source);
// ToDo: ruby sass errors on parent references
// ToDo: remap the source-map entries somehow
return p.parse_selector_list(false);
}
bool Parser::peek_newline(const char* start)
{
return peek_linefeed(start ? start : position)
&& ! peek_css<exactly<'{'>>(start);
}
Parser Parser::from_token(Token t, Context& ctx, Backtraces traces, ParserState pstate, const char* source)
{
Parser p(ctx, pstate, traces);
p.source = source ? source : t.begin;
p.position = t.begin ? t.begin : p.source;
p.end = t.end ? t.end : p.position + strlen(p.position);
Block_Obj root = SASS_MEMORY_NEW(Block, pstate);
p.block_stack.push_back(root);
root->is_root(true);
return p;
}
/* main entry point to parse root block */
Block_Obj Parser::parse()
{
// consume unicode BOM
read_bom();
// scan the input to find invalid utf8 sequences
const char* it = utf8::find_invalid(position, end);
// report invalid utf8
if (it != end) {
pstate += Offset::init(position, it);
traces.push_back(Backtrace(pstate));
throw Exception::InvalidSass(pstate, traces, "Invalid UTF-8 sequence");
}
// create a block AST node to hold children
Block_Obj root = SASS_MEMORY_NEW(Block, pstate, 0, true);
// check seems a bit esoteric but works
if (ctx.resources.size() == 1) {
// apply headers only on very first include
ctx.apply_custom_headers(root, path, pstate);
}
// parse children nodes
block_stack.push_back(root);
parse_block_nodes(true);
block_stack.pop_back();
// update final position
root->update_pstate(pstate);
if (position != end) {
css_error("Invalid CSS", " after ", ": expected selector or at-rule, was ");
}
return root;
}
// convenience function for block parsing
// will create a new block ad-hoc for you
// this is the base block parsing function
Block_Obj Parser::parse_css_block(bool is_root)
{
// parse comments before block
// lex < optional_css_comments >();
// lex mandatory opener or error out
if (!lex_css < exactly<'{'> >()) {
css_error("Invalid CSS", " after ", ": expected \"{\", was ");
}
// create new block and push to the selector stack
Block_Obj block = SASS_MEMORY_NEW(Block, pstate, 0, is_root);
block_stack.push_back(block);
if (!parse_block_nodes(is_root)) css_error("Invalid CSS", " after ", ": expected \"}\", was ");
if (!lex_css < exactly<'}'> >()) {
css_error("Invalid CSS", " after ", ": expected \"}\", was ");
}
// update for end position
// this seems to be done somewhere else
// but that fixed selector schema issue
// block->update_pstate(pstate);
// parse comments after block
// lex < optional_css_comments >();
block_stack.pop_back();
return block;
}
// convenience function for block parsing
// will create a new block ad-hoc for you
// also updates the `in_at_root` flag
Block_Obj Parser::parse_block(bool is_root)
{
return parse_css_block(is_root);
}
// the main block parsing function
// parses stuff between `{` and `}`
bool Parser::parse_block_nodes(bool is_root)
{
// loop until end of string
while (position < end) {
// we should be able to refactor this
parse_block_comments();
lex < css_whitespace >();
if (lex < exactly<';'> >()) continue;
if (peek < end_of_file >()) return true;
if (peek < exactly<'}'> >()) return true;
if (parse_block_node(is_root)) continue;
parse_block_comments();
if (lex_css < exactly<';'> >()) continue;
if (peek_css < end_of_file >()) return true;
if (peek_css < exactly<'}'> >()) return true;
// illegal sass
return false;
}
// return success
return true;
}
// parser for a single node in a block
// semicolons must be lexed beforehand
bool Parser::parse_block_node(bool is_root) {
Block_Obj block = block_stack.back();
parse_block_comments();
// throw away white-space
// includes line comments
lex < css_whitespace >();
Lookahead lookahead_result;
// also parse block comments
// first parse everything that is allowed in functions
if (lex < variable >(true)) { block->append(parse_assignment()); }
else if (lex < kwd_err >(true)) { block->append(parse_error()); }
else if (lex < kwd_dbg >(true)) { block->append(parse_debug()); }
else if (lex < kwd_warn >(true)) { block->append(parse_warning()); }
else if (lex < kwd_if_directive >(true)) { block->append(parse_if_directive()); }
else if (lex < kwd_for_directive >(true)) { block->append(parse_for_directive()); }
else if (lex < kwd_each_directive >(true)) { block->append(parse_each_directive()); }
else if (lex < kwd_while_directive >(true)) { block->append(parse_while_directive()); }
else if (lex < kwd_return_directive >(true)) { block->append(parse_return_directive()); }
// parse imports to process later
else if (lex < kwd_import >(true)) {
Scope parent = stack.empty() ? Scope::Rules : stack.back();
if (parent != Scope::Function && parent != Scope::Root && parent != Scope::Rules && parent != Scope::Media) {
if (! peek_css< uri_prefix >(position)) { // this seems to go in ruby sass 3.4.20
error("Import directives may not be used within control directives or mixins.");
没有合适的资源?快使用搜索试试~ 我知道了~
h5模板,项目框架搭建
共33576个文件
js:19157个
gz:2603个
json:2366个
需积分: 5 0 下载量 158 浏览量
2023-05-26
10:54:42
上传
评论
收藏 108.55MB RAR 举报
温馨提示
h5模板,项目开始的模板
资源推荐
资源详情
资源评论
收起资源包目录
h5模板,项目框架搭建 (33576个子文件)
039e81c90b22ee25e9ec368eea896936b030494b8ac7feb9e863239af2c7ef0e3948cd46b81e88a189e7aaac2a41f11a71d8861e62c66aae6e2905b28088 794KB
sshpk-conv.1 4KB
he.1 3KB
jsesc.1 3KB
jsesc.1 3KB
jsesc.1 3KB
sshpk-sign.1 2KB
sshpk-verify.1 2KB
cssesc.1 2KB
cssesc.1 2KB
166b7281b9bc8094d07f9307ea4842cf81f33ab912980b9a9b4f6531c123 1KB
3dd6eca1d000fbe7f6b6c0b381ae11fdce0df206123f526f21700f474a97 1KB
5889ba069a78995ac3dcaff4bd8b2cc3dbe0001d8df407bde37b886f12f34946ef571c23cbcf93f81fde69a1803393e4e733639020e8e82333277ee1fc7f 811KB
91e4531b4559652b518d716912538a84c98f39deeaad08b0040d59cd4c95f8047844a4c1c29ff2502ab9a73c6cf4975569a332f986ac010f73e3210b661e 1.77MB
99699761446b95493b9279a69e3df05660fd44985e6eb040734f093bb52c05d0f8c8897c6d96f0cf3ab4b65ab8fd820dd844c9db585f5c1ed92aaa10112a 2.05MB
_editorconfig 160B
_editorconfig 121B
_gitignore 499B
a28936434931dd920830128b6797f430c17640dfe2084afb98bcbc6cbda8 1KB
configure.ac 4KB
acorn 2KB
acorn 2KB
acorn 2KB
acorn 316B
acorn 316B
acorn 316B
acorn 316B
acorn 316B
acorn 316B
acorn 316B
acorn 316B
acorn 316B
acorn 316B
acorn 316B
acorn 62B
acorn 62B
acorn 62B
acorn 62B
acorn 62B
acorn 59B
acorn 59B
acorn 59B
address 692B
helperProject.aep 96KB
license.after 4B
GNUmakefile.am 2KB
GNUmakefile.am 1KB
ansi-html 2KB
ansi-html 332B
LICENSE.APACHE2 586B
openChrome.applescript 2KB
atob 318B
AUTHORS 1KB
AUTHORS 1KB
AUTHORS 1KB
AUTHORS 876B
AUTHORS 851B
AUTHORS 851B
AUTHORS 402B
AUTHORS 217B
AUTHORS 203B
AUTHORS 169B
AUTHORS 152B
AUTHORS 152B
AUTHORS 139B
AUTHORS 106B
.auto-changelog 113B
autoprefixer 540B
autoprefixer 344B
.babelrc 407B
.babelrc 164B
.babelrc 137B
.babelrc 131B
.babelrc 57B
.babelrc 55B
.babelrc 30B
.babelrc 29B
.babelrc 24B
README.md.bak 7KB
gyp.bat 201B
samples.bat 196B
license.before 4B
benchmark 692B
range.bnf 629B
range.bnf 619B
range.bnf 619B
range.bnf 619B
range.bnf 619B
bootstrap 299B
.bowerrc 26B
branding 351B
browserslist 324B
LICENSE.BSD 1KB
LICENSE.BSD 1KB
LICENSE.BSD 1KB
LICENSE.BSD 1KB
LICENSE.BSD 1KB
cencode.c 2KB
c99func.c 2KB
calendar 998B
共 33576 条
- 1
- 2
- 3
- 4
- 5
- 6
- 336
资源评论
嫣嫣细语
- 粉丝: 97
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 封装swagger组件,提供全新UI以及无状态登录接口调用解决方案
- 小龙坎支局2024年4月渠道积分核对数据.xlam
- onlyoffice搭建及与alist使用的view.html
- Quadcopter-UAV-attitude-estimation-linux常用命令大全demo
- Quadcopter-UAV-attitude-estimation-based-on-数据库课程设计
- pbdlib-python-master.zip
- 43904245495352013_base.apk
- 基于springboot+vue + redis的工作流审批系统
- 【qt基础语法及实际案例解析】qt基础语法及实际案例解析
- 结课作业.psd
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功