module Hydra.Ext.Scala.Language where

import Hydra.All

import qualified Data.Set as S


scalaLanguage :: Language m
scalaLanguage :: forall m. Language m
scalaLanguage = forall m. LanguageName -> LanguageConstraints m -> Language m
Language ([Char] -> LanguageName
LanguageName [Char]
"hydra/ext/scala") forall a b. (a -> b) -> a -> b
$ LanguageConstraints {
  languageConstraintsEliminationVariants :: Set EliminationVariant
languageConstraintsEliminationVariants = forall a. Ord a => [a] -> Set a
S.fromList [EliminationVariant]
eliminationVariants,
  languageConstraintsLiteralVariants :: Set LiteralVariant
languageConstraintsLiteralVariants = forall a. Ord a => [a] -> Set a
S.fromList [
    LiteralVariant
LiteralVariantBoolean,
    LiteralVariant
LiteralVariantFloat,
    LiteralVariant
LiteralVariantInteger,
    LiteralVariant
LiteralVariantString],
  languageConstraintsFloatTypes :: Set FloatType
languageConstraintsFloatTypes = forall a. Ord a => [a] -> Set a
S.fromList [
    -- Bigfloat is excluded for now
    FloatType
FloatTypeFloat32,
    FloatType
FloatTypeFloat64],
  languageConstraintsFunctionVariants :: Set FunctionVariant
languageConstraintsFunctionVariants = forall a. Ord a => [a] -> Set a
S.fromList [FunctionVariant]
functionVariants,
  languageConstraintsIntegerTypes :: Set IntegerType
languageConstraintsIntegerTypes = forall a. Ord a => [a] -> Set a
S.fromList [
    IntegerType
IntegerTypeBigint,
    IntegerType
IntegerTypeInt16,
    IntegerType
IntegerTypeInt32,
    IntegerType
IntegerTypeInt64,
    IntegerType
IntegerTypeUint8],
  languageConstraintsTermVariants :: Set TermVariant
languageConstraintsTermVariants = forall a. Ord a => [a] -> Set a
S.fromList [
    TermVariant
TermVariantApplication,
    TermVariant
TermVariantElement,
    TermVariant
TermVariantFunction,
    TermVariant
TermVariantList,
    TermVariant
TermVariantLiteral,
    TermVariant
TermVariantMap,
    TermVariant
TermVariantNominal,
    TermVariant
TermVariantOptional,
    TermVariant
TermVariantRecord,
    TermVariant
TermVariantSet,
    TermVariant
TermVariantUnion,
    TermVariant
TermVariantVariable],
  languageConstraintsTypeVariants :: Set TypeVariant
languageConstraintsTypeVariants = forall a. Ord a => [a] -> Set a
S.fromList [
    TypeVariant
TypeVariantAnnotated,
    TypeVariant
TypeVariantElement,
    TypeVariant
TypeVariantFunction,
    TypeVariant
TypeVariantList,
    TypeVariant
TypeVariantLiteral,
    TypeVariant
TypeVariantMap,
    TypeVariant
TypeVariantNominal,
    TypeVariant
TypeVariantOptional,
    TypeVariant
TypeVariantRecord,
    TypeVariant
TypeVariantSet,
    TypeVariant
TypeVariantUnion,
    TypeVariant
TypeVariantLambda,
    TypeVariant
TypeVariantVariable],
  languageConstraintsTypes :: Type m -> Bool
languageConstraintsTypes = forall a b. a -> b -> a
const Bool
True }

reservedWords :: S.Set [Char]
reservedWords :: Set [Char]
reservedWords = forall a. Ord a => [a] -> Set a
S.fromList forall a b. (a -> b) -> a -> b
$ [[Char]]
keywords forall a. [a] -> [a] -> [a]
++ [[Char]]
classNames
  where
    -- Classes in the Scala Standard Library 2.13.8
    -- Note: numbered class names like Function1, Product16, and the names of exception/error classes are omitted,
    --       as they are unlikely to occur by chance.
    classNames :: [[Char]]
classNames = [
      [Char]
"Any", [Char]
"AnyVal", [Char]
"App", [Char]
"Array", [Char]
"Boolean", [Char]
"Byte", [Char]
"Char", [Char]
"Console", [Char]
"DelayedInit", [Char]
"Double", [Char]
"DummyExplicit",
      [Char]
"Dynamic", [Char]
"Enumeration", [Char]
"Equals", [Char]
"Float", [Char]
"Function", [Char]
"Int", [Char]
"Long", [Char]
"MatchError", [Char]
"None",
      [Char]
"Nothing", [Char]
"Null", [Char]
"Option", [Char]
"PartialFunction", [Char]
"Predef", [Char]
"Product", [Char]
"Proxy",
      [Char]
"SerialVersionUID", [Char]
"Short", [Char]
"Singleton", [Char]
"Some", [Char]
"Specializable", [Char]
"StringContext",
      [Char]
"Symbol", [Char]
"Unit", [Char]
"ValueOf"]
    -- Not an official or comprehensive list; taken from https://www.geeksforgeeks.org/scala-keywords
    keywords :: [[Char]]
keywords = [
      [Char]
"abstract", [Char]
"case", [Char]
"catch", [Char]
"class", [Char]
"def", [Char]
"do", [Char]
"else", [Char]
"extends", [Char]
"false", [Char]
"final", [Char]
"finally", [Char]
"for",
      [Char]
"forSome", [Char]
"if", [Char]
"implicit", [Char]
"import", [Char]
"lazy", [Char]
"match", [Char]
"new", [Char]
"null", [Char]
"object", [Char]
"override", [Char]
"package", [Char]
"private",
      [Char]
"protected", [Char]
"return", [Char]
"sealed", [Char]
"super", [Char]
"this", [Char]
"throw", [Char]
"trait", [Char]
"true", [Char]
"try", [Char]
"type", [Char]
"val", [Char]
"var", [Char]
"while",
      [Char]
"with", [Char]
"yield"]