diff --git a/LANGUAGES.md b/LANGUAGES.md index 2458b3955..ad42d0f2a 100644 --- a/LANGUAGES.md +++ b/LANGUAGES.md @@ -4,6 +4,7 @@ ABNF (abnf) ActionScript (as) Ada (ada,adb,ads,pad) Agda (agda) +AL (al) Alchemist (crn) Alex (x) Algol 68 (a68) diff --git a/examples/language/al.al b/examples/language/al.al new file mode 100644 index 000000000..17c1b97ce --- /dev/null +++ b/examples/language/al.al @@ -0,0 +1,35 @@ +/* AL is the language of Microsoft Dynamics 365 Business Central. + This block comment spans three lines and should be counted + as three comment lines. */ + +namespace MyCompany.Sales; + +using Microsoft.Foundation; + +table 50100 "My Table" +{ + // a standalone line comment + fields + { + field(1; Name; Text[50]) + { + Caption = 'Name'; + } + } + + procedure Compute(Value: Decimal): Decimal + var + Total: Decimal; + Note: Text; + begin + Total := Value * 2; // double it + IF Total > 100 THEN // legacy upper case AL + Total := 100; + Note := 'It''s at https://example.com'; + Note := 'not /* a comment */ either'; + Note := '// not a comment either'; + while Total > 200 do + Total -= 1; + exit(Total); + end; +} diff --git a/languages.json b/languages.json index 47a13e00c..8eb2890e1 100644 --- a/languages.json +++ b/languages.json @@ -25,6 +25,13 @@ "multi_line": [], "quotes": [] }, + "AL": { + "complexitychecks": ["if ", "if(", "IF ", "IF(", "case ", "CASE ", "while ", "WHILE ", "for ", "FOR ", "foreach ", "FOREACH ", "until ", "UNTIL ", "else ", "ELSE ", "and ", "AND ", "or ", "OR ", "xor ", "XOR ", "not ", "NOT "], + "extensions": ["al"], + "line_comment": ["//"], + "multi_line": [["/*", "*/"]], + "quotes": [{"end": "'", "start": "'"}] + }, "Apex": { "complexitychecks": [ "for ", diff --git a/main_test.go b/main_test.go index ef478bbba..27b5d0204 100644 --- a/main_test.go +++ b/main_test.go @@ -835,6 +835,7 @@ func TestLanguageNameTruncate(t *testing.T) { func TestSpecificLanguages(t *testing.T) { languages := [...]string{ "ABNF", + "AL", "Alchemist", "Algol 68", "Alloy", diff --git a/processor/constants.go b/processor/constants.go index fd4078721..4340cd0c1 100644 --- a/processor/constants.go +++ b/processor/constants.go @@ -55,6 +55,60 @@ var languageDatabase = map[string]Language{ FileNames: []string{}, SheBangs: []string{}, }, + "AL": { + LineComment: []string{ + "//", + }, + ComplexityChecks: []string{ + "if ", + "if(", + "IF ", + "IF(", + "case ", + "CASE ", + "while ", + "WHILE ", + "for ", + "FOR ", + "foreach ", + "FOREACH ", + "until ", + "UNTIL ", + "else ", + "ELSE ", + "and ", + "AND ", + "or ", + "OR ", + "xor ", + "XOR ", + "not ", + "NOT ", + }, + Extensions: []string{ + "al", + }, + ExtensionFile: false, + MultiLine: [][]string{ + { + "/*", + "*/", + }, + }, + Quotes: []Quote{ + { + Start: "'", + End: "'", + IgnoreEscape: false, + DocString: false, + }, + }, + NestedMultiLine: false, + Keywords: []string{}, + Heuristics: []Heuristic{}, + FileNames: []string{}, + SheBangs: []string{}, + }, "APL": { LineComment: []string{ "⍝",