stadelmanma / tree-sitter-fortran

Fortran grammar for tree-sitter
MIT License
30 stars 15 forks source link

Turn 'keyword_statement' into some kind of helper function #27

Closed stadelmanma closed 3 years ago

stadelmanma commented 6 years ago

Basically, fortran has alot of bar keyword statements such as continue, cycle, goto, contains, etc. I think for highlighting purposes it might be easier to define some kind of helper method to generate rules for me (like preprocessor directives)

Example pseduo code, in reality I'll need to think more about the implementation.

function keywordStatement(name, keyword rule, *add_rules) {
    if add_rules is empty {
       return alias(caseInsenstive(keyword rule), name)
    }
   else {
       return seq(....)
    }
}

Possible expected output for GOTO 786 (keyword_statement (keyword), (statement_label))

I don't know if I really care in terms of parsing that it is a goto_statement in particular.