mint.lexicalhandler - Palamecia/mint GitHub Wiki
Module mint.lexicalhandler
Description
load mint.lexicalhandler
This module provides the LexicalHandler class which provides an interface to parse a mint script and get callbacks on each token.
Enums
LexicalHandler.Token
This enum describes the token types used in the onToken method.
| Constant | Value | Description | 
|---|---|---|
| Amp | 47 | The token is a &operator. | 
| AmpEqual | 60 | The token is a &=operator. | 
| Assert | 0 | The token is an assertkeyword. | 
| Asterisk | 81 | The token is a *operator. | 
| AsteriskEqual | 55 | The token is a *=operator. | 
| At | 39 | The token is a @operator. | 
| BackSlash | 41 | The token is a \operator. | 
| Break | 1 | The token is a breakkeyword. | 
| Caret | 46 | The token is a ^orxoroperator. | 
| CaretEqual | 62 | The token is a ^=operator. | 
| Case | 2 | The token is a casekeyword. | 
| Catch | 3 | The token is a catchkeyword. | 
| Class | 4 | The token is a classkeyword. | 
| CloseBrace | 98 | The token is a }operator. | 
| CloseBracket | 96 | The token is a ]operator. | 
| CloseBracketEqual | 52 | The token is a ]=operator. | 
| CloseParenthesis | 94 | The token is a )operator. | 
| Colon | 50 | The token is a :operator. | 
| ColonEqual | 51 | The token is a :=operator. | 
| Comma | 42 | The token is a ,operator. | 
| Comment | 37 | The token is a comment. | 
| Const | 5 | The token is a constkeyword. | 
| Constant | 30 | The token is a constant value like true,false,nullornone. | 
| Continue | 6 | The token is a continuekeyword. | 
| DblAmp | 44 | The token is a &&orandoperator. | 
| DblAsterisk | 91 | The token is a **operator. | 
| DblDot | 64 | The token is a ..operator. | 
| DblEqual | 66 | The token is a ==operator. | 
| DblLeftAngled | 77 | The token is a <<operator. | 
| DblLeftAngledEqual | 58 | The token is a <<=operator. | 
| DblMinus | 90 | The token is a --operator. | 
| DblPipe | 43 | The token is a ||ororoperator. | 
| DblPlus | 89 | The token is a ++operator. | 
| DblRightAngled | 78 | The token is a >>operator. | 
| DblRightAngledEqual | 59 | The token is a >>=operator. | 
| Def | 7 | The token is a defkeyword. | 
| Default | 8 | The token is a defaultkeyword. | 
| Defined | 88 | The token is a definedoperator. | 
| Dollar | 38 | The token is a $operator. | 
| Dot | 92 | The token is a .operator. | 
| Elif | 9 | The token is a elifkeyword. | 
| Else | 10 | The token is a elsekeyword. | 
| Enum | 11 | The token is a enumkeyword. | 
| Equal | 48 | The token is a =operator. | 
| EqualRightAngled | 63 | The token is a =>operator. | 
| EqualTilde | 71 | The token is a =~operator. | 
| Exclamation | 84 | The token is a !ornotoperator. | 
| ExclamationDblEqual | 69 | The token is a !==operator. | 
| ExclamationEqual | 68 | The token is a !=operator. | 
| ExclamationTilde | 72 | The token is a !~operator. | 
| Exit | 12 | The token is a exitkeyword. | 
| FileEnd | 36 | The token is an end of file. | 
| Final | 13 | The token is a finalkeyword. | 
| For | 14 | The token is a forkeyword. | 
| If | 15 | The token is a ifkeyword. | 
| In | 16 | The token is a inkeyword. | 
| Is | 70 | The token is a isoperator. | 
| LeftAngled | 73 | The token is a <operator. | 
| LeftAngledEqual | 75 | The token is a <=operator. | 
| Let | 17 | The token is a letkeyword. | 
| Lib | 18 | The token is a libkeyword. | 
| LineEnd | 35 | The token is a non escaped end of line. | 
| Load | 19 | The token is a loadkeyword. | 
| Membersof | 87 | The token is a membersofoperator. | 
| Minus | 80 | The token is a -operator. | 
| MinusEqual | 54 | The token is a -=operator. | 
| ModulePath | 99 | The token is a module path element. | 
| NoLineEnd | 34 | The token is an escaped end of line. | 
| Number | 32 | The token is a number. | 
| OpenBrace | 97 | The token is a {operator. | 
| OpenBracket | 95 | The token is a [operator. | 
| OpenParenthesis | 93 | The token is a (operator. | 
| Override | 20 | The token is a overridekeyword. | 
| Package | 21 | The token is a packagekeyword. | 
| Percent | 83 | The token is a %operator. | 
| PercentEqual | 57 | The token is a %=operator. | 
| Pipe | 45 | The token is a |operator. | 
| PipeEqual | 61 | The token is a |=operator. | 
| Plus | 79 | The token is a +operator. | 
| PlusEqual | 53 | The token is a +=operator. | 
| 22 | The token is a printkeyword. | |
| Question | 49 | The token is a ?operator. | 
| Raise | 23 | The token is a raisekeyword. | 
| Regex | 100 | The token is a regular expression literal. | 
| Return | 24 | The token is a returnkeyword. | 
| RightAngled | 74 | The token is a >operator. | 
| RightAngledEqual | 76 | The token is a >=operator. | 
| Sharp | 40 | The token is a #operator. | 
| Slash | 82 | The token is a /operator. | 
| SlashEqual | 56 | The token is a /=operator. | 
| String | 31 | The token is a string literal. | 
| Switch | 25 | The token is a switchkeyword. | 
| Symbol | 33 | The token is a symbol. | 
| Tilde | 85 | The token is a ~operator. | 
| TplDot | 65 | The token is a ...operator. | 
| TplEqual | 67 | The token is a ===operator. | 
| Try | 26 | The token is a trykeyword. | 
| Typeof | 86 | The token is a typeofoperator. | 
| Var | 29 | The token is a varkeyword. | 
| While | 27 | The token is a whilekeyword. | 
| Yield | 28 | The token is a yieldkeyword. | 
Classes
LexicalHandler
This class provides an interface to parse mint scripts using the parse method. Each encountred token will be provided to a callback method like onToken.
Public members
| Modifiers | Member | Description | 
|---|---|---|
| enum | Token | This enum describes the token types used in the LexicalHandler.Token.onToken... | 
| const | new | Creates a new handler. | 
| onComment | The parser calls this method when it has parsed a line of comment. The token... | |
| onCommentBegin | The parser calls this method when it has parsed the begin of a comment. The o... | |
| onCommentEnd | The parser calls this method when it has parsed the end of a comment. The offset... | |
| onModulePathToken | The parser calls this method when it has parsed an element of a module path. ... | |
| onNewLine | The parser calls this method when it is about to parse a new line. The lineNu... | |
| onScriptBegin | The parser calls this method when it begin the parsing of the script. The par... | |
| onScriptEnd | The parser calls this method when the parsing reach the end of the script. Th... | |
| onSymbolToken | The parser calls this method when it has parsed an user defined symbol. The c... | |
| onToken | The parser calls this method when it has parsed a token. The typeparameter i... | |
| onWhiteSpace | The parser calls this method when it has parsed blank characters. The tokenp... | |
| const | parse | Parses the script provided by stream. Thestreamparameter must implement the... | 
Private members
| Modifiers | Member | Description | 
|---|---|---|
| final | d_ptr | Object data. | 
| @ | g_lib | Global library handle. | 
Descriptions
LexicalHandler.Token.Amp
47
The token is a & operator.
LexicalHandler.Token.AmpEqual
60
The token is a &= operator.
LexicalHandler.Token.Assert
0
The token is an assert keyword.
LexicalHandler.Token.Asterisk
81
The token is a * operator.
LexicalHandler.Token.AsteriskEqual
55
The token is a *= operator.
LexicalHandler.Token.At
39
The token is a @ operator.
LexicalHandler.Token.BackSlash
41
The token is a \ operator.
LexicalHandler.Token.Break
1
The token is a break keyword.
LexicalHandler.Token.Caret
46
The token is a ^ or xor operator.
LexicalHandler.Token.CaretEqual
62
The token is a ^= operator.
LexicalHandler.Token.Case
2
The token is a case keyword.
LexicalHandler.Token.Catch
3
The token is a catch keyword.
LexicalHandler.Token.Class
4
The token is a class keyword.
LexicalHandler.Token.CloseBrace
98
The token is a } operator.
LexicalHandler.Token.CloseBracket
96
The token is a ] operator.
LexicalHandler.Token.CloseBracketEqual
52
The token is a ]= operator.
LexicalHandler.Token.CloseParenthesis
94
The token is a ) operator.
LexicalHandler.Token.Colon
50
The token is a : operator.
LexicalHandler.Token.ColonEqual
51
The token is a := operator.
LexicalHandler.Token.Comma
42
The token is a , operator.
LexicalHandler.Token.Comment
37
The token is a comment.
LexicalHandler.Token.Const
5
The token is a const keyword.
LexicalHandler.Token.Constant
30
The token is a constant value like true, false, null or none.
LexicalHandler.Token.Continue
6
The token is a continue keyword.
LexicalHandler.Token.DblAmp
44
The token is a && or and operator.
LexicalHandler.Token.DblAsterisk
91
The token is a ** operator.
LexicalHandler.Token.DblDot
64
The token is a .. operator.
LexicalHandler.Token.DblEqual
66
The token is a == operator.
LexicalHandler.Token.DblLeftAngled
77
The token is a << operator.
LexicalHandler.Token.DblLeftAngledEqual
58
The token is a <<= operator.
LexicalHandler.Token.DblMinus
90
The token is a -- operator.
LexicalHandler.Token.DblPipe
43
The token is a || or or operator.
LexicalHandler.Token.DblPlus
89
The token is a ++ operator.
LexicalHandler.Token.DblRightAngled
78
The token is a >> operator.
LexicalHandler.Token.DblRightAngledEqual
59
The token is a >>= operator.
LexicalHandler.Token.Def
7
The token is a def keyword.
LexicalHandler.Token.Default
8
The token is a default keyword.
LexicalHandler.Token.Defined
88
The token is a defined operator.
LexicalHandler.Token.Dollar
38
The token is a $ operator.
LexicalHandler.Token.Dot
92
The token is a . operator.
LexicalHandler.Token.Elif
9
The token is a elif keyword.
LexicalHandler.Token.Else
10
The token is a else keyword.
LexicalHandler.Token.Enum
11
The token is a enum keyword.
LexicalHandler.Token.Equal
48
The token is a = operator.
LexicalHandler.Token.EqualRightAngled
63
The token is a => operator.
LexicalHandler.Token.EqualTilde
71
The token is a =~ operator.
LexicalHandler.Token.Exclamation
84
The token is a ! or not operator.
LexicalHandler.Token.ExclamationDblEqual
69
The token is a !== operator.
LexicalHandler.Token.ExclamationEqual
68
The token is a != operator.
LexicalHandler.Token.ExclamationTilde
72
The token is a !~ operator.
LexicalHandler.Token.Exit
12
The token is a exit keyword.
LexicalHandler.Token.FileEnd
36
The token is an end of file.
LexicalHandler.Token.Final
13
The token is a final keyword.
LexicalHandler.Token.For
14
The token is a for keyword.
LexicalHandler.Token.If
15
The token is a if keyword.
LexicalHandler.Token.In
16
The token is a in keyword.
LexicalHandler.Token.Is
70
The token is a is operator.
LexicalHandler.Token.LeftAngled
73
The token is a < operator.
LexicalHandler.Token.LeftAngledEqual
75
The token is a <= operator.
LexicalHandler.Token.Let
17
The token is a let keyword.
LexicalHandler.Token.Lib
18
The token is a lib keyword.
LexicalHandler.Token.LineEnd
35
The token is a non escaped end of line.
LexicalHandler.Token.Load
19
The token is a load keyword.
LexicalHandler.Token.Membersof
87
The token is a membersof operator.
LexicalHandler.Token.Minus
80
The token is a - operator.
LexicalHandler.Token.MinusEqual
54
The token is a -= operator.
LexicalHandler.Token.ModulePath
99
The token is a module path element.
LexicalHandler.Token.NoLineEnd
34
The token is an escaped end of line.
LexicalHandler.Token.Number
32
The token is a number.
LexicalHandler.Token.OpenBrace
97
The token is a { operator.
LexicalHandler.Token.OpenBracket
95
The token is a [ operator.
LexicalHandler.Token.OpenParenthesis
93
The token is a ( operator.
LexicalHandler.Token.Override
20
The token is a override keyword.
LexicalHandler.Token.Package
21
The token is a package keyword.
LexicalHandler.Token.Percent
83
The token is a % operator.
LexicalHandler.Token.PercentEqual
57
The token is a %= operator.
LexicalHandler.Token.Pipe
45
The token is a | operator.
LexicalHandler.Token.PipeEqual
61
The token is a |= operator.
LexicalHandler.Token.Plus
79
The token is a + operator.
LexicalHandler.Token.PlusEqual
53
The token is a += operator.
LexicalHandler.Token.Print
22
The token is a print keyword.
LexicalHandler.Token.Question
49
The token is a ? operator.
LexicalHandler.Token.Raise
23
The token is a raise keyword.
LexicalHandler.Token.Regex
100
The token is a regular expression literal.
LexicalHandler.Token.Return
24
The token is a return keyword.
LexicalHandler.Token.RightAngled
74
The token is a > operator.
LexicalHandler.Token.RightAngledEqual
76
The token is a >= operator.
LexicalHandler.Token.Sharp
40
The token is a # operator.
LexicalHandler.Token.Slash
82
The token is a / operator.
LexicalHandler.Token.SlashEqual
56
The token is a /= operator.
LexicalHandler.Token.String
31
The token is a string literal.
LexicalHandler.Token.Switch
25
The token is a switch keyword.
LexicalHandler.Token.Symbol
33
The token is a symbol.
LexicalHandler.Token.Tilde
85
The token is a ~ operator.
LexicalHandler.Token.TplDot
65
The token is a ... operator.
LexicalHandler.Token.TplEqual
67
The token is a === operator.
LexicalHandler.Token.Try
26
The token is a try keyword.
LexicalHandler.Token.Typeof
86
The token is a typeof operator.
LexicalHandler.Token.Var
29
The token is a var keyword.
LexicalHandler.Token.While
27
The token is a while keyword.
LexicalHandler.Token.Yield
28
The token is a yield keyword.
LexicalHandler.d_ptr
null
Object data.
LexicalHandler.g_lib
lib ('libmint-mint')
Global library handle.
LexicalHandler.new
def (self)
Creates a new handler.
LexicalHandler.onComment
def (self, token, offset)
The parser calls this method when it has parsed a line of comment. The
token parameter is a string containing the characters that were read.
The offset parameter is the position of the token in the script. If the
comment is split into multiple lines, this method is called for each lines
of the comment.
If this method returns false the parser stops and reports an error.
LexicalHandler.onCommentBegin
def (self, offset)
The parser calls this method when it has parsed the begin of a comment.
The offset parameter is the position of the comment in the script.
If this method returns false the parser stops and reports an error.
LexicalHandler.onCommentEnd
def (self, offset)
The parser calls this method when it has parsed the end of a comment.
The offset parameter is the position after the comment in the script.
If this method returns false the parser stops and reports an error.
LexicalHandler.onModulePathToken
def (self, context, token, offset)
The parser calls this method when it has parsed an element of a module
path. The context is an array containing the previous elements of the
module path as strings and the token parameter is the current element
being parsed. The offset parameter is the position of the token in the
script.
If this method returns false the parser stops and reports an error.
LexicalHandler.onNewLine
def (self, lineNumber, offset)
The parser calls this method when it is about to parse a new line. The
lineNumber parameter is the number of the next line starting from 1.
The offset parameter is the position of the new line in the script.
If this method returns false the parser stops and reports an error.
LexicalHandler.onScriptBegin
def (self)
The parser calls this method when it begin the parsing of the script. The parser calls this method just once, after the call to parse, and before any other method in this class are called.
If this method returns false the parser stops and reports an error.
LexicalHandler.onScriptEnd
def (self)
The parser calls this method when the parsing reach the end of the script. The parser calls this method just once and is the last handler function called.
If this method returns false the parser stops and reports an error.
LexicalHandler.onSymbolToken
def (self, context, token, offset)
The parser calls this method when it has parsed an user defined symbol.
The context is an array containing the path to the symbol as strings
(e.g. ['System', 'OS'] for System.OS.getType) and the token parameter
is the current symbol being parsed. The offset parameter is the position
of the token in the script.
If this method returns false the parser stops and reports an error.
def (self, context, offset)
The parser calls this method when it was expecting an user defined symbol
but found nothing. The context is an array containing the path to the
expected symbol as strings (e.g. ['System', 'OS'] for System.OS.). The
offset parameter is the position where the token was expected in the
script.
If this method returns false the parser stops and reports an error.
LexicalHandler.onToken
def (self, % type, token, offset)
The parser calls this method when it has parsed a token. The type
parameter is a value of Token that provides the type of the token
and the token parameter is the string representation of the token. The
offset parameter is the position of the token in the script.
If this method returns false the parser stops and reports an error.
LexicalHandler.onWhiteSpace
def (self, token, offset)
The parser calls this method when it has parsed blank characters. The
token parameter is a string containing the characters that were read.
The offset parameter is the position of the token in the script.
If this method returns false the parser stops and reports an error.
LexicalHandler.parse
def (const self, stream)
Parses the script provided by stream. The stream parameter must
implement the read part of the serializer interface and provide
a getChar method. Returns true on success; otherwise returns false.