【问题标题】:.sublime-syntax multiple line function detection.sublime-syntax 多行功能检测
【发布时间】:2017-03-14 06:20:22
【问题描述】:

我正在写.sublime-syntax for the Specman language,需要有关多行方法声明的帮助。

使用关键字is 声明方法,该关键字位于方法声明的大部分其他部分之后。

例如

fwd_init() @driver.clock is {

add(x : uint, y : uint) is also {

private do_stuff(field : my_type) is only {

等等……

我的问题是声明的部分可能会很长,以防向方法传递大量参数,因此我倾向于将行拆分为多行。

我无法匹配该方法的语法,因为我需要多行匹配。

以下是我目前拥有的,但它不起作用:

methods:
- match: (?=^\s*(?:private|static|final)?\s+[a-zA-Z](?:[a-zA-Z0-9_]+)?\s*\()
  set:
    - match: (?=\bis\b)
      push: method-declaration

基本上我想返回前瞻,可能匹配函数,以防它不是函数弹出它。

【问题讨论】:

    标签: regex sublimetext3 syntax-highlighting regex-lookarounds specman


    【解决方案1】:

    当我写下我意识到的问题时,我需要做的就是将method-declaration 推入堆栈,首先对is 进行负前瞻。

    如下:

    methods:
      - match: (?=^\s*(?:private|static|final)?\s+[a-zA-Z](?:[a-zA-Z0-9_]+)?\s*\()
        push: method-declaration
    
    method-declaration:
      - match: (?!is(?:\s+)(only|first|also)?)
        pop: true
      - ... parsing of the method declaration
    

    希望这可以帮助其他寻找有关该主题的信息的人。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-03
      • 2014-02-10
      • 1970-01-01
      • 1970-01-01
      • 2012-12-06
      相关资源
      最近更新 更多