dignifiedquire / dignifiedquire/pegjs-coffee-plugin

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

Open
#5 3 comments 0 reactions 0 assignees View on GitHub
investigate
Dominant language
JavaScript
Stars
34
Forks
6
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.