-
Notifications
You must be signed in to change notification settings - Fork 0
/
notex2.dart
99 lines (83 loc) · 1.92 KB
/
notex2.dart
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
98
99
/*
* Copyright (c) 2014 syuilo All rights reserved.
* Thanks for Akari, Chinatsu, Yui, Kyoko and you.
* syuilo
**************************************************************** */
library notex2;
/*
* Import Scanner
*/
part 'scanner.dart';
/*
* Import Parser
*/
part 'parser.dart';
/*
* Import lexcal analyzer
*/
part 'lexer.dart';
/*
* Import elements
*/
part 'Elements/element.dart';
part 'Elements/article.dart';
part 'Elements/blockquote.dart';
part 'Elements/code.dart';
part 'Elements/image.dart';
part 'Elements/keyword.dart';
part 'Elements/link.dart';
part 'Elements/list.dart';
part 'Elements/list_item.dart';
part 'Elements/multilinecode.dart';
part 'Elements/paragraph.dart';
part 'Elements/section.dart';
part 'Elements/strike.dart';
part 'Elements/strong.dart';
part 'Elements/table.dart';
part 'Elements/table_data.dart';
part 'Elements/table_header.dart';
part 'Elements/table_row.dart';
part 'Elements/text.dart';
void scream() {
print("うー!にゃー!" * 4);
}
String indent(int hierarchy) {
//return ("\t" * hierarchy);
return (" " * hierarchy);
}
String htmlEscape(String source) {
String html = source;
html = html.replaceAll('<', '<');
html = html.replaceAll('>', '>');
return html;
}
/**
* Token
*/
class Token {
int id = 0;
String token = "";
String lexeme = "";
// 解析には不要。エラー提示用
int row = 0; // 行
int col = 0; // 列
}
/**
* コンパイラ本体です。
*/
class Notex2 {
String source;
String id = "article";
Parser parser;
Notex2(String source, [String articleId = "article"]) {
this.source = source;
this.id = articleId;
}
Article compile() {
this.parser = new Parser(new Scanner(new Lexer(this.source).analyze()));
Article article = new Article();
article.title = this.id;
article.children = this.parser.analyze(article, (token){return false;});
return article;
}
}