当前位置:网站首页>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 { 边栏推荐
猜你喜欢
随机推荐
路由过滤器
LoadBalancer 负载均衡
Record NLP various resource URLs
Software testing interview questions and answer analysis, the strongest version in 2022
WPF引入 ttf 图标文件使用记录
Nacos实现高可用
MySQL之数据查询(分类汇总与排序)
小程序毕设作品之微信积分商城小程序毕业设计成品(1)开发概要
SQL 入门之第一讲——MySQL 8.0.29安装教程(windows 64位)
Nacos namespace
论坛管理系统
护网行动基本介绍
Process priority nice
小程序毕设作品之微信二手交易小程序毕业设计成品(3)后台功能
小程序毕设作品之微信二手交易小程序毕业设计成品(7)中期检查报告
小程序毕设作品之微信二手交易小程序毕业设计成品(5)任务书
阿里云EasyNLP中文文图生成模型带你秒变艺术家
NLP自然语言处理(一)
小程序毕设作品之微信积分商城小程序毕业设计成品(6)开题答辩PPT
EasyCVR启动时报错“no such file or directory”,该如何解决?









