Skip to content

Lots of missing keywords, can we automate the generation of the highlighter spec? #5

@nickanderson

Description

@nickanderson

Your highlighter is a great start, but there are quite a few missing keywords.

In 3.6 we added a syntax map dump to cf-promises

  --syntax-description, -s value - Output a document describing the available syntax elements of CFEngine. Possible values: 'none', 'json'. Default is 'none'.

I started playing around with parsing that. Perhaps we could use it to automatically generate a more complete syntax highlighter.

Here is my experiment so far.

#!/usr/bin/env python

import json
from pprint import pprint

seperator="|"
json_data = open('syntaxmap.json');
data = json.load(json_data)


attributes = []
for promiseType in data['promiseTypes']:
    print promiseType
    for attribute in data['promiseTypes'][promiseType]['attributes']:
        attributes.append(attribute)
attributes=list(set(attributes))
attributes.sort()



#print data["functions"]
functions = []
for function in data['functions']:
    functions.append(function)
functions.sort()

cfengine_keywords = attributes + functions
cfengine_keywords.sort()

for each in cfengine_keywords:
    print each

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions