#
# linter.py
# Linter for SublimeLinter3, a code checking framework for Sublime Text 3
#
# Written by Andrew Grim
# Copyright (c) 2014 Andrew Grim
#
# License: MIT
#

"""This module exports the Puppet plugin class."""

from SublimeLinter.lint import Linter, util


class Puppet(Linter):

    """Provides an interface to puppet."""

    syntax = 'puppet'
    cmd = ('puppet', 'parser', 'validate', '--color=false')
    regex = r'^Error:.+?(?P<message>Syntax error at \'(?P<near>.+?)\'; expected \'.+\').+?line (?P<line>\d+)'
    error_stream = util.STREAM_STDERR

#
# linter.py
# Linter for SublimeLinter3, a code checking framework for Sublime Text 3
#
# Written by Andrew Grim
# Copyright (c) 2014 Andrew Grim
#
# License: MIT
#

"""This module exports the Puppet plugin class."""

from SublimeLinter.lint import Linter, util


class Puppet(Linter):

    """Provides an interface to puppet."""

    syntax = 'puppet'
    cmd = ('puppet', 'parser', 'validate', '--color=false')
    regex = r'^Error:.+?(?P<message>Syntax error at \'?(?P<near>.+?)\'?(?:; expected \'.+\')?) at line (?P<line>\d+)'
    error_stream = util.STREAM_STDERR

Support Additional Error Output Formats
Support Additional Error Output Formats

Make the 'near' match group more flexible to support multiple error
output styles for some syntax errors.

Examples:

    Error: Could not parse for environment production: Syntax error at 'class' at line 27
    Error: Could not parse for environment production: Syntax error at end of file at line 32
    Error: Could not parse for environment production: Syntax error at ','; expected '}' at line 28

See https://regex101.com/r/aT3aR3/3 for testing
