yi-mode-javascript-0.19.1: Yi editor javascript mode

Safe Haskell | None
Language | Haskell2010

Yi.Lexer.JavaScript

Synopsis

- initState :: HlState
- alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput))
- tokenToStyle :: Token -> UIStyle -> Style
- type TT = Tok Token
- data Token
  - = Unknown
  - | Res !Reserved
  - | Str !String
  - | Rex !String
  - | Op !Operator
  - | Special !Char
  - | Number !String
  - | ValidName !String
  - | Comment !CommentType
  - | Const !String
- data Reserved
  - = Break'
  - | Case'
  - | Catch'
  - | Continue'
  - | Default'
  - | Delete'
  - | Do'
  - | Else'
  - | Finally'
  - | For'
  - | Function'
  - | If'
  - | In'
  - | InstanceOf'
  - | New'
  - | Return'
  - | Switch'
  - | This'
  - | Throw'
  - | Try'
  - | TypeOf'
  - | Var'
  - | Void'
  - | While'
  - | With'
  - | True'
  - | False'
  - | Null'
  - | Undefined'
- data Operator
  - = Add'
  - | Subtract'
  - | Multiply'
  - | Divide'
  - | Modulo'
  - | Increment'
  - | Decrement'
  - | Assign'
  - | AddAssign'
  - | SubtractAssign'
  - | MultiplyAssign'
  - | DivideAssign'
  - | ModuloAssign'
  - | Equals'
  - | NotEquals'
  - | GT'
  - | GTE'
  - | LT'
  - | LTE'
  - | EqualsType'
  - | NotEqualsType'
  - | And'
  - | Or'
  - | Not'
  - | BitAnd'
  - | BitOr'
  - | BitXor'
  - | LeftShift'
  - | RightShift'
  - | RightShiftZ'
  - | BitNot'
  - | Qualify'
- type HlState = Int
- prefixOperators :: [Operator]
- infixOperators :: [Operator]
- postfixOperators :: [Operator]

# Documentation

initState :: HlState Source #

alexScanToken :: (AlexState HlState, AlexInput) -> Maybe (Tok Token, (AlexState HlState, AlexInput)) Source #

Scan one token. Return (maybe) a token and a new state.

tokenToStyle :: Token -> UIStyle -> Style Source #

Takes a `Token` and returns a style to be used for that type of token.

TODO: The `elem` check is potentially unnecessarily slow. We could split the Const constructor into two different ones, one for builtins and one for others.

type TT = Tok Token Source #

data Token Source #

The different tokens.

Constructors

Unknown |
Res !Reserved |
Str !String |
Rex !String |
Op !Operator |
Special !Char |
Number !String |
ValidName !String |
Comment !CommentType |
Const !String |

#### Instances

Instances details

Show Token Source # |
Instance details Defined in Yi.Lexer.JavaScript Methods showsPrec :: Int -> Token -> ShowS Source # show :: Token -> String Source # showList :: [Token] -> ShowS Source #
Eq Token Source # |
Instance details Defined in Yi.Lexer.JavaScript Methods (==) :: Token -> Token -> Bool Source # (/=) :: Token -> Token -> Bool Source #
Strokable (Tok Token) Source # |
Instance details Defined in Yi.Syntax.JavaScript Methods toStrokes :: Tok Token -> Endo [Stroke] Source #
Strokable (Array TT) Source # |
Instance details Defined in Yi.Syntax.JavaScript Methods toStrokes :: Array TT -> Endo [Stroke] Source #
Strokable (Block TT) Source # |
Instance details Defined in Yi.Syntax.JavaScript Methods toStrokes :: Block TT -> Endo [Stroke] Source #
Strokable (Expr TT) Source # |
Instance details Defined in Yi.Syntax.JavaScript Methods toStrokes :: Expr TT -> Endo [Stroke] Source #
Strokable (ForContent TT) Source # |
Instance details Defined in Yi.Syntax.JavaScript Methods toStrokes :: ForContent TT -> Endo [Stroke] Source #
Strokable (KeyValue TT) Source # |
Instance details Defined in Yi.Syntax.JavaScript Methods toStrokes :: KeyValue TT -> Endo [Stroke] Source #
Strokable (ParExpr TT) Source # |
Instance details Defined in Yi.Syntax.JavaScript Methods toStrokes :: ParExpr TT -> Endo [Stroke] Source #
Strokable (Parameters TT) Source # |
Instance details Defined in Yi.Syntax.JavaScript Methods toStrokes :: Parameters TT -> Endo [Stroke] 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.
Instance details Defined in Yi.Syntax.JavaScript Methods toStrokes :: Statement TT -> Endo [Stroke] Source #
Strokable (VarDecAss TT) Source # |
Instance details Defined in Yi.Syntax.JavaScript Methods toStrokes :: VarDecAss TT -> Endo [Stroke] Source #

data Reserved Source #

The constructors for `Reserved` have an apostrophe as a suffix because `Default` is already used. Also note that `Undefined'` is not intended as some sort of "backup" reserved word for things we don't care about -- it really means the "undefined" built-in in JavaScript.

Constructors

Break' |
Case' |
Catch' |
Continue' |
Default' |
Delete' |
Do' |
Else' |
Finally' |
For' |
Function' |
If' |
In' |
InstanceOf' |
New' |
Return' |
Switch' |
This' |
Throw' |
Try' |
TypeOf' |
Var' |
Void' |
While' |
With' |
True' |
False' |
Null' |
Undefined' |

#### Instances

Instances details

Show Reserved Source # |
Instance details Defined in Yi.Lexer.JavaScript Methods showsPrec :: Int -> Reserved -> ShowS Source # show :: Reserved -> String Source # showList :: [Reserved] -> ShowS Source #
Eq Reserved Source # |
Instance details Defined in Yi.Lexer.JavaScript Methods (==) :: Reserved -> Reserved -> Bool Source # (/=) :: Reserved -> Reserved -> Bool Source #

data Operator Source #

The constructors for `Operator` have an apostrophe as a suffix because e.g. `LT` is already used by `Prelude`.

Constructors

Add' |
Subtract' |
Multiply' |
Divide' |
Modulo' |
Increment' |
Decrement' |
Assign' |
AddAssign' |
SubtractAssign' |
MultiplyAssign' |
DivideAssign' |
ModuloAssign' |
Equals' |
NotEquals' |
GT' |
GTE' |
LT' |
LTE' |
EqualsType' |
NotEqualsType' |
And' |
Or' |
Not' |
BitAnd' |
BitOr' |
BitXor' |
LeftShift' |
RightShift' |
RightShiftZ' |
BitNot' |
Qualify' |

#### Instances

Instances details

Show Operator Source # |
Instance details Defined in Yi.Lexer.JavaScript Methods showsPrec :: Int -> Operator -> ShowS Source # show :: Operator -> String Source # showList :: [Operator] -> ShowS Source #
Eq Operator Source # |
Instance details Defined in Yi.Lexer.JavaScript Methods (==) :: Operator -> Operator -> Bool Source # (/=) :: Operator -> Operator -> Bool Source #

type HlState = Int Source #

`HlState` is 0 when outside of a multi-line comment and -1 when inside one.

prefixOperators :: [Operator] Source #

Prefix operators. NOTE: Add' is also a valid prefix operator, but since it's completely useless in the real world, we don't care about it here. Doing this makes parsing much, much easier.

infixOperators :: [Operator] Source #

Infix operators.

postfixOperators :: [Operator] Source #

Postfix operators.