Skip to content

Accessing variables/functions from initializer in predicates doesn't work #5

Description

@tamagottschi

This is my initializer in the .pegcoffee file

{
  @knownNamespaces = []

  @isKnownNamespace = (ns) ->
    for x in namespaces
      if ns in x
        return true
    return false
}

When I try to use the definitions

Element
    = tagInfos:StartTag
        & {
            @knownNamespaces.push(tagInfos.namespaces)
            prefix = tagInfos.qid.prefix
            if (@isKnownNamespace(prefix) == false)
                error("unknown namespace prefix '" + prefix + "'")
            true
        }
        ElementContent*
        & {
            @knownNamespaces.pop()
        }
        qid:EndTag
        { if ( tagInfos.qid.full != qid.full ) then expected "that start and end tag must be identical" }

In the final action I can access, e.g. @knownNamespaces, but not in the predicates!?!

Any help?

thanks,

Jan

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions