epics-extensions / tree-sitter-epics Goto Github PK
View Code? Open in Web Editor NEWParsers for various EPICS-specific syntaxes
License: MIT License
Parsers for various EPICS-specific syntaxes
License: MIT License
line:
dbpf toto 8 # this is a comment
tree-sitter message:
MISSING "\n"
fix:
dbpf toto 8
# this is a comment
In my opinion, this should be allowed
end of my cmd file:
``
#=================================================================
tree-sitter messgae:
MISSING "\n"
fix:
``
#=================================================================
#
module should accept that last line is a comment (but it should not accept something else). IEE .cmd template finishes with '#'
line:
dbpf $(SYS)-$(EVR):DlyGen1-Polarity-Sel 1
tree-sitter message
(ERROR [118, 0] - [122, 17]
(command_name [118, 0] - [118, 4]
(word [118, 0] - [118, 4]))
(macro_expansion [118, 5] - [118, 11])
(argument [118, 11] - [118, 12]
(word [118, 11] - [118, 12]))
(macro_expansion [118, 12] - [118, 18])
(argument [118, 18] - [118, 39]
(word [118, 18] - [118, 39]))
(ERROR [118, 40] - [120, 9]
(file_descriptor [118, 40] - [118, 41])
fix
dbpf $(SYS)-$(EVR):DlyGen1-Polarity-Sel "1"
# or
dbpf $(SYS)-$(EVR):DlyGen1-Polarity-Sel 1.0
lines:
getEnable{
out "\$1\$2\$3.\$4bEnable?";
in "%{0|1}";
}
tree-sitter message:
$ tree-sitter parse --stat $file
(source_file [0, 0] - [3, 1]
(function [0, 0] - [3, 1]
(function_name [0, 0] - [0, 9])
(command [1, 4] - [1, 32]
(command_name [1, 4] - [1, 7])
(string [1, 8] - [1, 31]
(ERROR [1, 9] - [1, 30]
(number_literal [1, 11] - [1, 12])
(number_literal [1, 14] - [1, 15])
(number_literal [1, 17] - [1, 18])
(number_literal [1, 21] - [1, 22])
(ERROR [1, 24] - [1, 26])
(ERROR [1, 27] - [1, 28]))))
(command [2, 4] - [2, 16]
(command_name [2, 4] - [2, 6])
(string [2, 7] - [2, 15]
(ERROR [2, 8] - [2, 14]
(checksum_flag [2, 10] - [2, 11])
(number_literal [2, 12] - [2, 13]))))))
FB_DriveVirtual_v1_01.proto 0 ms (ERROR [1, 9] - [1, 30])
Total parses: 1; successful parses: 0; failed parses: 1; success percentage: 0.00%
lines:
toto( ${pollMsec})
toto( "${pollMsec}")
toto( "${pollMsec}", "tata")
toto( ${pollMsec}, "tata")
tree-sitter message:
$ tree-sitter parse --stat $file
(source_file [0, 0] - [4, 0]
(command [0, 0] - [0, 18]
name: (command_name [0, 0] - [0, 4]
(word [0, 0] - [0, 4]))
(macro_expansion [0, 6] - [0, 17]))
(command [1, 0] - [1, 20]
name: (command_name [1, 0] - [1, 4]
(word [1, 0] - [1, 4]))
(argument [1, 6] - [1, 19]
(string [1, 6] - [1, 19]
(macro_expansion [1, 7] - [1, 18]))))
(command [2, 0] - [2, 28]
name: (command_name [2, 0] - [2, 4]
(word [2, 0] - [2, 4]))
(argument [2, 6] - [2, 19]
(string [2, 6] - [2, 19]
(macro_expansion [2, 7] - [2, 18])))
(argument [2, 21] - [2, 27]
(string [2, 21] - [2, 27])))
(command [3, 0] - [3, 28]
name: (command_name [3, 0] - [3, 4]
(word [3, 0] - [3, 4]))
(macro_expansion [3, 6] - [3, 17])
(ERROR [3, 17] - [3, 18])
(argument [3, 21] - [3, 27]
(string [3, 21] - [3, 27]))))
mifile.cmd 0 ms (ERROR [3, 17] - [3, 18])
Total parses: 1; successful parses: 0; failed parses: 1; success percentage: 0.00%
fix:
toto( ${pollMsec})
toto( "${pollMsec}")
toto( "${pollMsec}", "tata")
toto( "${pollMsec}", "tata")
Please note that ioc works without these quotes.
This may be impossible to fix but I write it down here for next similar cases.
lines:
program SequenceLoad
ss ss3
{
state idle
{
when (pvConnectCount() != pvAssignCount()){
} state idle
}
}
tree-sitter message:
$ tree-sitter parse --stat SequenceLoad.st
(source_file [0, 0] - [9, 0]
(program [0, 0] - [8, 1]
name: (identifier [0, 8] - [0, 20])
(state_set [1, 0] - [8, 1]
name: (identifier [1, 3] - [1, 6])
(state [3, 4] - [7, 5]
name: (identifier [3, 10] - [3, 14])
(state_block [4, 4] - [7, 5]
(transition [5, 12] - [6, 24]
condition: (binary_expression [5, 18] - [5, 53]
left: (call_expression [5, 18] - [5, 34]
function: (identifier [5, 18] - [5, 32])
(args [5, 33] - [5, 33]
(true [5, 33] - [5, 33])))
right: (call_expression [5, 38] - [5, 53]
function: (identifier [5, 38] - [5, 51])
(args [5, 52] - [5, 52]
(true [5, 52] - [5, 52]))))
(block [5, 54] - [6, 13])
name: (identifier [6, 20] - [6, 24])))))))
SequenceLoad.st 0 ms (MISSING true [5, 33] - [5, 33])
Total parses: 1; successful parses: 0; failed parses: 1; success percentage: 0.00%
fix:
program SequenceLoad
ss ss3
{
state idle
{
when (pvConnectCount(true) != pvAssignCount(true)){
} state idle
}
}
when (pvConnectCount() != pvAssignCount()){
should be accepted: source
lines
record(stringin, "${SIGNAL}-CAL-NNAM") {
field(INP, "$(NNAM_PV=${SIGNAL}-NNAM CPP)")
}
tree-sitter message:
$ tree-sitter parse --stat $file
(source_file [0, 0] - [4, 0]
(record_instance [0, 0] - [2, 1]
type: (record_type [0, 7] - [0, 15])
name: (record_name [0, 17] - [0, 37]
(macro_expansion [0, 18] - [0, 27])
(string_text_fragment [0, 27] - [0, 36]))
(field [1, 4] - [1, 48]
name: (field_name [1, 10] - [1, 13])
value: (string [1, 16] - [1, 47]
(macro_expansion [1, 17] - [1, 46]
(ERROR [1, 35] - [1, 45]
(ERROR [1, 36] - [1, 45])))))))
calibPolynom.template 0 ms (ERROR [1, 35] - [1, 45])
Total parses: 1; successful parses: 0; failed parses: 1; success percentage: 0.00%
fix:
remove macro in macro 😄
line
dbl > pvlist_${IOCNAME}.dbl
tree-sitter message:
(ERROR [56, 0] - [56, 13])
(macro_expansion [56, 13] - [56, 23])
(ERROR [56, 23] - [57, 17])
fix:
dbl > "pvlist_${IOCNAME}.dbl"
could you accept that the redirection is not between quotes ?
lines:
file myDBfile.template {
pattern { PREFIX, SCAN }
{ ${ PREFIX } "1 second"}
{ ${ PREFIX } "3 second"}
}
tree-sitter message:
$ tree-sitter parse --stat $file
(source_file [0, 0] - [5, 0]
(db_template [0, 0] - [4, 1]
file: (string [0, 5] - [0, 13])
(ERROR [0, 13] - [0, 22]
(ERROR [0, 13] - [0, 22]))
(substitutions [0, 23] - [4, 1]
(pattern [1, 4] - [3, 37]
(pattern_variables [1, 12] - [1, 32]
(identifier [1, 14] - [1, 20])
(identifier [1, 26] - [1, 30]))
(pattern_values [2, 12] - [2, 37]
(macro_expansion [2, 14] - [2, 25])
(string [2, 26] - [2, 36]
(quoted_string [2, 26] - [2, 36]
(quoted_string_text_fragment [2, 27] - [2, 35]))))
(pattern_values [3, 12] - [3, 37]
(macro_expansion [3, 14] - [3, 25])
(string [3, 26] - [3, 36]
(quoted_string [3, 26] - [3, 36]
(quoted_string_text_fragment [3, 27] - [3, 35]))))))))
iocMebt.substitutions 0 ms (ERROR [0, 13] - [0, 22])
Total parses: 1; successful parses: 0; failed parses: 1; success percentage: 0.00%
fix: remove extension from myDBfile.template
lines:
file x.template {
pattern {P BPM-1}
{"${P_GSCAN}" myNickname1}
{"${P_GSCAN}" myNickname2}
}
tree-sitter-epics output:
$ tree-sitter parse --stat --scope source.epics.msi_substitution test.sub
(source_file [0, 0] - [5, 1]
(db_template [0, 0] - [5, 1]
file: (string [0, 5] - [0, 15])
(substitutions [0, 16] - [5, 1]
(pattern [1, 4] - [3, 51]
(pattern_variables [1, 12] - [1, 34]
(identifier [1, 13] - [1, 14])
(identifier [1, 28] - [1, 31])
(ERROR [1, 31] - [1, 33]
(ERROR [1, 31] - [1, 33])))
(pattern_values [2, 12] - [2, 51]
(string [2, 13] - [2, 25]
(quoted_string [2, 13] - [2, 25]
(macro_expansion [2, 14] - [2, 24])))
(string [2, 28] - [2, 50]))
(pattern_values [3, 12] - [3, 51]
(string [3, 13] - [3, 25]
(quoted_string [3, 13] - [3, 25]
(macro_expansion [3, 14] - [3, 24])))
(string [3, 28] - [3, 50]))))))
test.sub 0 ms (ERROR [1, 31] - [1, 33])
Total parses: 1; successful parses: 0; failed parses: 1; success percentage: 0.00%
fix: remove '-' character in macro name (BPM-1
)
lines:
record(longin, "${P=}${FCT=Core}Dimension") {
field(HOPR, ${INF=65535})
}
tree-sitter message:
$ tree-sitter parse --stat $file
(source_file [0, 0] - [2, 1]
(record_instance [0, 0] - [2, 1]
type: (record_type [0, 7] - [0, 13])
name: (record_name [0, 15] - [0, 42]
(macro_expansion [0, 16] - [0, 21])
(macro_expansion [0, 21] - [0, 32])
(string_text_fragment [0, 32] - [0, 41]))
(field [1, 4] - [1, 29]
name: (field_name [1, 10] - [1, 14])
(macro_expansion [1, 16] - [1, 28])
value: (json_value [1, 28] - [1, 28]))))
gscan_core.template 0 ms (MISSING "null" [1, 28] - [1, 28])
Total parses: 1; successful parses: 0; failed parses: 1; success percentage: 0.00%
fix:
record(longin, "${P=}${FCT=Core}Dimension") {
field(HOPR, "${INF=65535}")
}
We already talk about this case. I know it is complicated to solve. I just note it here for next case.
lines:
program editSseq
#include <seq_release.h>
ss ss3
{
state idle
{
when (pvConnectCount(true) != pvAssignCount(true)){
} state idle
}
}
tree-sitter-message:
$ tree-sitter parse --stat -- quiet $file
(source_file [0, 0] - [10, 0]
(ERROR [0, 0] - [0, 16]
(identifier [0, 8] - [0, 16]))
(preproc_include [1, 0] - [2, 0]
path: (system_lib_string [1, 9] - [1, 24]))
(ERROR [2, 0] - [9, 1]
(line_number [2, 5] - [2, 6])
(ERROR [4, 10] - [4, 14])
(ERROR [6, 14] - [6, 28])
(true [6, 29] - [6, 33])
(ERROR [6, 38] - [6, 41])
(ERROR [6, 43] - [6, 51])
(true [6, 52] - [6, 56])
(ERROR [7, 16] - [7, 20])))
editSseq.st 0 ms (ERROR [0, 0] - [0, 16])
Total parses: 1; successful parses: 0; failed parses: 1; success percentage: 0.00%
fix:
program editSseq
%%#include <seq_release.h>
ss ss3
{
state idle
{
when (pvConnectCount(true) != pvAssignCount(true)){
} state idle
}
}
the error indicates the lines 0 but the issue is on line 1, "%%" is missing. It is possible to have a better message for this case. It took me some time to understand that the issue was the missing %%
List of characters not accepted by tree-sitter-epics
but works in IOC (in my case for EGU
field:
µ
for µA
°
for °C
%
for percentagePlease note that if I put these specials characters inside quotes, tree-sitter-epics
is happy.
file "x.template"
{
pattern
{ SIGNAL, EGU}
{ MY_PREFIX, µA }
}
file "x.template"
{
pattern
{ SIGNAL, EGU}
{ MY_PREFIX, °C }
}
file "x.template"
{
pattern
{ SIGNAL, EGU}
{ MY_PREFIX, % }
}
It would be awesome if the parser included dbd grammar parsing.
DBD SYNTAX SUMMARY:
path "path"
addpath "path"
include "filename"
#comment
menu(name) {
include "filename" choice(choice_name, "choice_value")
...
}
recordtype(record_type) {}
recordtype(record_type) {
include "filename"
field(field_name, field_type) {
asl(asl_level)
initial("init_value")
promptgroup("group_name")
prompt("prompt_value")
special(special_value)
pp(pp_value)
interest(interest_level)
base(base_type)
size(size_value)
extra("extra_info")
menu(name)
prop(yesno)
}
%C_declaration
...
}
device(record_type, link_type, dset_name, "choice_string")
driver(drvet_name)
registrar(function_name)
variable(variable_name)
breaktable(name) {
raw_value eng_value
...
}
lines:
get_current
{
out ":CURR?";
in "%f";
}
set_current
{
out ":CURR %f";
@init { get_current };
}
tree-sitter message:
$ tree-sitter parse --stat $file
(source_file [0, 0] - [11, 0]
(function [0, 0] - [4, 1]
(function_name [0, 0] - [0, 11])
(command [2, 4] - [2, 17]
(command_name [2, 4] - [2, 7])
(string [2, 8] - [2, 16]))
(command [3, 4] - [3, 13]
(command_name [3, 4] - [3, 6])
(string [3, 8] - [3, 12]
(format_converter [3, 9] - [3, 11]))))
(function [6, 0] - [10, 1]
(function_name [6, 0] - [6, 11])
(command [8, 4] - [8, 19]
(command_name [8, 4] - [8, 7])
(string [8, 8] - [8, 18]
(format_converter [8, 15] - [8, 17])))
(handler [9, 4] - [10, 1]
(handler_name [9, 5] - [9, 9])
(function_name [9, 12] - [9, 23])
(ERROR [9, 24] - [9, 25]))))
tdkLambdaGenesys.proto 0 ms (ERROR [9, 24] - [9, 25])
Total parses: 1; successful parses: 0; failed parses: 1; success percentage: 0.00%
Changing to @init { get_current };
makes tree-sitter happy but I don't know if it works (I don't have a streamdevice ioc running to test it)
I don't know if you are going to laugh or cry for this one.
line:
Asyn${project}DrvrConfigure()
tree-sitter message:
$ tree-sitter parse --stat $file
(source_file [0, 0] - [1, 0]
(command [0, 0] - [0, 29]
name: (command_name [0, 0] - [0, 4]
(word [0, 0] - [0, 4]))
(macro_expansion [0, 4] - [0, 14])
(ERROR [0, 14] - [0, 27]
(word [0, 14] - [0, 27]))))
file.cmd 0 ms (ERROR [0, 14] - [0, 27])
Total parses: 1; successful parses: 0; failed parses: 1; success percentage: 0.00%
fix:
AsynMyProjectDrvrConfigure()
line:
getKV {
out STX, "14,", ETX;
in STX, "14,%i,", ETX;
}
tree-sitter message:
$ tree-sitter parse --stat spellman_SLxPNx.proto
(source_file [0, 0] - [4, 0]
(function [0, 0] - [3, 1]
(function_name [0, 0] - [0, 5])
(command [1, 1] - [1, 21]
(command_name [1, 1] - [1, 4])
(number [1, 5] - [1, 8]
(ascii_name [1, 5] - [1, 8]))
(ERROR [1, 8] - [1, 9]
(ERROR [1, 8] - [1, 9]))
(string [1, 10] - [1, 15])
(ERROR [1, 15] - [1, 20]
(ERROR [1, 15] - [1, 16])))
(command [2, 1] - [2, 24]
(command_name [2, 1] - [2, 3])
(number [2, 5] - [2, 8]
(ascii_name [2, 5] - [2, 8]))
(ERROR [2, 8] - [2, 9]
(ERROR [2, 8] - [2, 9]))
(string [2, 10] - [2, 18]
(format_converter [2, 14] - [2, 16]))
(ERROR [2, 18] - [2, 23]
(ERROR [2, 18] - [2, 19])))))
spellman_SLxPNx.proto 0 ms (ERROR [1, 8] - [1, 9])
Total parses: 1; successful parses: 0; failed parses: 1; success percentage: 0.00%
fix: remove the STX and ETX:
getKV {
out "14,";
in "14,%i,";
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.