Skip to content

Commit

Permalink
Merge pull request #2916 from oliver-sanders/cylc-reference-syntax-files
Browse files Browse the repository at this point in the history
syntax: add reference syntax files for testing lexers
  • Loading branch information
kinow authored Feb 6, 2019
2 parents 268270e + b4ed8ed commit 3549c0f
Show file tree
Hide file tree
Showing 3 changed files with 290 additions and 0 deletions.
144 changes: 144 additions & 0 deletions etc/syntax/reference-files/suite.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# SYNTAX numbering matches the table in https://github.com/cylc/cylc/issues/2752

# SYNTAX: 1.

# SYNTAX: 1.1
# keys and values should display differently
# sections should be highlighted
[a]
b = c
[[d]]
-j = k # keys can have hyphens
j j = k # and spaces
g = h=i # values can have equals
e = "f" # and quotes
e = "${HOME} `$HOME`" # and funny characters
[[l, m, n]] # sections can contain commas
[[[o]]] # sections can be deeply nested

# SYNTAX: 1.2
l=m # no comment

# SYNTAX: 1.3
# display should be consistent throughout multi-line string
n = """foo"""
n = """
foo
bar
baz
"""

# SYNTAX: 1.4
# highlighting should be consistent with the following examples
%include bar
%include "bar/baz"
%include "baz/bo ol"


# SYNTAX: 2.
graph = """
# settings should not be highlighted here
a = b

# SYNTAX: 2.1
# tasks and dependency arrows should display differently
foo => bar
foo=>bar

# chaining should work in-line and across lines ending in `=>` or `|`
foo => bar => baz
foo => bar =>
pub => baz
foo => \
bar => \
pub

# SYNTAX: 2.2
# comment highlighting should be un-affected
foo => bar # pub
foo => bar # pub => baz

# SYNTAX: 2.3
# &|() should be highlighted
# !foo should be highlighted
# ! foo should NOT be highlighted
foo | bar & baz => pub & qux
(foo | bar) & baz => (pub & qux)
foo => !foo & bar
! foo => bar

# SYNTAX: 2.4
# text inside <> should be highlighted
# optionally suite / task could be highlighted
<other.suite::foo> => foo
foo & <other.suite::task_bar> => baz

# SYNTAX: 2.5
# @x should be highlighted
@wall_clock => foo
foo & @myxtrig1 => bar

# SYNTAX: 2.6
# text inside <> should be highlighted
foo<x> => bar<x>
<x> => <y>

# SYNTAX: 2.7
# text inside <> should be highlighted
# optionally +- could be highlighted
<x-1> => <x+1>
<x - 1> => <x + 1>

# SYNTAX: 2.8
# text inside <> should be highlighted
# optionally = could be highlighted
a<x=1> => a<x=2>
a<x = 1> => a<x = 2>

# SYNTAX: 2.9
# qualifier should be highlighted, whole and nothing but
foo:succeed => bar
pub & foo:fail => bar
FOO:succeed-all => bar
foo:custom_a => bar

# SYNTAX: 2.10
# inter-cycle dep should be highlighted
# integer intervals:
foo[P1] => bar
foo[-P1] => bar
# iso8601 intervals:
foo[P1D] => bar
foo[-P1D] => bar
foo[P1DT1M] => bar
foo[PT1M] => bar
foo[-P1Y1M1DT1H1M1S] => bar
foo[^] => bar
# integer points:
foo[123] => bar
foo[-123] => bar
# iso8601 points:
foo[20000000T0000] => bar
foo[2000-01-01T00:00] => bar
foo[2000-01-01T00] => bar
foo[2000-01-01] => bar
foo[2000-00] => bar
foo[2000] => bar
# arithmetic:
foo[^+P1D]
foo[^+P1]
foo[20000101T0000+P1D]
foo[2+P1]
# optionally invalid syntax can be marked as erroneous:
foo[2000T00] => bar # corrupted date
foo[2000-01-01T0000] => bar # mixed long and short syntax (-:)
foo[20000101T00:00] => bar # mixed long and short syntax (-:)
foo[P1D1Y] => bar # missing T separator
foo[P1H] => bar # missing T separator
foo[PT1M1H] => bar # incorrect component ordering
foo[01T00] => bar # truncated date
foo[T00] => bar # truncated date
"""

# graph strings should not highlight here, this should display as a setting:
foo => bar => baz => quz
75 changes: 75 additions & 0 deletions etc/syntax/reference-files/suite_empy.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!empy
# ^ SYNTAX:3.1

# SYNTAX numbering matches the table in https://github.com/cylc/cylc/issues/2752

