Lex and Yacc syntax highlighting for Nano

Posted: February 15th, 2011 | Author: | Filed under: Uncategorized | Comments Off

There’s not a lot to them, but it’s better than anything I could find on the Internet. The real key feature is a line in the yacc syntax highlighting file that marks whitespace at the end of lines. Since yacc/bison are sensitive to that, it’s good to be able to see it.

Nano syntax highlighting for yacc or bison:

## Syntax highlighting for yacc/bison input files
syntax "yacc" "\.y$"
color red "%[a-zA-Z0-9]*"
## String highlighting.  You will in general want your comments and
## strings to come last, because syntax highlighting rules will be
## applied in the order they are read in.
color brightyellow "<[^=        ]*>" ""(\\.|[^"])*""
## This string is VERY resource intensive!
color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
## Comments
color brightblue start="/\*" end="\*/"
## Visible space at line ends
color green,green "[[:space:]]+$"

Nano syntax highlighting for Lex or Flex:

## Syntax highlighting for lex/flex input files
syntax "lex" "\.l$"
color red "%[^[[:space:]]]*"
## String highlighting.  You will in general want your comments and
## strings to come last, because syntax highlighting rules will be
## applied in the order they are read in.
color brightyellow "<[^=        ]*>" ""(\\.|[^"])*""
## This string is VERY resource intensive!
color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
## Comments
color brightblue start="/\*" end="\*/"