当前位置:网站首页>spicy (two) unit hooks
spicy (two) unit hooks
2022-07-30 03:43:00 【a tobey】
unit hooks, the hook.Used to control parsing, track status and retrieve results.is the block of code that triggers execution during parsing and has access to the current unit instance.
Hooks are similar to functions: they are bodies that execute when triggered. These bodies can receive a set of input parameters, but unlike functions, a hook can have multiple bodies.If multiple body implementations are provided for the same hook, they will be executed in sequence.
The 7 most commonly used hooks:
# Start execution before unit parsingon %init() { ... }# Execute after unit parsing is completeon %done { ... }# Executed when a parsing error is encountered, just before the parser aborts processingon %error { ... }# Executed after cell parsing is done in any way.This hook is most useful for modifying global state that needs to be updated, regardless of whether the parsing process was successful or not.This hook is also guaranteed to execute eventually once %init fires.It will run after %done or %error respectively.(If a new error occurs during the execution of %finally, the unit's %error hook will not be triggered.)on %finally { ... }#on %print { ... }# Executed immediately after parsing the given unit field.The parsed value can be accessed via $$, possibly with any relevant type conversions applied (see Dynamic type conversions using &convert).The same content has also been assigned to this field.on { ... } (field hook)# Assuming the specified field is a container (eg, a vector), this is executed each time a new container element is parsed, and just before it is added to the container.The parsed element can be accessed via the $$ identifier and can be modified before being stored.Hook implementations can also use the stop statement to abort container resolution without adding the current element.on foreach {
边栏推荐
猜你喜欢
论坛管理系统
【Node访问MongoDB数据库】
小程序毕设作品之微信二手交易小程序毕业设计成品(6)开题答辩PPT
The most important transport layer
Starlight does not ask passers-by!The young lady on the Wuhan campus successfully switched to software testing in three months and received a salary of 9k+13!
Gateway routing gateway
Nacos实现高可用
小程序毕设作品之微信积分商城小程序毕业设计成品(3)后台功能
小程序毕设作品之微信二手交易小程序毕业设计成品(2)小程序功能
MyCat中对分库分表、ER表、全局表、分片规则、全局序列等的实现与基本使用操作
随机推荐
[Flink] How to determine the cluster planning size from development to production launch?
AI智能安防视频平台EasyCVR如何配置音视频同时传输?
【SQL】按某个关联列用一张表的数据更新另一张表
route filter
vscode 调试和远程
Basic introduction to protect the network operations
写给技术人的管理入门知识1:什么是管理
MySQ deadlock
OpenFeign实现降级
阿里云EasyNLP中文文图生成模型带你秒变艺术家
智能答题功能,CRMEB知识付费系统必须有!
小程序毕设作品之微信积分商城小程序毕业设计成品(8)毕业设计论文模板
一直空、一直爽,继续抄顶告捷!
【Use of scientific research tools】A
C# 一周入门之《C#-类和对象》Day Six
发给你的好友,让 TA 请你吃炸鸡!
CMake的安装和测试
Testers, what else do you need to know besides testing?
小程序毕设作品之微信积分商城小程序毕业设计成品(1)开发概要
Hystrix service circuit breaker