Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add language: LPC #7179

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,9 @@
[submodule "vendor/grammars/logtalk.tmbundle"]
path = vendor/grammars/logtalk.tmbundle
url = https://github.com/textmate/logtalk.tmbundle
[submodule "vendor/grammars/lpc-language-server"]
path = vendor/grammars/lpc-language-server
url = https://github.com/jlchmura/lpc-language-server.git
[submodule "vendor/grammars/lua.tmbundle"]
path = vendor/grammars/lua.tmbundle
url = https://github.com/LuaLS/lua.tmbundle.git
Expand Down
3 changes: 3 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,9 @@ vendor/grammars/logos:
- source.logos
vendor/grammars/logtalk.tmbundle:
- source.logtalk
vendor/grammars/lpc-language-server:
- documentation.injection.lpc
- source.lpc.lang-server
vendor/grammars/lua.tmbundle:
- source.lua
vendor/grammars/m3:
Expand Down
10 changes: 10 additions & 0 deletions lib/linguist/heuristics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ disambiguations:
rules:
- language: XML
pattern: '^(\s*)(?i:<Project|<Import|<Property|<?xml|xmlns)'
- extensions: ['.c']
rules:
- language: LPC
named_pattern: lpc
negative_pattern: '(?i)([ \t]*(unsigned|uint|enum)|^\s*\*[A-Za-z]|([A-Za-z][A-Za-z0-9_]*\[\]))'
- language: C
- extensions: ['.cairo']
rules:
- language: Cairo Zero
Expand Down Expand Up @@ -347,6 +353,9 @@ disambiguations:
named_pattern: objectivec
- language: C++
named_pattern: cpp
- language: LPC
named_pattern: lpc
negative_pattern: '(?i)([ \t]*(unsigned|uint|enum|extern|pragma mark|__inline__)|\s*\*\(|^\s*\*[A-Za-z]|([A-Za-z][A-Za-z0-9_]*\[\]))'
- language: C
- extensions: ['.hh']
rules:
Expand Down Expand Up @@ -947,6 +956,7 @@ named_patterns:
- '^[ \t]*#[ \t]*(?:precache|using_animtree)[ \t]*\('
json: '\A\s*[{\[]'
key_equals_value: '^[^#!;][^=]*='
lpc: '(mixed|nosave|clone_object)|(this_player\(\))|(^inherit [\"A-Za-z][A-Za-z0-9_]*)|(((public|private|protected)\s+)?((varargs|nomask|noshadow)+\s+)?((string|int|mixed|object|mapping)\s+)?[A-Za-z][A-Za-z0-9_]*\()'
m68k:
- '(?im)\bmoveq(?:\.l)?\s+#(?:\$-?[0-9a-f]{1,3}|%[0-1]{1,8}|-?[0-9]{1,3}),\s*d[0-7]\b'
- '(?im)^\s*move(?:\.[bwl])?\s+(?:sr|usp),\s*[^\s]+'
Expand Down
9 changes: 9 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3780,6 +3780,15 @@ LOLCODE:
tm_scope: source.lolcode
ace_mode: text
language_id: 192
LPC:
type: programming
extensions:
- ".c"
- ".h"
tm_scope: source.lpc.lang-server
ace_mode: c_cpp
language_id: 397797394
color: "#ffb100"
LSL:
type: programming
tm_scope: source.lsl
Expand Down
4 changes: 4 additions & 0 deletions samples/LPC/area_env.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

public string query_label() {
return "Area Label";
}
7 changes: 7 additions & 0 deletions samples/LPC/array2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
string* arr = ({ "a", "b", "c" });
test() {
arr += ({ "d" });
// should always allow subtracting 0 elements
arr -= ({ 0 });
arr -= ({ "a" });
}
7 changes: 7 additions & 0 deletions samples/LPC/callOther3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
test() {
/** @type {"object.c"*} */
object *o = ({});

// call other on an array is legal in fluffos
o->query_number();
}
8 changes: 8 additions & 0 deletions samples/LPC/closures.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test() {
int *arr = ({1, 2, 3});
int *i = filter(arr, (: $1 > 1 :));
}

private object *apply_custom_filter(object *obs, function f, object tp) {
return filter(obs, (: (*$(f))($1, $(tp)) :)) ;
}
Loading