1
0
mirror of https://github.com/alecthomas/chroma.git synced 2025-01-26 03:20:10 +02:00

fix: C++ comments after #include

Fixes #841
This commit is contained in:
Alec Thomas 2023-09-09 13:07:35 +10:00
parent 40542a6255
commit c4527e8d5c
7 changed files with 426 additions and 421 deletions

View File

@ -13,11 +13,11 @@ tokentype_string.go: types.go
go generate
chromad:
rm -f chromad
rm -rf build
esbuild --bundle cmd/chromad/static/index.js --minify --outfile=cmd/chromad/static/index.min.js
esbuild --bundle cmd/chromad/static/index.css --minify --outfile=cmd/chromad/static/index.min.css
(export CGOENABLED=0 ; cd ./cmd/chromad && go build -ldflags="-X 'main.version=$(VERSION)'" -o ../../chromad .)
(export CGOENABLED=0 ; cd ./cmd/chromad && go build -ldflags="-X 'main.version=$(VERSION)'" -o ../../build/chromad .)
upload: chromad
scp chromad root@swapoff.org: && \
upload: build/chromad
scp build/chromad root@swapoff.org: && \
ssh root@swapoff.org 'install -m755 ./chromad /srv/http/swapoff.org/bin && service chromad restart'

1
bin/.svu-1.11.0.pkg Symbolic link
View File

@ -0,0 +1 @@
hermit

1
bin/svu Symbolic link
View File

@ -0,0 +1 @@
.svu-1.11.0.pkg

View File

@ -84,7 +84,7 @@
</rule>
</state>
<state name="macro">
<rule pattern="(include)(\s*(?:/[*].*?[*]/\s*)?)([^\n]+)">
<rule pattern="(include)(\s+)(&quot;[^&quot;]+?&quot;|&lt;[^&gt;]+?&gt;)">
<bygroups>
<token type="CommentPreproc"/>
<token type="Text"/>

View File

@ -1,5 +1,5 @@
#include "a"
#include <b>
#include "a" // comment
#include <b> // comment
[[nodiscard]] void foo() noexcept;
void foo();

View File

@ -2,10 +2,13 @@
{"type":"CommentPreproc","value":"#include"},
{"type":"Text","value":" "},
{"type":"CommentPreprocFile","value":"\"a\""},
{"type":"CommentPreproc","value":"\n#include"},
{"type":"CommentPreproc","value":" "},
{"type":"CommentSingle","value":"// comment\n"},
{"type":"CommentPreproc","value":"#include"},
{"type":"Text","value":" "},
{"type":"CommentPreprocFile","value":"\u003cb\u003e"},
{"type":"CommentPreproc","value":"\n"},
{"type":"CommentPreproc","value":" "},
{"type":"CommentSingle","value":"// comment\n"},
{"type":"Text","value":"\n"},
{"type":"NameAttribute","value":"[[nodiscard]]"},
{"type":"Text","value":" "},

View File

@ -1,414 +1,414 @@
[
{"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"}
{"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"}
]