26 lines
780 B
Haskell
26 lines
780 B
Haskell
module PrimaryExpression (PrimaryExpression(..) ) where
|
|
|
|
import qualified Data.List as List
|
|
|
|
import ClassLiteral (ClassLiteral)
|
|
import JavaLanguage (m_identifier)
|
|
import LiteralExpression (LiteralExpression)
|
|
|
|
import Text.Parsec (manyTill, char, string')
|
|
import Text.Parsec.String (Parser)
|
|
|
|
data PrimaryExpression = Literal LiteralExpression
|
|
| ClassLiteral ClassLiteral
|
|
| This
|
|
| TypedThis String
|
|
| InstanceCreation
|
|
deriving Show
|
|
|
|
parseThis :: Parser PrimaryExpression
|
|
parseThis = string' "this" *> return This
|
|
|
|
parseTypedThis :: Parser PrimaryExpression
|
|
parseTypedThis = do
|
|
start <- m_identifier
|
|
paths <- manyTill (char '.' *> m_identifier) (string' ".this")
|
|
return . TypedThis . List.intercalate "." $ (start:paths)
|