-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLangwej.js
More file actions
97 lines (88 loc) · 4.55 KB
/
Langwej.js
File metadata and controls
97 lines (88 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// fsm-config: {"font" : "Roboto", "bgColor": "white", "color": "black", "fontColor":"black", "finalShape": "doubleoctagon"}
let Langwej = {
initial: 'emptyLexeme',
final: ['_IDENTIFIER', '_INTEGER', '_KEYWORD', '_FLOAT', 'CHAR', 'STRING', 'GTEQ', 'LTEQ', 'ISEQ', 'NOTEQ', '_GT', '_LT', '_NOT', 'SYMBOL', 'OR', 'AND', '_ASSIGN', "SingleComment","MultipleComment"],
events: [
{ name: 'whitespace', from: 'emptyLexeme', to: 'emptyLexeme' },
// Single comment
{ name: 'hashtag', from: 'emptyLexeme', to: 'middleSingleComment'},
{ name: 'anything', from: 'middleSingleComment', to: 'middleSingleComment' },
{ name: 'newline', from: 'middleSingleComment', to: 'SingleComment'},
// Multiple comment
{ name: 'backtick', from: 'emptyLexeme', to: 'middleMultipleComment'},
{ name: 'anything', from: 'middleMultipleComment', to: 'middleMultipleComment' },
{ name: 'backtick', from: 'middleMultipleComment', to: 'MultipleComment'},
// Keyword and Identifier
{name: 'a-z,A-Z,_', from: 'emptyLexeme', to: 'alphabet'},
{name: 'a-z,A-Z,_', from: 'alphabet', to: 'alphabet'},
{name: '0-9', from: 'alphabet', to: 'alnum'},
{name: 'a-z,A-Z,_0-9', from: 'alnum', to: 'alnum'},
{name: 'symbol, whitespace', from: 'alnum', to: '_IDENTIFIER'},
{name: 'symbol, whitespace', from: 'alphabet', to: '_KEYWORD'},
{name: '!KEYWORD', from: '_KEYWORD', to: '_IDENTIFIER', color: "green"},
// Integer
{name: '0-9', from: 'emptyLexeme', to: 'number'},
{name: '0-9', from: 'number', to: 'number'},
{name: 'symbol, whitespace', from: 'number', to: '_INTEGER'},
// Float
{name: '.', from: 'number', to: 'point'},
{name: '0-9', from: 'point', to: 'float'},
{name: '0-9', from: 'float', to: 'float'},
{name: 'symbol, whitespace', from: 'float', to: '_FLOAT'},
{name: 'e,E', from: 'float', to: 'exponent'},
{name: '0-9', from: 'exponent', to: 'float'},
{name: '+, -', from: 'exponent', to: 'exponentSign'},
{name: '0-9', from: 'exponentSign', to: 'float'},
// Char
{name: 'singleQuote', from: 'emptyLexeme', to: 'openChar'},
{name: 'anything', from: 'openChar', to: 'char'},
{name: 'backslash', from: 'openChar', to: 'slashChar'},
{name: 'n,t,doubleQuote,r,backslash', from: 'slashChar', to: 'char'},
{name: 'singleQuote', from: 'char', to: 'CHAR'},
{name: 'singleQuote', from: 'openChar', to: 'CHAR'},
// String
{name: 'doubleQuote', from: 'emptyLexeme', to: 'openString'},
{name: 'anything', from: 'openString', to: 'openString'},
{name: 'doubleQuote', from: 'openString', to: 'STRING'},
// Operators
{name: '>', from: 'emptyLexeme', to: 'greaterThan'},
{name: '<', from: 'emptyLexeme', to: 'lessThan'},
{name: '=', from: 'greaterThan', to: 'GTEQ'},
{name: '=', from: 'lessThan', to: 'LTEQ'},
{name: '=', from: 'emptyLexeme', to: 'equalHalf'},
{name: '!', from: 'emptyLexeme', to: 'notEqualHalf'},
{name: '=', from: 'equalHalf', to: 'ISEQ'},
{name: 'anything', from: 'equalHalf', to: '_ASSIGN'},
{name: '=', from: 'notEqualHalf', to: 'NOTEQ'},
{name: 'anything', from: 'greaterThan', to: '_GT'},
{name: 'anything', from: 'lessThan', to: '_LT'},
{name: 'anything', from: 'notEqualHalf', to: '_NOT'},
{name: 'symbol', from: 'emptyLexeme', to: 'SYMBOL'},
{name: '|', from: 'emptyLexeme', to: 'orHalf'},
{name: '|', from: 'orHalf', to: 'OR'},
{name: '&', from: 'emptyLexeme', to: 'andHalf'},
{name: '&', from: 'andHalf', to: 'AND'},
],
states: [
{ name: 'emptyLexeme', color: 'blue'},
{name: 'SingleComment', color: "green"},
{name: 'MultipleComment', color: "green"},
{name: '_IDENTIFIER', color: "green"},
{name: '_KEYWORD', color: "green"},
{name: '_INTEGER', color: "green"},
{name: '_FLOAT', color: "green"},
{name: 'CHAR', color: "green"},
{name: 'STRING', color: "green"},
{name: 'GTEQ', color: "green"},
{name: 'LTEQ', color: "green"},
{name: '_GT', color: "green"},
{name: '_LT', color: "green"},
{name: 'ISEQ', color: "green"},
{name: 'NOTEQ', color: "green"},
{name: '_ASSIGN', color: "green"},
{name: '_NOT', color: "green"},
{name: 'SYMBOL', color: "green"},
{name: 'OR', color: "green"},
{name: 'AND', color: "green"}
],
}