2023-08-22 21:02:40 +00:00
|
|
|
module.exports = grammar({
|
|
|
|
name: 'Dust',
|
|
|
|
|
|
|
|
rules: {
|
|
|
|
source_file: $ => repeat(choice($.comment, $.expression)),
|
|
|
|
|
2023-08-22 21:28:19 +00:00
|
|
|
identifier: $ => /[a-zA-Z|_|.]+(_[a-zA-Z]+)*/,
|
|
|
|
|
2023-08-22 21:02:40 +00:00
|
|
|
comment: $ => /(#)(.+?)([\n\r])/,
|
|
|
|
|
|
|
|
expression: $ => choice(
|
2023-08-22 21:28:19 +00:00
|
|
|
$.identifier,
|
|
|
|
seq($.identifier, $.operator, $.identifier)
|
|
|
|
|
2023-08-22 21:02:40 +00:00
|
|
|
),
|
|
|
|
|
|
|
|
operator: $ => choice(
|
|
|
|
'=',
|
2023-08-22 21:28:19 +00:00
|
|
|
'-',
|
|
|
|
'+',
|
|
|
|
';',
|
|
|
|
'/',
|
|
|
|
'|',
|
|
|
|
'&'
|
2023-08-22 21:02:40 +00:00
|
|
|
),
|
|
|
|
|
|
|
|
integer: $ => /\d/,
|
|
|
|
}
|
|
|
|
});
|