Skip to content

Commit

Permalink
Start to implementation of syntax matcher for requirements.
Browse files Browse the repository at this point in the history
So far, I'm just recording a few ideas about the implementation.
There's a long way to go.
  • Loading branch information
cdsmith committed Nov 26, 2018
1 parent 33c19de commit e7f1c8b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions codeworld-compiler/codeworld-compiler.cabal
Expand Up @@ -37,6 +37,7 @@ Library
CodeWorld.Compile.Requirements.Eval
CodeWorld.Compile.Requirements.Language
CodeWorld.Compile.Requirements.LegacyLanguage
CodeWorld.Compile.Requirements.Matcher
CodeWorld.Compile.Requirements.Types
CodeWorld.Compile.Stages

Expand Down
30 changes: 30 additions & 0 deletions codeworld-compiler/src/CodeWorld/Compile/Requirements/Matcher.hs
@@ -0,0 +1,30 @@
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ViewPatterns #-}

{-
Copyright 2018 The CodeWorld Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-}

module CodeWorld.Compile.Requirements.Matcher where

import Data.List
import Language.Haskell.Exts

pattern SpecialExp nm <- Var _ (UnQual _ (Ident _ (specialName -> Just nm)))
pattern SpecialPat nm <- PVar _ (Ident _ (specialName -> Just nm))

specialName :: String -> Maybe String
specialName s | "__" `isPrefixOf` s = Just s
| otherwise = Nothing

0 comments on commit e7f1c8b

Please sign in to comment.