From a10f26d0217fcf696b44ee9328a529e8f9153d17 Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Tue, 8 Jan 2019 17:24:44 +0000 Subject: [PATCH 1/2] syntax: add reference syntax files for testing lexers --- etc/syntax/reference-files/suite.rc | 115 +++++++++++++++++++++ etc/syntax/reference-files/suite_empy.rc | 75 ++++++++++++++ etc/syntax/reference-files/suite_jinja2.rc | 70 +++++++++++++ 3 files changed, 260 insertions(+) create mode 100644 etc/syntax/reference-files/suite.rc create mode 100644 etc/syntax/reference-files/suite_empy.rc create mode 100644 etc/syntax/reference-files/suite_jinja2.rc diff --git a/etc/syntax/reference-files/suite.rc b/etc/syntax/reference-files/suite.rc new file mode 100644 index 00000000000..7a355e0aae7 --- /dev/null +++ b/etc/syntax/reference-files/suite.rc @@ -0,0 +1,115 @@ +# 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 be contain commas + [[[o]]] # sections can be deeply nested + +# SYNTAX: 1.2 +l=m # no comment + +# SYNTAX: 1.3 +# display should be consistant throught 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 + => foo + foo & => baz + + # SYNTAX: 2.5 + # @x should be highlighted + @wall_clock => foo + foo & @myxtrig1 => bar + + # SYNTAX: 2.6 + # text inside <> should be highlighted + foo => bar + => + + # SYNTAX: 2.7 + # text inside <> should be highlighted + # optionally +- could be highlighted + => + => + + # SYNTAX: 2.8 + # text inside <> should be highlighted + # optionally = could be highlighted + a => a + a => a + + # 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 + foo[P1D] => bar + foo[-P1D] => bar + foo[-P1Y1M1DT1H1M1S] => bar + foo[^] => bar + foo[123] => bar # optionally invalid offsets should display as an error +""" + +# graph strings should not highlight here, this should display as a setting: +foo => bar => baz => quz diff --git a/etc/syntax/reference-files/suite_empy.rc b/etc/syntax/reference-files/suite_empy.rc new file mode 100644 index 00000000000..ef3fa184cba --- /dev/null +++ b/etc/syntax/reference-files/suite_empy.rc @@ -0,0 +1,75 @@ +#!empy +# ^ SYNTAX:3.1 + +# SYNTAX numbering matches the table in https://github.com/cylc/cylc/issues/2752 + +# SYNTAX: 3.2 +# templating code should be displayed diffently 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.3 +# 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" +**'@'** # ??? +@[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 @ +""" diff --git a/etc/syntax/reference-files/suite_jinja2.rc b/etc/syntax/reference-files/suite_jinja2.rc new file mode 100644 index 00000000000..15e10584425 --- /dev/null +++ b/etc/syntax/reference-files/suite_jinja2.rc @@ -0,0 +1,70 @@ +#!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 diffently 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 templating code should be consistent with single-line code +{# + no comment +#} # all three lines should display as a single comment +{# a + b + c #} # all three lines should display as a single comment +{% + 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 %} +""" From b4ed8ed48a4f418081a2f180b4f39913d1bb4c0e Mon Sep 17 00:00:00 2001 From: Sadie Bartholomew <30274190+sadielbartholomew@users.noreply.github.com> Date: Wed, 16 Jan 2019 09:40:37 +0000 Subject: [PATCH 2/2] syntax: feedback --- etc/syntax/reference-files/suite.rc | 35 ++++++++++++++++++++-- etc/syntax/reference-files/suite_empy.rc | 12 ++++---- etc/syntax/reference-files/suite_jinja2.rc | 9 +++--- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/etc/syntax/reference-files/suite.rc b/etc/syntax/reference-files/suite.rc index 7a355e0aae7..39317213e6d 100644 --- a/etc/syntax/reference-files/suite.rc +++ b/etc/syntax/reference-files/suite.rc @@ -13,14 +13,14 @@ g = h=i # values can have equals e = "f" # and quotes e = "${HOME} `$HOME`" # and funny characters - [[l, m, n]] # sections can be contain commas + [[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 consistant throught multi-line string +# display should be consistent throughout multi-line string n = """foo""" n = """ foo @@ -104,11 +104,40 @@ graph = """ # 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 - foo[123] => bar # optionally invalid offsets should display as an error + # 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: diff --git a/etc/syntax/reference-files/suite_empy.rc b/etc/syntax/reference-files/suite_empy.rc index ef3fa184cba..f5e4ed26c81 100644 --- a/etc/syntax/reference-files/suite_empy.rc +++ b/etc/syntax/reference-files/suite_empy.rc @@ -3,8 +3,8 @@ # SYNTAX numbering matches the table in https://github.com/cylc/cylc/issues/2752 -# SYNTAX: 3.2 -# templating code should be displayed diffently to cylc code +# SYNTAX: 3.4 +# templating code should be displayed differently to cylc code @# no comment # should display as a comment @foo @{foo="bar"} @@ -19,7 +19,7 @@ @[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.3 +# SYNTAX 3.5 # non-exhaustive list of advanced empy syntax @# no comment @?NewContextName @@ -32,8 +32,8 @@ foo = @@ # the @@ should NOT be highlighted @os.environ @`x` @:2 + 2: -:%title "Cylc" -**'@'** # ??? +@%title "Cylc" +**'@'** # custom markup @[def f(x, y=z, **kwargs)] @[end def] @[try] @[except] @@ -44,7 +44,7 @@ a = @b @a = b a = @( b + 1 ) a = @( b_b | c.d('1', "2", 3) ) -[[@a}]] +[[@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 diff --git a/etc/syntax/reference-files/suite_jinja2.rc b/etc/syntax/reference-files/suite_jinja2.rc index 15e10584425..2bcfee3b08e 100644 --- a/etc/syntax/reference-files/suite_jinja2.rc +++ b/etc/syntax/reference-files/suite_jinja2.rc @@ -4,7 +4,7 @@ # SYNTAX numbering matches the table in https://github.com/cylc/cylc/issues/2752 # SYNTAX: 3.2 -# templating code should be displayed diffently to cylc code +# templating code should be displayed differently to cylc code {# no comment #} # should display as a comment {% set foo = "bar" %} {% set foo = '%s' % 'bar' %} @@ -19,13 +19,14 @@ {% from 'foo' import foo as a, b %} # SYNTAX 3.3 -# multi-line templating code should be consistent with single-line code +# 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 +#} # all three lines should display as a single comment with no gaps {# a b - c #} # all three lines should display as a single comment + c #} # all three lines should display as a single comment with no gaps {% set foo = {"1": 2, "3", []} %}