# SYNTAX: 3.4
# templating code should be displayed differently to cylc code
@# no comment # should display as a comment
@foo
@{foo="bar"}
@{ foo = "bar" }
@{ foo = "bar"; bar = "baz" }
@{ foo = '%s' % 'bar' }
@{ set foo = {"1": 2, "3", []} } # highlight to the last }
@{ set foo = foo.bar(1, 2, 3) } # highlight to the last }
@{ foo_bar }
@{foo_bar}
@{ foo.bar(1, 2, 3, []) } # highlight to the last }
@[if x]a = b@[end if] # highlight all but "a = b"
@[if x.y[]]a = b@[end if] # highlight all but "a = b"
a = b
# SYNTAX 3.5
# non-exhaustive list of advanced empy syntax
@# no comment
@?NewContextName
@!100
invisible@ whitespace # the @ character should be highlighted
foo = @\0 bar @\xHH # @\0 and @\xHH should both be highlighted
foo = @@ # the @@ should NOT be highlighted
@"foo" # this should be highlighted the same as @foo?
@( x ? "true" ! "false )
@os.environ
@`x`
@:2 + 2:
@%title "Cylc"
**'@<CONTENTS>'** # custom markup
@[def f(x, y=z, **kwargs)] @[end def]
@[try] @[except]

# SYNTAX 3./1.1
# keys, values and sections outside of the templating code should display
# as normal
a = @b
@a = b
a = @( b + 1 )
a = @( b_b | c.d('1', "2", 3) )
[[@a]]
d = e # check highlighting of this line un-affected by section
[[@( a_a | c.d('1', "2", 3) )]]
d = e # check highlighting of this line un-affected by section
[[@( "%(foo)s" % {"foo": "abc"} )]]
d = e # check highlighting of this line un-affected by section

# SYNTAX 3./1.2
# comments outside of the templating code should display as normal
@( foo ) # foo
@{ foo } # foo
@[ foo ] # foo

# syntax 3./1.3
# tasks and deps outside of the templating code should display as normal
graph = """
foo => @( b_az.pub('1', "2", 3) ) => qux =>
@[ if BAR ]
bar => pub
@[ else ]
baz => pub
@[ endif ]
"""

# syntax 3./2.5
# clashing xtrigger and empy syntax should somehow be handled
graph = """
@wall_clock => @@bar => baz # note empy evaluates @@ as @
"""
71 changes: 71 additions & 0 deletions etc/syntax/reference-files/suite_jinja2.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!Jinja2
# ^ SYNTAX:3.1

# SYNTAX numbering matches the table in https://github.com/cylc/cylc/issues/2752

# SYNTAX: 3.2
# templating code should be displayed differently to cylc code
{# no comment #} # should display as a comment
{% set foo = "bar" %}
{% set foo = '%s' % 'bar' %}
{% set foo = {"1": 2, "3", []} %}
{% set foo = foo.bar(1, 2, 3) %}
{{ foo_bar }}
{{ foo.bar(1, 2, 3) }}
{{ foo | bar(1, 2, 3) }}
{% include 'foo' %}
{% include ['foo', 'bar'] %}
{% import 'foo' as foo %}
{% from 'foo' import foo as a, b %}

# SYNTAX 3.3
# multi-line template code should appear the same as single-line template code
# if it were distributed over multiple lines
{#
no comment
#} # all three lines should display as a single comment with no gaps
{# a
b
c #} # all three lines should display as a single comment with no gaps
{%
set foo = {"1": 2, "3", []}
%}
{% set foo = {
"1": 2,
"3", []} %}



# SYNTAX 3./1.1
# keys, values and sections outside of the templating code should display
# as normal
a = {{ b }}
{{ a }} = b
a = {{ b + 1 }}
a = {{ b_b | c.d('1', "2", 3) }}
[[{{ a }}]]
d = e # check highlighting of this line un-affected by section
[[{{ a_a | c.d('1', "2", 3) }}]]
d = e # check highlighting of this line un-affected by section
[[a{{ b }}c]]
d = e # check highlighting of this line un-affected by section
[[{{ "%(foo)s" % {"foo": "abc"}}}]]
d = e # check highlighting of this line un-affected by section

# SYNTAX 3./1.2
# comments outside of the templating code should display as normal
{# foo #} # foo
{% foo %} # foo
{{ foo }} # foo

# SYNTAX 3./1.3
# tasks and deps outside of the templating code should display as normal
graph = """
foo => {{ bar }} => qux
foo => {{ b_ar | baz.pub('1', "2", 3) }} => qux =>
{% if BAR %}
bar => pub
{% else %}
baz => pub
{% endif %}
"""

0 comments on commit 3549c0f

Please sign in to comment.