Skip to content
This repository has been archived by the owner on May 3, 2020. It is now read-only.

Latest commit

 

History

History
51 lines (43 loc) · 1.2 KB

config.md

File metadata and controls

51 lines (43 loc) · 1.2 KB

Compiler Config

Option Description Example Available since
functions Inject native-function written in JS / TS to manipulate the result See custom functions 0.0.11
locationData Apply location properties to each object See location data 0.0.12

locationData

If set to true or a definition object it will assign two additional properties to each object which specify the start and end -position of the matched type.

const parse = compile(`
    entry [object:
        '(' 
        def foo = [object:
            def content = [(a - z)+]
        ]
        ')'
    ]
`, {
    locationData: true
});

console.log(parse('(abcdef)'));

The snipped above would log the following:

{
    "foo": { 
        "content": "abcdef", 
        "__starts": 1, 
        "__ends": 6 
    },
    "__starts": 0,
    "__ends": 7
}

It's also possible to use an object as value to customize the propertie-names:

const option = {
    locationData: {
        start: 'startsAt',
        end: 'endsAt'
    }
}