mint.lexicalhandler - Palamecia/mint GitHub Wiki

Module

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 assert keyword.
Asterisk 80 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 break keyword.
Caret 46 The token is a ^ or xor operator.
CaretEqual 62 The token is a ^= operator.
Case 2 The token is a case keyword.
Catch 3 The token is a catch keyword.
Class 4 The token is a class keyword.
CloseBrace 97 The token is a } operator.
CloseBracket 95 The token is a ] operator.
CloseBracketEqual 52 The token is a ]= operator.
CloseParenthesis 93 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 const keyword.
Constant 30 The token is a constant value like true, false, null or none .
Continue 6 The token is a continue keyword.
DblAmp 44 The token is a && or and operator.
DblAsterisk 90 The token is a ** operator.
DblEqual 65 The token is a == operator.
DblLeftAngled 76 The token is a << operator.
DblLeftAngledEqual 58 The token is a <<= operator.
DblMinus 89 The token is a -- operator.
DblPipe 43 The token is a &#124;&#124; or or operator.
DblPlus 88 The token is a ++ operator.
DblRightAngled 77 The token is a >> operator.
DblRightAngledEqual 59 The token is a >>= operator.
Dbldot 50 The token is a : operator.
DbldotEqual 51 The token is a := operator.
Def 7 The token is a def keyword.
Default 8 The token is a default keyword.
Defined 87 The token is a defined operator.
Dollar 38 The token is a $ operator.
Dot 91 The token is a . operator.
DotDot 63 The token is a .. operator.
Elif 9 The token is a elif keyword.
Else 10 The token is a else keyword.
Enum 11 The token is a enum keyword.
Equal 48 The token is a = operator.
EqualTilde 70 The token is a =~ operator.
Exclamation 83 The token is a ! or not operator.
ExclamationDblEqual 68 The token is a !== operator.
ExclamationEqual 67 The token is a != operator.
ExclamationTilde 71 The token is a !~ operator.
Exit 12 The token is a exit keyword.
FileEnd 36 The token is an end of file.
Final 13 The token is a final keyword.
For 14 The token is a for keyword.
If 15 The token is a if keyword.
In 16 The token is a in keyword.
Is 69 The token is a is operator.
LeftAngled 72 The token is a < operator.
LeftAngledEqual 74 The token is a <= operator.
Let 17 The token is a let keyword.
Lib 18 The token is a lib keyword.
LineEnd 35 The token is a non escaped end of line.
Load 19 The token is a load keyword.
Membersof 86 The token is a membersof operator.
Minus 79 The token is a - operator.
MinusEqual 54 The token is a -= operator.
ModulePath 98 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 96 The token is a { operator.
OpenBracket 94 The token is a [ operator.
OpenParenthesis 92 The token is a ( operator.
Override 20 The token is a override keyword.
Package 21 The token is a package keyword.
Percent 82 The token is a % operator.
PercentEqual 57 The token is a %= operator.
Pipe 45 The token is a &#124; operator.
PipeEqual 61 The token is a &#124;= operator.
Plus 78 The token is a + operator.
PlusEqual 53 The token is a += operator.
Print 22 The token is a print keyword.
Question 49 The token is a ? operator.
Raise 23 The token is a raise keyword.
Regex 99 The token is a regular expression literal.
Return 24 The token is a return keyword.
RightAngled 73 The token is a > operator.
RightAngledEqual 75 The token is a >= operator.
Sharp 40 The token is a # operator.
Slash 81 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 switch keyword.
Symbol 33 The token is a symbol.
Tilde 84 The token is a ~ operator.
TplDot 64 The token is a ... operator.
TplEqual 66 The token is a === operator.
Try 26 The token is a try keyword.
Typeof 85 The token is a typeof operator.
Var 29 The token is a var keyword.
While 27 The token is a while keyword.
Yield 28 The token is a yield keyword.

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.

Members

Modifiers Member Description
+ enum Token This enum describes the token types used in the onToken method.
- final d_ptr Object data.
- @ g_lib Global library handle.
+ const new Creates a new handler.
+ onComment The parser calls this method when it has parsed a line of comment. The toke...
+ onCommentBegin The parser calls this method when it has parsed the begin of a comment. The ...
+ onCommentEnd The parser calls this method when it has parsed the end of a comment. The o...
+ 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 line...
+ 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 ...
+ onToken The parser calls this method when it has parsed a token. The type parameter...
+ onWhiteSpace The parser calls this method when it has parsed blank characters. The token...
+ const parse Parses the script provided by stream. The stream parameter must implement...

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

80

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

97

The token is a } operator.

LexicalHandler.Token.CloseBracket

95

The token is a ] operator.

LexicalHandler.Token.CloseBracketEqual

52

The token is a ]= operator.

LexicalHandler.Token.CloseParenthesis

93

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

90

The token is a ** operator.

LexicalHandler.Token.DblEqual

65

The token is a == operator.

LexicalHandler.Token.DblLeftAngled

76

The token is a << operator.

LexicalHandler.Token.DblLeftAngledEqual

58

The token is a <<= operator.

LexicalHandler.Token.DblMinus

89

The token is a -- operator.

LexicalHandler.Token.DblPipe

43

The token is a || or or operator.

LexicalHandler.Token.DblPlus

88

The token is a ++ operator.

LexicalHandler.Token.DblRightAngled

77

The token is a >> operator.

LexicalHandler.Token.DblRightAngledEqual

59

The token is a >>= operator.

LexicalHandler.Token.Dbldot

50

The token is a : operator.

LexicalHandler.Token.DbldotEqual

51

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

87

The token is a defined operator.

LexicalHandler.Token.Dollar

38

The token is a $ operator.

LexicalHandler.Token.Dot

91

The token is a . operator.

LexicalHandler.Token.DotDot

63

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.EqualTilde

70

The token is a =~ operator.

LexicalHandler.Token.Exclamation

83

The token is a ! or not operator.

LexicalHandler.Token.ExclamationDblEqual

68

The token is a !== operator.

LexicalHandler.Token.ExclamationEqual

67

The token is a != operator.

LexicalHandler.Token.ExclamationTilde

71

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

69

The token is a is operator.

LexicalHandler.Token.LeftAngled

72

The token is a < operator.

LexicalHandler.Token.LeftAngledEqual

74

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

86

The token is a membersof operator.

LexicalHandler.Token.Minus

79

The token is a - operator.

LexicalHandler.Token.MinusEqual

54

The token is a -= operator.

LexicalHandler.Token.ModulePath

98

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

96

The token is a { operator.

LexicalHandler.Token.OpenBracket

94

The token is a [ operator.

LexicalHandler.Token.OpenParenthesis

92

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

82

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

78

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

99

The token is a regular expression literal.

LexicalHandler.Token.Return

24

The token is a return keyword.

LexicalHandler.Token.RightAngled

73

The token is a > operator.

LexicalHandler.Token.RightAngledEqual

75

The token is a >= operator.

LexicalHandler.Token.Sharp

40

The token is a # operator.

LexicalHandler.Token.Slash

81

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

84

The token is a ~ operator.

LexicalHandler.Token.TplDot

64

The token is a ... operator.

LexicalHandler.Token.TplEqual

66

The token is a === operator.

LexicalHandler.Token.Try

26

The token is a try keyword.

LexicalHandler.Token.Typeof

85

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 tokenparameter 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.