#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.");
没有合适的资源?快使用搜索试试~ 我知道了~
微信小程序点餐系统(前端+后端+数据库)
共24495个文件
js:14856个
json:2722个
md:1961个
需积分: 5 0 下载量 115 浏览量
2023-04-27
15:37:50
上传
评论
收藏 64.07MB ZIP 举报
温馨提示
完整的点餐系统项目,前端+后端+数据库
资源推荐
资源详情
资源评论
收起资源包目录
微信小程序点餐系统(前端+后端+数据库) (24495个子文件)
sshpk-conv.1 4KB
he.1 3KB
jsesc.1 3KB
jsesc.1 3KB
sshpk-sign.1 2KB
sshpk-verify.1 2KB
cssesc.1 2KB
package-lock.json.1909017369 0B
configure.ac 4KB
acorn 2KB
acorn 316B
acorn 316B
acorn 59B
address 673B
GNUmakefile.am 2KB
GNUmakefile.am 1KB
ansi-html 2KB
ansi-html 332B
atob 318B
AUTHORS 5KB
AUTHORS 4KB
AUTHORS 1KB
AUTHORS 876B
AUTHORS 514B
AUTHORS 217B
AUTHORS 203B
AUTHORS 169B
AUTHORS 169B
AUTHORS 159B
AUTHORS 152B
AUTHORS 152B
AUTHORS 152B
AUTHORS 146B
autoprefixer-info 354B
autoprefixer-info 75B
.babelrc 230B
.babelrc 186B
.babelrc 81B
.babelrc 31B
.babelrc 30B
.babelrc 29B
.babelrc 28B
babylon 330B
README.md.bak 7KB
base64_utf8 8KB
gyp.bat 196B
benchmark 692B
range.bnf 619B
range.bnf 619B
range.bnf 619B
range.bnf 619B
bootstrap 299B
branding 351B
browserslist 324B
browserslist 324B
browserslist 324B
browserslist 324B
LICENSE.BSD 1KB
LICENSE.BSD 1KB
LICENSE.BSD 1KB
LICENSE.BSD 1KB
LICENSE.BSD 1KB
cencode.c 2KB
c99func.c 2KB
Cakefile 1KB
CakeFile 1KB
Cakefile 1KB
CakeFile 1KB
Cakefile 537B
calendar 945B
card 2KB
win_delay_load_hook.cc 872B
large-pdb-shim.cc 653B
node.cert 1KB
haproxy.cfg 1KB
Changelog 7KB
ChangeLog 7KB
CHANGELOG 2KB
CHANGELOG 896B
CHANGELOG 465B
changelog 120B
CHANGES 27KB
CHANGES 2KB
CHANGES 2KB
CHANGES 1KB
CHANGES 1KB
CHANGES 1KB
CHANGES 901B
CHANGES 851B
CHANGES 440B
ci-build-libsass 4KB
ci-build-plugin 2KB
ci-install-compiler 96B
ci-install-deps 412B
ci-report-coverage 1KB
index.cjs 41KB
mvnw.cmd 6KB
mvnw.cmd 6KB
webpack-dev-server.cmd 287B
webpack-bundle-analyzer.cmd 286B
共 24495 条
- 1
- 2
- 3
- 4
- 5
- 6
- 245
资源评论
BeMartian
- 粉丝: 0
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 不坑盒子Word v2024.1218免费Office插件.mp4
- gec6818 交叉编译openssl
- 菜鸟裹裹周五抽5或6折寄件券.mp4
- 基于Android Studio开发的音乐播放器APP源码+报告(高分Android音乐播放器项目)
- 产后速效瘦身(13集)瑜伽健身各种训练课.mp4
- 茶百道每天抽大杯奶茶免单券.mp4
- 车来了v4.59.0高级版 精准实时公交地铁神器.mp4
- 待办事项记录app 让你的生活更有效率.mp4
- 单品主播进阶课付费培训46节完整+话术本.mp4
- 得物订单截图模拟器 本应用仅供娱乐.mp4
- 滴滴打车集卡片兑换库迪咖啡.mp4
- 电池大师Battery Guru v2.3.13 for解锁付费版.mp4
- 电脑蹭网防护神器一键断网.mp4
- 电脑组装、维护、维修 全能一本通.mp4
- 电脑维修技术大全,有台式也有笔记本的教程.mp4
- 电信口令綐0.88~100亓话费6个口令.mp4
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功