Skip to content

Instantly share code, notes, and snippets.

@leegee
Last active April 6, 2016 07:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leegee/0fc1623f41beb999005a to your computer and use it in GitHub Desktop.
Save leegee/0fc1623f41beb999005a to your computer and use it in GitHub Desktop.
Start of a Sublime syntax file Gherkin
%YAML1.2
---
# See http://www.sublimetext.com/docs/3/syntax.html
file_extensions:
- feature
scope: source.feature
contexts:
main:
- match: '"'
scope: punctuation.definition.string.begin.feature
push: double_quoted_string
# Note that blackslashes don't need to be escaped within single quoted
# strings in YAML. When using single quoted strings, only single quotes
# need to be escaped: this is done by using two single quotes next to each
# other.
- match: ''''
scope: punctuation.definition.string.begin.feature
push: single_quoted_string
# Comments begin with a '#' and finish at the end of the line
- match: '#'
scope: punctuation.definition.comment.feature
push: line_comment
- match: '<[^>]+>'
scope: string.quoted.single.feature
- match: '^\s*\|.+$'
scope: entity.name.tag.section
- match: '^\s*@\S+$'
scope: entity.name.tag
- match: '^Feature:'
scope: keyword.control.feature
# push: feature_def
- match: '^\s*(Scenario|Scenario\s+Outline):'
scope: keyword.control.feature
- match: '^\s*(Examples|Background):'
scope: keyword.control.feature
- match: '^\s*(Given|Then|When|And|But)\s+'
scope: keyword.control.feature
# Numbers
- match: '\b(-)?[0-9.]+\b'
scope: constant.numeric.feature
# Brack balancing
- match: '<'
push: brackets
- match: '>'
scope: invalid.illegal.stray-bracket-end
single_quoted_string:
- meta_scope: string.quoted.single.feature
- match: ''''
scope: punctuation.definition.string.end.feature
pop: true
double_quoted_string:
- meta_scope: string.quoted.double.feature
- match: '"'
scope: punctuation.definition.string.end.feature
pop: true
line_comment:
- meta_scope: comment.line.feature
- match: $
pop: true
tag:
- meta_scope: entity.name.tag
- match: $
pop: true
# feature_def:
# - meta_scope: comment.block.documentation.feature
# meta_include_prototype: false
# match: '^\s*$'
# pop: true
# # ^\s*[\n\r\f]
brackets:
- match: '>'
pop: true
- include: main
@leegee
Copy link
Author

leegee commented Mar 9, 2016

A bit stumped on matching the termination of the Feature: block

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment