Update ats syntax (#1141)

* Multiple changes
 - Fixed overlapping between the macros and some statements.
 - Added "t" and "abs" as types.
 - Removed "fun0", "fun1", "clo0", "clo1", ..., "prf" from types and added them to the special block as effects.
 - Added "lin", "lincloptr0" and "lincloptr1" as effects.
 - Added "do" and "static" as statements.
 - Added "tupz!" and "prerr!" to the special block.
 - Fixed some typos.

* Updated regex for exhaustive types

* Final touches

* Removed "t" from types

* Minor fix

* Improved support for floats and integers
Make it comply with https://github.com/Hibou57/PostiATS-Utilities/blob/master/doc/lexemes-guide.md

* Chars are now interpreted as strings
Less troubling when working with '"' inside chars or multiline strings

* Reverted strings and chars from multiline to one line
For some reason, having strings on the same line as other symbols breaks the highlighting on the latter

* Add "ldouble" type
This commit is contained in:
djmnzp 2018-07-16 21:37:57 +02:00 committed by Zachary Yedidia
parent 7a013f666e
commit 8a250f7d95

View File

@ -6,58 +6,55 @@ detect:
rules:
- default: \b[[:alnum:]]+[^0-9A-Za-z]
# Some C macros and other ATS macros
- preproc: ^[[:space:]]*#[[:space:]]*(define|pragma|include|(un|ifn?)def|endif|el(if|se)|if|warning|error|assert)\b
- preproc: ^[[:space:]]*#[[:space:]]*(codegen2|codegen3|elifdef|elifndef|prerr|print|require|then|staload|dynload)\b
# Operators
- symbol.operator: "[.:;+`|~<>?='\\&]|/|%|-|,|!|\\*|@|\\#"
- symbol.operator: \^
# Types, abstract types and some predefined sorts
- type: \b(addr|age?z|bool|char|cls|schar|uchar|double|eff|exn|float|int(ptr)?|lincloptr|uint)\b
- type: \b(lint|ulint|llint|ullint|nat|prop|ptr|prf|real|ref|size_t|ssize_t|sint|usint|string|tkind|viewt|view|v?t0p|vt|void)\b
- type: \b(fun[01]|cloptr(0|1)?|cloref(0|1)?|clo(0|1)?)\b
- type: \b(prop[+-]|t[@0]ype[+-]?|type[+-]?|viewt[@0]ype[+-]?|viewtype[+-]?|vt[@0]ype[+-]?|vtype[+-]?|view[+-]?)
- type: \b(addr|age?z|bool|char|cls|schar|uchar|double|ldouble|eff|exn|float|int(ptr)?|lincloptr|uint)\b
- type: \b(lint|ulint|llint|ullint|nat|ptr|real|ref|size_t|ssize_t|sint|usint|string|tkind|viewt|v?t0p|vt|void)\b
- type: \b(prop|t[@0]ype|type|viewt[@0]ype|viewtype|vt[@0]ype|vtype|view)\b
- type: \b(prop[+-]|t[@0]ype[+-]|type[+-]|viewt[@0]ype[+-]|viewtype[+-]|vt[@0]ype[+-]|vtype[+-]|view[+-])
# Statements
- statement: \b(abstype|abst|absprop|absviewt|absvt(ype)?|absview|and|andalso|as|(re)?assume|begin|(pr)?csase|s?case)\b
- statement: \b(classdec|dataprop|data(v|view)?type|dataview|datasort|else|end|exception|extype|extvar|s?if)\b
- statement: \b(ifcase|for|in|infix(l|r)?|let|local|macrodef|macdef|not|of|op|or|orelse|overload|(pre|post|non)fix)\b
- statement: \b(propdef|rec|sortdef|stacst|stadef|stavar|sta|symelim|symintr|tkindef|then|try|viewdef|v?typedef)\b
- statement: \b(abstype|abst|absprop|absviewt|absvt(ype)?|absview|and|andalso|as|(re)?assume|begin|(pr)?case|s?case)\b
- statement: \b(classdec|dataprop|data(v|view)?type|dataview|datasort|do|dynload|else|end|exception|extype|extva(r|l)|s?if)\b
- statement: \b(ifcase|import|for|in|infix(l|r)?|let|local|macrodef|macdef|not|of|op|or|orelse|overload|(pre|post|non)fix)\b
- statement: \b(propdef|rec|sortdef|stacst|stadef|staload|stavar|sta(tic)?|symelim|symintr|tkindef|then|try|viewdef|v?typedef)\b
- statement: \b(viewtypedef|(pr)?va(l|r)|when|where|while|with|withtype|withprop|withv(iew)?type|withview)\b
- statement: \b(abst[@0]ype|absviewt[@0]ype|absviewtype|absvt[@0]ype)\b
- statement: \b(import|staload|dynload)\b
- statement: \b(abst[@0]ype|absviewt[@0]?ype|absvt[@0]ype|abstbox|abstflat|absvtbox|absvtflat|absimpl|absreimpl|abs)\b
- statement: \b(case[+-]|(pr)?va(l|r)[+-]|for\*|while\*)
# Added in ATS2 0.3.11
- statement: \b(abstbox|abstflat|absvtbox|absvtflat)\b
- statement: \b(absimpl|absreimpl)\b
# Numbers
- constant.number: (\b[0-9]+\b|\b0(x|b)[0-9A-Fa-f]+\b)
- constant.number: \b[0-9]+(u|U|l|L|ul|UL|f|F|b|B)?\b
- constant.number: \b[0-9.]+([eE][+-]?[0-9]+)?[fFlL]?\b
- constant.number: \b0[xX][0-9A-Fa-f]*(\.[0-9A-Fa-f]*)?[pP][+-]?[0-9]+[fFlL]?\b
- constant.number: \b([0-9]+|0[xX][0-9A-Fa-f]+)[lLuU]*\b
# Function-related keywords, special functions and namespaces. Not really identifiers
- identifier: \b(fix|(pr)?fu?n|fnx|castfn|praxi|extern|lam|llam|(pr)?implement|(pr)?implmnt)\b
- identifier: \b(fix@|fold@|free@|lam@|llam@|addr@|view@|ref@)
- identifier: \b(fn\*)
- identifier: \b(fix@|fold@|free@|lam@|llam@|addr@|view@|ref@|fn\*)
- identifier: \$\w*\b
# Other keywords, function effects...
- special: (\$(arrpsz|arrptrsize|break|continue|d2ctype|delay|effmask_(ntm|exn|ref|wrt|all)))\b
- special: (\$(effmask|extern|extype_struct|extype|extkind|extval|extfcall|extmcall|ldelay|literal))\b
- special: (\$(li?st_vt|li?st_t|li?st|myfilename|myfunction|mylocation|raise|rec(ord)?_vt))\b
- special: (\$(rec(ord)?_t|rec(ord)?|(r|l)par|sep|showtype|solver_assert|solver_verify|tempenver))\b
- special: (\$(rec(ord)?_t|rec(ord)?|showtype|solver_assert|solver_verify|tempenver))\b
- special: (\$(tup(le)?_vt|tup(le)?_t|tup(le)?|tyrep|vararg|vcopyenv_vt|vcopyenv_v))\b
- special: \!(wrt|exnref|exnwrt|exn|refwrt|ref|all|ntm|laz)\b
- special: \b(f?print(ln)?!|prerrln!)
- special: \b(fun(0|1)|(lin)?cloptr(0|1)?|cloref(0|1)?|clo(0|1)?|lin|prf)\b
- special: \b(f?print(ln)?!|prerr(ln)?!|tupz!)
# Some C macros and other ATS macros
- preproc: ^[[:space:]]*#[[:space:]]*(define|pragma|include|(un|ifn?)def|endif|el(if|se)|if|warning|error|assert)\b
- preproc: ^[[:space:]]*#[[:space:]]*(codegen2|codegen3|elifdef|elifndef|prerr|print|require|then|staload|dynload)\b
# Boolean values
- constant.bool: \b(true|false|null)\b
# The "%{ ... %}" block inserts foreign code into ATS at compile-time
# Code inside it is generally C or JavaScript
# Code inside of it is generally C or JavaScript
- default:
start: "%{[#^$]?"
end: "%}"
@ -69,19 +66,12 @@ rules:
# Strings and chars
- constant.string:
start: \"
end: \"
skip: \\.
rules:
- constant.specialChar: \\.
- constant.char: ('\\?.')
- constant.string: \"[^"]*\"
- constant.string: \'[^']*\'
# Comments
# "////" comments everything until EOF
# "////" comments everything until it reaches EOF
- comment.block:
start: ////
end: $a