|
| 1 | +-- This module is a copy-paste of the `empyDef` from `Text.Parsec.Language` module, with the |
| 2 | +-- following changes: |
| 3 | +-- 1. Made `commentLine` a `Parser` instead of a `String`. |
| 4 | +-- This way, we can accept arbitrary parsers for line comments, which is useful for our use case, as |
| 5 | +-- just adding `//` as a line comment would make the parser ignore documentation comments `///`. |
| 6 | +-- Original at |
| 7 | +-- https://hackage.haskell.org/package/parsec-3.1.14.0/docs/src/Text.Parsec.Language.html#emptyDef |
| 8 | +-- ------------------------------------------------------------------------------------------------- |
| 9 | + |
| 10 | +-- | |
| 11 | +-- Module : Text.Parsec.Language |
| 12 | +-- Copyright : (c) Daan Leijen 1999-2001, (c) Paolo Martini 2007 |
| 13 | +-- License : BSD-style (see the LICENSE file) |
| 14 | +-- |
| 15 | +-- Maintainer : derek.a.elkins@gmail.com |
| 16 | +-- Stability : provisional |
| 17 | +-- Portability : non-portable (uses non-portable module Text.Parsec.Token) |
| 18 | +-- |
| 19 | +-- A helper module that defines some language definitions that can be used |
| 20 | +-- to instantiate a token parser (see "Text.Parsec.Token"). |
| 21 | +module Wasp.Psl.Parser.Common.Language |
| 22 | + ( emptyDef, |
| 23 | + ) |
| 24 | +where |
| 25 | + |
| 26 | +import Control.Monad (void) |
| 27 | +import Text.Parsec |
| 28 | +import Wasp.Psl.Parser.Common.Token |
| 29 | + |
| 30 | +----------------------------------------------------------- |
| 31 | +-- minimal language definition |
| 32 | +-------------------------------------------------------- |
| 33 | + |
| 34 | +-- | This is the most minimal token definition. It is recommended to use |
| 35 | +-- this definition as the basis for other definitions. @emptyDef@ has |
| 36 | +-- no reserved names or operators, is case sensitive and doesn't accept |
| 37 | +-- comments, identifiers or operators. |
| 38 | +emptyDef :: LanguageDef st |
| 39 | +emptyDef = |
| 40 | + LanguageDef |
| 41 | + { commentLine = void $ string "//", |
| 42 | + nestedComments = True, |
| 43 | + identStart = letter <|> char '_', |
| 44 | + identLetter = alphaNum <|> oneOf "_'", |
| 45 | + opStart = opLetter emptyDef, |
| 46 | + opLetter = oneOf ":!#$%&*+./<=>?@\\^|-~", |
| 47 | + reservedOpNames = [], |
| 48 | + reservedNames = [], |
| 49 | + caseSensitive = True |
| 50 | + } |
0 commit comments