Skip to content

Commit 95f1a04

Browse files
authored
Add files via upload
1 parent e84a282 commit 95f1a04

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

pine_lexer.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from pygments.lexer import RegexLexer
2+
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
3+
Number, Literal, Punctuation, Generic, Other, Error
4+
5+
# Many examples are here https://bitbucket.org/birkenfeld/pygments-main/src/default/pygments/lexers/
6+
class PinePygmentsLexer(RegexLexer):
7+
name = 'pine'
8+
9+
tokens = {
10+
'root': [
11+
(r'\#([0-9a-fA-F]{8})|\#([0-9a-fA-F]{6})', Literal), # Color literal
12+
(r'[0-9]+', Number.Integer),
13+
(r'(\.\d+|[0-9]+\.[0-9]*)([eE][-+]?[0-9]+)?', Number.Float),
14+
(r'\s+', Text.Whitespace),
15+
(r'//.*?$', Comment),
16+
(r'(for|if|else|var)\b', Keyword),
17+
(r'(open|high|low|close|volume|time|hl2|hlc3|ohlc4)\b', Name.Constant), # Built-in series 'open', 'high', ...
18+
(r'(study|strategy|plot|plotshape|plotchar|plotarrow|fill|hline|input)\b', Name.Entity), # Annotation function
19+
(r'[\w\.]+', Name.Other),
20+
(r'\+|\-|\*|\/|\%|\=|\[|\]|and|or|not|\?|\:|\<|\>|\!', Operator),
21+
(r'\(|\)|\,', Punctuation),
22+
(r'"(\\\\|\\"|[^"])*"', String.Double),
23+
(r"'(\\\\|\\'|[^'])*'", String.Single),
24+
]
25+
}

pine_style.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from pygments.style import Style
2+
from pygments.token import Keyword, Name, Comment, String, Error, \
3+
Number, Literal, Operator, Generic, Whitespace
4+
5+
# Many examples are here https://bitbucket.org/birkenfeld/pygments-main/src/default/pygments/styles/default.py
6+
7+
class PineStyle(Style):
8+
background_color = "#f8f8f8"
9+
default_style = ""
10+
11+
styles = {
12+
Whitespace: "#bbbbbb",
13+
Comment: "italic #408080",
14+
15+
Keyword: "bold #008000",
16+
17+
Operator: "#666666",
18+
19+
Literal: "#ff00ff", # Color literal
20+
Name: "#101010",
21+
Name.Constant: "bold #800000", # Built-in series 'open', 'high', ...
22+
Name.Entity: "bold #008000", # Annotation function
23+
24+
String: "#BA2121",
25+
Number: "#6666FF",
26+
27+
Error: "border:#FF0000"
28+
}

0 commit comments

Comments
 (0)