stadelmanma / tree-sitter-fortran

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

Improve BOZ number literal regexs #19

Closed stadelmanma closed 6 years ago

stadelmanma commented 6 years ago

I noticed while working on implied do loops in an attempt to recover from the error 'A' and 'B' were getting caught as number literals instead of string literals. My patterns for BOZ constants need reworked so one of those letters is always required

New patterns to test:

    number_literal: $ => token(
      choice(
        // integer, real with and without exponential notation
        /[-+]?\d*(\.\d*)?([eEdD][-+]?\d+)?/,
        // binary literal
        /[-+]?(([bB]'[01]+)|([01]+'[bB]))/,
        // octal literal
        /[-+]?(([oO]'[0-8]+)|([0-8]+'[oO]))/,
        // hexcadecimal
        /[-+]?(([zZ]'[0-9a-fA-F]+)|([0-9a-fA-F]+'[zZ]))/
      )),