License | GPL-2 |
---|---|
Maintainer | yi-devel@googlegroups.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Extensions |
|
Parser for the JavaScript language as described at Dogan 2009.
The mode using this parser can be found at Yi.Mode.JavaScript.
Synopsis
- class Strokable a where
- class Failable f where
- type BList a = [a]
- type Tree t = BList (Statement t)
- type Semicolon t = Maybe t
- data Statement t
- = FunDecl t t (Parameters t) (Block t)
- | VarDecl t (BList (VarDecAss t)) (Semicolon t)
- | Return t (Maybe (Expr t)) (Semicolon t)
- | While t (ParExpr t) (Block t)
- | DoWhile t (Block t) t (ParExpr t) (Semicolon t)
- | For t t (Expr t) (ForContent t) t (Block t)
- | If t (ParExpr t) (Block t) (Maybe (Statement t))
- | Else t (Block t)
- | With t (ParExpr t) (Block t)
- | Comm t
- | Expr (Expr t) (Semicolon t)
- data Parameters t
- = Parameters t (BList t) t
- | ParErr t
- data ParExpr t
- = ParExpr t (BList (Expr t)) t
- | ParExprErr t
- data ForContent t
- data Block t
- data VarDecAss t
- data Expr t
- = ExprObj t (BList (KeyValue t)) t
- | ExprPrefix t (Expr t)
- | ExprNew t (Expr t)
- | ExprSimple t (Maybe (Expr t))
- | ExprParen t (Expr t) t (Maybe (Expr t))
- | ExprAnonFun t (Parameters t) (Block t)
- | ExprTypeOf t (Expr t)
- | ExprFunCall t (ParExpr t) (Maybe (Expr t))
- | OpExpr t (Expr t)
- | ExprCond t (Expr t) t (Expr t)
- | ExprArr t (Maybe (Array t)) t (Maybe (Expr t))
- | PostExpr t
- | ExprErr t
- data Array t
- data KeyValue t
- = KeyValue t t (Expr t)
- | KeyValueErr t
- normal :: TT -> Endo [Stroke]
- error :: TT -> Endo [Stroke]
- one :: (t -> a) -> t -> Endo [a]
- modStroke :: StyleName -> Stroke -> Stroke
- nError :: [TT] -> [TT] -> Endo [Stroke]
- failStroker :: [TT] -> TT -> Endo [Stroke]
- tokenToStroke :: TT -> Stroke
- getStrokes :: Tree TT -> Point -> Point -> Point -> [Stroke]
- parse :: P TT (Tree TT)
- statement :: P TT (Statement TT)
- block :: P TT (Block TT)
- stmtExpr :: P TT (Expr TT)
- opExpr :: P TT (Expr TT)
- expression :: P TT (Expr TT)
- array :: P TT (Expr TT)
- semicolon :: P TT (Maybe TT)
- parameters :: P TT (Parameters TT)
- parExpr :: P TT (ParExpr TT)
- comment :: P TT TT
- preOp :: P TT TT
- inOp :: P TT TT
- postOp :: P TT TT
- opTok :: P TT TT
- simpleTok :: P TT TT
- strTok :: P TT TT
- numTok :: P TT TT
- name :: P TT TT
- boolean :: P TT TT
- res :: Reserved -> P TT TT
- spc :: Char -> P TT TT
- oper :: Operator -> P TT TT
- plzTok :: P TT TT -> P TT TT
- plzSpc :: Char -> P TT TT
- plzExpr :: P TT (Expr TT)
- plz :: Failable f => P TT (f TT) -> P TT (f TT)
- anything :: P s TT
- hate :: Int -> P s a -> P s a
- fromBlock :: Block t -> [Statement t]
- firstTok :: Foldable f => f t -> t
- errorToken :: TT
- isError :: TT -> Bool
- toTT :: t -> Tok t
- fromTT :: Tok t -> t
Data types, classes and instances
class Strokable a where Source #
Instances of Strokable
are datatypes which can be syntax highlighted.
Instances
Strokable (Tok Token) Source # | |
Strokable (KeyValue TT) Source # | |
Strokable (Array TT) Source # | |
Strokable (Expr TT) Source # | |
Strokable (VarDecAss TT) Source # | |
Strokable (Block TT) Source # | |
Strokable (ForContent TT) Source # | |
Defined in Yi.Syntax.JavaScript | |
Strokable (ParExpr TT) Source # | |
Strokable (Parameters TT) Source # | |
Defined in Yi.Syntax.JavaScript | |
Strokable (Statement TT) Source # | TODO: This code is *screaming* for some generic programming. TODO: Somehow fix Failable and failStroker to be more "generic". This will make these instances much nicer and we won't have to make ad-hoc stuff like this. |
class Failable f where Source #
Instances of Failable
can represent failure. This is a useful class for
future work, since then we can make stroking much easier.
Instances
Failable KeyValue Source # | |
Failable Expr Source # | |
Failable VarDecAss Source # | |
Failable Block Source # | |
Failable ForContent Source # | |
Defined in Yi.Syntax.JavaScript stupid :: t -> ForContent t Source # hasFailed :: ForContent t -> Bool Source # | |
Failable ParExpr Source # | |
Failable Parameters Source # | |
Defined in Yi.Syntax.JavaScript stupid :: t -> Parameters t Source # hasFailed :: Parameters t -> Bool Source # |
FunDecl t t (Parameters t) (Block t) | |
VarDecl t (BList (VarDecAss t)) (Semicolon t) | |
Return t (Maybe (Expr t)) (Semicolon t) | |
While t (ParExpr t) (Block t) | |
DoWhile t (Block t) t (ParExpr t) (Semicolon t) | |
For t t (Expr t) (ForContent t) t (Block t) | |
If t (ParExpr t) (Block t) (Maybe (Statement t)) | |
Else t (Block t) | |
With t (ParExpr t) (Block t) | |
Comm t | |
Expr (Expr t) (Semicolon t) |
Instances
Foldable Statement Source # | |
Defined in Yi.Syntax.JavaScript fold :: Monoid m => Statement m -> m # foldMap :: Monoid m => (a -> m) -> Statement a -> m # foldMap' :: Monoid m => (a -> m) -> Statement a -> m # foldr :: (a -> b -> b) -> b -> Statement a -> b # foldr' :: (a -> b -> b) -> b -> Statement a -> b # foldl :: (b -> a -> b) -> b -> Statement a -> b # foldl' :: (b -> a -> b) -> b -> Statement a -> b # foldr1 :: (a -> a -> a) -> Statement a -> a # foldl1 :: (a -> a -> a) -> Statement a -> a # toList :: Statement a -> [a] # length :: Statement a -> Int # elem :: Eq a => a -> Statement a -> Bool # maximum :: Ord a => Statement a -> a # minimum :: Ord a => Statement a -> a # | |
IsTree Statement Source # | |
Data t => Data (Statement t) Source # | |
Defined in Yi.Syntax.JavaScript gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Statement t -> c (Statement t) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Statement t) # toConstr :: Statement t -> Constr # dataTypeOf :: Statement t -> DataType # dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (Statement t)) # dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (Statement t)) # gmapT :: (forall b. Data b => b -> b) -> Statement t -> Statement t # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Statement t -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Statement t -> r # gmapQ :: (forall d. Data d => d -> u) -> Statement t -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Statement t -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Statement t -> m (Statement t) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Statement t -> m (Statement t) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Statement t -> m (Statement t) # | |
Show t => Show (Statement t) Source # | |
Strokable (Statement TT) Source # | TODO: This code is *screaming* for some generic programming. TODO: Somehow fix Failable and failStroker to be more "generic". This will make these instances much nicer and we won't have to make ad-hoc stuff like this. |
data Parameters t Source #
Parameters t (BList t) t | |
ParErr t |
Instances
Foldable Parameters Source # | |
Defined in Yi.Syntax.JavaScript fold :: Monoid m => Parameters m -> m # foldMap :: Monoid m => (a -> m) -> Parameters a -> m # foldMap' :: Monoid m => (a -> m) -> Parameters a -> m # foldr :: (a -> b -> b) -> b -> Parameters a -> b # foldr' :: (a -> b -> b) -> b -> Parameters a -> b # foldl :: (b -> a -> b) -> b -> Parameters a -> b # foldl' :: (b -> a -> b) -> b -> Parameters a -> b # foldr1 :: (a -> a -> a) -> Parameters a -> a # foldl1 :: (a -> a -> a) -> Parameters a -> a # toList :: Parameters a -> [a] # null :: Parameters a -> Bool # length :: Parameters a -> Int # elem :: Eq a => a -> Parameters a -> Bool # maximum :: Ord a => Parameters a -> a # minimum :: Ord a => Parameters a -> a # sum :: Num a => Parameters a -> a # product :: Num a => Parameters a -> a # | |
Failable Parameters Source # | |
Defined in Yi.Syntax.JavaScript stupid :: t -> Parameters t Source # hasFailed :: Parameters t -> Bool Source # | |
Data t => Data (Parameters t) Source # | |
Defined in Yi.Syntax.JavaScript gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Parameters t -> c (Parameters t) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Parameters t) # toConstr :: Parameters t -> Constr # dataTypeOf :: Parameters t -> DataType # dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (Parameters t)) # dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (Parameters t)) # gmapT :: (forall b. Data b => b -> b) -> Parameters t -> Parameters t # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Parameters t -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Parameters t -> r # gmapQ :: (forall d. Data d => d -> u) -> Parameters t -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Parameters t -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Parameters t -> m (Parameters t) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Parameters t -> m (Parameters t) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Parameters t -> m (Parameters t) # | |
Show t => Show (Parameters t) Source # | |
Defined in Yi.Syntax.JavaScript showsPrec :: Int -> Parameters t -> ShowS # show :: Parameters t -> String # showList :: [Parameters t] -> ShowS # | |
Strokable (Parameters TT) Source # | |
Defined in Yi.Syntax.JavaScript |
ParExpr t (BList (Expr t)) t | |
ParExprErr t |
Instances
Foldable ParExpr Source # | |
Defined in Yi.Syntax.JavaScript fold :: Monoid m => ParExpr m -> m # foldMap :: Monoid m => (a -> m) -> ParExpr a -> m # foldMap' :: Monoid m => (a -> m) -> ParExpr a -> m # foldr :: (a -> b -> b) -> b -> ParExpr a -> b # foldr' :: (a -> b -> b) -> b -> ParExpr a -> b # foldl :: (b -> a -> b) -> b -> ParExpr a -> b # foldl' :: (b -> a -> b) -> b -> ParExpr a -> b # foldr1 :: (a -> a -> a) -> ParExpr a -> a # foldl1 :: (a -> a -> a) -> ParExpr a -> a # elem :: Eq a => a -> ParExpr a -> Bool # maximum :: Ord a => ParExpr a -> a # minimum :: Ord a => ParExpr a -> a # | |
Failable ParExpr Source # | |
Data t => Data (ParExpr t) Source # | |
Defined in Yi.Syntax.JavaScript gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ParExpr t -> c (ParExpr t) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ParExpr t) # toConstr :: ParExpr t -> Constr # dataTypeOf :: ParExpr t -> DataType # dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (ParExpr t)) # dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (ParExpr t)) # gmapT :: (forall b. Data b => b -> b) -> ParExpr t -> ParExpr t # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ParExpr t -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ParExpr t -> r # gmapQ :: (forall d. Data d => d -> u) -> ParExpr t -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ParExpr t -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ParExpr t -> m (ParExpr t) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ParExpr t -> m (ParExpr t) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ParExpr t -> m (ParExpr t) # | |
Show t => Show (ParExpr t) Source # | |
Strokable (ParExpr TT) Source # | |
data ForContent t Source #
Instances
Foldable ForContent Source # | |
Defined in Yi.Syntax.JavaScript fold :: Monoid m => ForContent m -> m # foldMap :: Monoid m => (a -> m) -> ForContent a -> m # foldMap' :: Monoid m => (a -> m) -> ForContent a -> m # foldr :: (a -> b -> b) -> b -> ForContent a -> b # foldr' :: (a -> b -> b) -> b -> ForContent a -> b # foldl :: (b -> a -> b) -> b -> ForContent a -> b # foldl' :: (b -> a -> b) -> b -> ForContent a -> b # foldr1 :: (a -> a -> a) -> ForContent a -> a # foldl1 :: (a -> a -> a) -> ForContent a -> a # toList :: ForContent a -> [a] # null :: ForContent a -> Bool # length :: ForContent a -> Int # elem :: Eq a => a -> ForContent a -> Bool # maximum :: Ord a => ForContent a -> a # minimum :: Ord a => ForContent a -> a # sum :: Num a => ForContent a -> a # product :: Num a => ForContent a -> a # | |
Failable ForContent Source # | |
Defined in Yi.Syntax.JavaScript stupid :: t -> ForContent t Source # hasFailed :: ForContent t -> Bool Source # | |
Data t => Data (ForContent t) Source # | |
Defined in Yi.Syntax.JavaScript gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ForContent t -> c (ForContent t) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ForContent t) # toConstr :: ForContent t -> Constr # dataTypeOf :: ForContent t -> DataType # dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (ForContent t)) # dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (ForContent t)) # gmapT :: (forall b. Data b => b -> b) -> ForContent t -> ForContent t # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ForContent t -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ForContent t -> r # gmapQ :: (forall d. Data d => d -> u) -> ForContent t -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ForContent t -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ForContent t -> m (ForContent t) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ForContent t -> m (ForContent t) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ForContent t -> m (ForContent t) # | |
Show t => Show (ForContent t) Source # | |
Defined in Yi.Syntax.JavaScript showsPrec :: Int -> ForContent t -> ShowS # show :: ForContent t -> String # showList :: [ForContent t] -> ShowS # | |
Strokable (ForContent TT) Source # | |
Defined in Yi.Syntax.JavaScript |
Instances
Foldable Block Source # | |
Defined in Yi.Syntax.JavaScript fold :: Monoid m => Block m -> m # foldMap :: Monoid m => (a -> m) -> Block a -> m # foldMap' :: Monoid m => (a -> m) -> Block a -> m # foldr :: (a -> b -> b) -> b -> Block a -> b # foldr' :: (a -> b -> b) -> b -> Block a -> b # foldl :: (b -> a -> b) -> b -> Block a -> b # foldl' :: (b -> a -> b) -> b -> Block a -> b # foldr1 :: (a -> a -> a) -> Block a -> a # foldl1 :: (a -> a -> a) -> Block a -> a # elem :: Eq a => a -> Block a -> Bool # maximum :: Ord a => Block a -> a # minimum :: Ord a => Block a -> a # | |
Failable Block Source # | |
Data t => Data (Block t) Source # | |
Defined in Yi.Syntax.JavaScript gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Block t -> c (Block t) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Block t) # toConstr :: Block t -> Constr # dataTypeOf :: Block t -> DataType # dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (Block t)) # dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (Block t)) # gmapT :: (forall b. Data b => b -> b) -> Block t -> Block t # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Block t -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Block t -> r # gmapQ :: (forall d. Data d => d -> u) -> Block t -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Block t -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Block t -> m (Block t) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Block t -> m (Block t) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Block t -> m (Block t) # | |
Show t => Show (Block t) Source # | |
Strokable (Block TT) Source # | |
Represents either a variable name or a variable name assigned to an
expression. AssBeg
is a variable name maybe followed by an assignment.
AssRst
is an equals sign and an expression. (AssBeg
means x
(Just (AssRst
'=' '5')))x = 5
.
Instances
Foldable VarDecAss Source # | |
Defined in Yi.Syntax.JavaScript fold :: Monoid m => VarDecAss m -> m # foldMap :: Monoid m => (a -> m) -> VarDecAss a -> m # foldMap' :: Monoid m => (a -> m) -> VarDecAss a -> m # foldr :: (a -> b -> b) -> b -> VarDecAss a -> b # foldr' :: (a -> b -> b) -> b -> VarDecAss a -> b # foldl :: (b -> a -> b) -> b -> VarDecAss a -> b # foldl' :: (b -> a -> b) -> b -> VarDecAss a -> b # foldr1 :: (a -> a -> a) -> VarDecAss a -> a # foldl1 :: (a -> a -> a) -> VarDecAss a -> a # toList :: VarDecAss a -> [a] # length :: VarDecAss a -> Int # elem :: Eq a => a -> VarDecAss a -> Bool # maximum :: Ord a => VarDecAss a -> a # minimum :: Ord a => VarDecAss a -> a # | |
Failable VarDecAss Source # | |
Data t => Data (VarDecAss t) Source # | |
Defined in Yi.Syntax.JavaScript gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> VarDecAss t -> c (VarDecAss t) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (VarDecAss t) # toConstr :: VarDecAss t -> Constr # dataTypeOf :: VarDecAss t -> DataType # dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (VarDecAss t)) # dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (VarDecAss t)) # gmapT :: (forall b. Data b => b -> b) -> VarDecAss t -> VarDecAss t # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> VarDecAss t -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> VarDecAss t -> r # gmapQ :: (forall d. Data d => d -> u) -> VarDecAss t -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> VarDecAss t -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> VarDecAss t -> m (VarDecAss t) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> VarDecAss t -> m (VarDecAss t) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> VarDecAss t -> m (VarDecAss t) # | |
Show t => Show (VarDecAss t) Source # | |
Strokable (VarDecAss TT) Source # | |
ExprObj t (BList (KeyValue t)) t | |
ExprPrefix t (Expr t) | |
ExprNew t (Expr t) | |
ExprSimple t (Maybe (Expr t)) | |
ExprParen t (Expr t) t (Maybe (Expr t)) | |
ExprAnonFun t (Parameters t) (Block t) | |
ExprTypeOf t (Expr t) | |
ExprFunCall t (ParExpr t) (Maybe (Expr t)) | |
OpExpr t (Expr t) | |
ExprCond t (Expr t) t (Expr t) | |
ExprArr t (Maybe (Array t)) t (Maybe (Expr t)) | |
PostExpr t | |
ExprErr t |
Instances
Foldable Expr Source # | |
Defined in Yi.Syntax.JavaScript fold :: Monoid m => Expr m -> m # foldMap :: Monoid m => (a -> m) -> Expr a -> m # foldMap' :: Monoid m => (a -> m) -> Expr a -> m # foldr :: (a -> b -> b) -> b -> Expr a -> b # foldr' :: (a -> b -> b) -> b -> Expr a -> b # foldl :: (b -> a -> b) -> b -> Expr a -> b # foldl' :: (b -> a -> b) -> b -> Expr a -> b # foldr1 :: (a -> a -> a) -> Expr a -> a # foldl1 :: (a -> a -> a) -> Expr a -> a # elem :: Eq a => a -> Expr a -> Bool # maximum :: Ord a => Expr a -> a # | |
Failable Expr Source # | |
Data t => Data (Expr t) Source # | |
Defined in Yi.Syntax.JavaScript gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Expr t -> c (Expr t) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Expr t) # toConstr :: Expr t -> Constr # dataTypeOf :: Expr t -> DataType # dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (Expr t)) # dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (Expr t)) # gmapT :: (forall b. Data b => b -> b) -> Expr t -> Expr t # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Expr t -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Expr t -> r # gmapQ :: (forall d. Data d => d -> u) -> Expr t -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Expr t -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Expr t -> m (Expr t) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Expr t -> m (Expr t) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Expr t -> m (Expr t) # | |
Show t => Show (Expr t) Source # | |
Strokable (Expr TT) Source # | |
Instances
Foldable Array Source # | |
Defined in Yi.Syntax.JavaScript fold :: Monoid m => Array m -> m # foldMap :: Monoid m => (a -> m) -> Array a -> m # foldMap' :: Monoid m => (a -> m) -> Array a -> m # foldr :: (a -> b -> b) -> b -> Array a -> b # foldr' :: (a -> b -> b) -> b -> Array a -> b # foldl :: (b -> a -> b) -> b -> Array a -> b # foldl' :: (b -> a -> b) -> b -> Array a -> b # foldr1 :: (a -> a -> a) -> Array a -> a # foldl1 :: (a -> a -> a) -> Array a -> a # elem :: Eq a => a -> Array a -> Bool # maximum :: Ord a => Array a -> a # minimum :: Ord a => Array a -> a # | |
Data t => Data (Array t) Source # | |
Defined in Yi.Syntax.JavaScript gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Array t -> c (Array t) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Array t) # toConstr :: Array t -> Constr # dataTypeOf :: Array t -> DataType # dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (Array t)) # dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (Array t)) # gmapT :: (forall b. Data b => b -> b) -> Array t -> Array t # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Array t -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Array t -> r # gmapQ :: (forall d. Data d => d -> u) -> Array t -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Array t -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Array t -> m (Array t) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Array t -> m (Array t) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Array t -> m (Array t) # | |
Show t => Show (Array t) Source # | |
Strokable (Array TT) Source # | |
KeyValue t t (Expr t) | |
KeyValueErr t |
Instances
Foldable KeyValue Source # | |
Defined in Yi.Syntax.JavaScript fold :: Monoid m => KeyValue m -> m # foldMap :: Monoid m => (a -> m) -> KeyValue a -> m # foldMap' :: Monoid m => (a -> m) -> KeyValue a -> m # foldr :: (a -> b -> b) -> b -> KeyValue a -> b # foldr' :: (a -> b -> b) -> b -> KeyValue a -> b # foldl :: (b -> a -> b) -> b -> KeyValue a -> b # foldl' :: (b -> a -> b) -> b -> KeyValue a -> b # foldr1 :: (a -> a -> a) -> KeyValue a -> a # foldl1 :: (a -> a -> a) -> KeyValue a -> a # elem :: Eq a => a -> KeyValue a -> Bool # maximum :: Ord a => KeyValue a -> a # minimum :: Ord a => KeyValue a -> a # | |
Failable KeyValue Source # | |
Data t => Data (KeyValue t) Source # | |
Defined in Yi.Syntax.JavaScript gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> KeyValue t -> c (KeyValue t) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (KeyValue t) # toConstr :: KeyValue t -> Constr # dataTypeOf :: KeyValue t -> DataType # dataCast1 :: Typeable t0 => (forall d. Data d => c (t0 d)) -> Maybe (c (KeyValue t)) # dataCast2 :: Typeable t0 => (forall d e. (Data d, Data e) => c (t0 d e)) -> Maybe (c (KeyValue t)) # gmapT :: (forall b. Data b => b -> b) -> KeyValue t -> KeyValue t # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> KeyValue t -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> KeyValue t -> r # gmapQ :: (forall d. Data d => d -> u) -> KeyValue t -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> KeyValue t -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> KeyValue t -> m (KeyValue t) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> KeyValue t -> m (KeyValue t) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> KeyValue t -> m (KeyValue t) # | |
Show t => Show (KeyValue t) Source # | |
Strokable (KeyValue TT) Source # | |
Helper functions.
modStroke :: StyleName -> Stroke -> Stroke Source #
Given a new style and a stroke, return a stroke with the new style appended to the old one.
Stroking functions
nError :: [TT] -> [TT] -> Endo [Stroke] Source #
Given a list of tokens to check for errors (xs
) and a list of tokens to
stroke (xs'
), returns normal strokes for xs'
if there were no errors.
Otherwise returns error strokes for xs'
.
failStroker :: [TT] -> TT -> Endo [Stroke] Source #
Given a list of TT
, if any of them is an error, returns an error stroker,
otherwise a normal stroker. Using e.g. existentials, we could make this
more general and have support for heterogeneous lists of elements which
implement Failable, but I haven't had the time to fix this.
tokenToStroke :: TT -> Stroke Source #
Given a TT
, return a Stroke
for it.
The parser
statement :: P TT (Statement TT) Source #
Parser for statements such as "return", "while", "do-while", "for", etc.
block :: P TT (Block TT) Source #
Parser for "blocks", i.e. a bunch of statements wrapped in curly brackets or just a single statement.
Note that this works for JavaScript 1.8 "lambda" style function bodies as well, e.g. "function hello() 5", since expressions are also statements and we don't require a trailing semi-colon.
TODO: function hello() var x; is not a valid program.
stmtExpr :: P TT (Expr TT) Source #
Parser for expressions which may be statements. In reality, any expression is also a valid statement, but this is a slight compromise to get rid of the massive performance loss which is introduced when allowing JavaScript objects to be valid statements.
opExpr :: P TT (Expr TT) Source #
The basic idea here is to parse "the rest" of expressions, e.g. + 3
in x
+ 3
or [i]
in x[i]
. Anything which is useful in such a scenario goes
here. TODO: This accepts [], but shouldn't, since x[] is invalid.
array :: P TT (Expr TT) Source #
Parses both empty and non-empty arrays. Should probably be split up into
further parts to allow for the separation of []
and [1, 2, 3]
.
Parsing helpers
parameters :: P TT (Parameters TT) Source #
Parses a comma-separated list of valid identifiers.
Simple parsers
Recovery parsers
Utility stuff
errorToken :: TT Source #