mirror of
https://github.com/alecthomas/chroma.git
synced 2025-02-13 13:28:27 +02:00
415 lines
16 KiB
Plaintext
415 lines
16 KiB
Plaintext
[
|
|
{"type":"CommentSingle","value":"# Everything after \"#\" is a comment."},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentSingle","value":"# A file is a class!"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"# (optional) icon to show in the editor dialogs:"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"NameDecorator","value":"@icon"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringDouble","value":"\"res://path/to/optional/icon.svg\""},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"# (optional) class definition:"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"class_name"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"MyClass"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"# Inheritance:"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"extends"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"BaseClass"},
|
|
{"type":"Text","value":"\n\n\n"},
|
|
{"type":"CommentSingle","value":"# Member variables."},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"var"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"5"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"var"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"s"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringDouble","value":"\"Hello\""},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"var"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"arr"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"["},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":"]"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"var"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"dict"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"LiteralStringDouble","value":"\"key\""},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringDouble","value":"\"value\""},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"var"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"other_dict"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Name","value":"key"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringDouble","value":"\"value\""},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"other_key"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"var"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"typed_var"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"KeywordType","value":"int"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"var"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"inferred_type"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":":="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringDouble","value":"\"String\""},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"# Constants."},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"const"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"ANSWER"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"42"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"const"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"THE_NAME"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralStringDouble","value":"\"Charly\""},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"# Enums."},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"enum"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Name","value":"UNIT_NEUTRAL"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"UNIT_ENEMY"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"UNIT_ALLY"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"enum"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"Named"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Punctuation","value":"{"},
|
|
{"type":"Name","value":"THING_1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"THING_2"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"ANOTHER_THING"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-"},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":"}"},
|
|
{"type":"Text","value":"\n\n"},
|
|
{"type":"CommentSingle","value":"# Built-in vector types."},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"var"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"v2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Vector2"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"var"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"v3"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Vector3"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"2"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n\n"},
|
|
{"type":"CommentSingle","value":"# Functions."},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"func"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"some_function"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"param1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"param2"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"param3"},
|
|
{"type":"Punctuation","value":"):"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"KeywordDeclaration","value":"const"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"local_const"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"5"},
|
|
{"type":"Text","value":"\n\n "},
|
|
{"type":"Keyword","value":"if"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"param1"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003c"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"local_const"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"NameBuiltin","value":"print"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"param1"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"Keyword","value":"elif"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"param2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"\u003e"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"5"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"NameBuiltin","value":"print"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"param2"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"Keyword","value":"else"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"NameBuiltin","value":"print"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringDouble","value":"\"Fail!\""},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n "},
|
|
{"type":"Keyword","value":"for"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"i"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"OperatorWord","value":"in"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameBuiltin","value":"range"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralNumberInteger","value":"20"},
|
|
{"type":"Punctuation","value":"):"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"NameBuiltin","value":"print"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"i"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n "},
|
|
{"type":"Keyword","value":"while"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"param2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"!="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"0"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"Name","value":"param2"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"-="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"1"},
|
|
{"type":"Text","value":"\n\n "},
|
|
{"type":"Keyword","value":"match"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"param3"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"NameBuiltin","value":"print"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringDouble","value":"\"param3 is 3!\""},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"Name","value":"_"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"NameBuiltin","value":"print"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringDouble","value":"\"param3 is not 3!\""},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n "},
|
|
{"type":"KeywordDeclaration","value":"var"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"local_var"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"param1"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"+"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"3"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"Keyword","value":"return"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"local_var"},
|
|
{"type":"Text","value":"\n\n\n"},
|
|
{"type":"CommentSingle","value":"# Functions override functions with the same name on the base/super class."},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"CommentSingle","value":"# If you still want to call them, use \"super\":"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"func"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"something"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"p1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"p2"},
|
|
{"type":"Punctuation","value":"):"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"Keyword","value":"super"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"p1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"p2"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n\n"},
|
|
{"type":"CommentSingle","value":"# It's also possible to call another function in the super class:"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"func"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"other_something"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"p1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"p2"},
|
|
{"type":"Punctuation","value":"):"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"Keyword","value":"super"},
|
|
{"type":"Operator","value":"."},
|
|
{"type":"NameFunction","value":"something"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"p1"},
|
|
{"type":"Punctuation","value":","},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"p2"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n\n\n"},
|
|
{"type":"CommentSingle","value":"# Inner class"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"class"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameClass","value":"Something"},
|
|
{"type":"Punctuation","value":":"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"KeywordDeclaration","value":"var"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"a"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"LiteralNumberInteger","value":"10"},
|
|
{"type":"Text","value":"\n\n\n"},
|
|
{"type":"CommentSingle","value":"# Constructor"},
|
|
{"type":"Text","value":"\n"},
|
|
{"type":"KeywordDeclaration","value":"func"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"NameFunction","value":"_init"},
|
|
{"type":"Punctuation","value":"():"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"NameBuiltin","value":"print"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"LiteralStringDouble","value":"\"Constructed!\""},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"KeywordDeclaration","value":"var"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"lv"},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Operator","value":"="},
|
|
{"type":"Text","value":" "},
|
|
{"type":"Name","value":"Something"},
|
|
{"type":"Operator","value":"."},
|
|
{"type":"NameFunction","value":"new"},
|
|
{"type":"Punctuation","value":"()"},
|
|
{"type":"Text","value":"\n "},
|
|
{"type":"NameBuiltin","value":"print"},
|
|
{"type":"Punctuation","value":"("},
|
|
{"type":"Name","value":"lv"},
|
|
{"type":"Operator","value":"."},
|
|
{"type":"Name","value":"a"},
|
|
{"type":"Punctuation","value":")"},
|
|
{"type":"Text","value":"\n"}
|
|
]
|