- 授权协议: MIT
- 开发语言: PHP
- 操作系统: 跨平台
- 软件首页: https://github.com/Microsoft/tolerant-php-parser
- 软件文档: https://github.com/Microsoft/tolerant-php-parser
软件介绍
这是一个早期的 PHP 解析器,相当于实现了 PHP 对 PHP 脚本的解析。
示例代码:
<?php
// Autoload required classes
require "vendor/autoload.php";
// Instantiate new parser instance
$parser = new PhpParser\Parser();
// Return and print an AST from string contents
$astNode = $parser->parseSourceFile('<?php /* comment */ echo "hi!"');
var_dump($astNode);
// Gets and prints errors from AST Node. The parser handles errors gracefully,
// so it can be used in IDE usage scenarios (where code is often incomplete).
$errors = PhpParser\Utilities::getDiagnostics($astNode);
var_dump(iterator_to_array($errors));
// Traverse all Node descendants of $astNode
foreach ($astNode->getDescendantNodes() as $descendant) {
if ($descendant instanceof \PhpParser\Node\StringLiteral) {
// Print the Node text (without whitespace or comments)
var_dump($descendant->getText());
// All Nodes link back to their parents, so it's easy to navigate the tree.
$grandParent = $descendant->getParent()->getParent();
var_dump($grandParent->getNodeKindName());
// The AST is fully-representative, and round-trippable to the original source.
// This enables consumers to build reliable formatting and refactoring tools.
var_dump($grandParent->getLeadingCommentAndWhitespaceText());
}
// In addition to retrieving all children or descendants of a Node,
// Nodes expose properties specific to the Node type.
if ($descendant instanceof \PhpParser\Node\Expression\EchoExpression) {
$echoKeywordStartPosition = $descendant->echoKeyword->getStartPosition();
// To cut down on memory consumption, positions are represented as a single integer
// index into the document, but their line and character positions are easily retrieved.
$lineCharacterPosition = \PhpParser\Utilities::getLineCharacterPositionFromPosition(
$echoKeywordStartPosition
);
echo "line: $lineCharacterPosition->line, character: $lineCharacterPosition->character";
}
}
新媒体文案创作与传播
秋叶、叶小鱼、勾俊伟 / 人民邮电出版社 / 2017-4 / 39.80元
《新媒体文案创作与传播》共分三篇。第1篇是新媒体文案基础篇,主要讲述了新媒体文案的基本概念、新媒体文案的岗位要求和职业能力素养;第二篇是新媒体文案创意实务篇,主要讲述了新媒体文案的创作思路、新媒体文案的写作技巧、爆款新媒体文案的打造、新媒体销售文案的写作、新媒体对文案传播的新要求、新媒体品-牌文案的写作,以及不同媒介的特征及发布形式;第三篇为新媒体文案相关技能补充,主要讲述的是策划能力。 《新媒体......一起来看看 《新媒体文案创作与传播》 这本书的介绍吧!
