%{ %} DIGIT [0-9] BRACKET \(|\) STR \"([^\"]|\\\")*([^\\]|\\\\)\" NUMBERS [^A-z](\+|-)?{DIGIT}+(\.{DIGIT}+(e{DIGIT}+|d{DIGIT}+|e-{DIGIT}+)?|\/{DIGIT}+)? COMMENT ;.*$ PARAMETER_TYPE &[0-9A-z]+ KEYWORD :[0-9A-z]+ CONSTANTS T|NIL|pi|t SPECIAL_FORM block|function|if|let|quote|return-from|defun|demacro /* Functions */ F_ARITHMETIC "+ "|"- "|"* "|\/|1\+|1-|conjugate|gcd|lcm F_NUM_COMPARISON =|\/=|<|>|<=|>=|max|min F_TRIGONOMETRIC sin|cos|tan|cis|asin|acos|atan|sinh|cosh|tanh|asinh|acosh|atanh F_OTHER_MATH abs|sqrt|phase|signum F_LOGICAL not F_LISTS list F_OTHER format /* Macros */ M_ARITHMETIC incf|decf M_LOGICAL and|or M_CONDITIONAL when|unless|cond|case|typecase M_DECLARE defvar|defparameter|defconstant|defun /* Not in spec, but commonly followed */ GLOBAL_VAR \*([0-9A-z.?-_])+\* CONST_VAR \+([0-9A-z.?-_])+\+ %% {BRACKET} { printf("%s", yytext); } {STR} { printf("%s", yytext); } {NUMBERS} { printf("%s", yytext); } {COMMENT} { printf("%s", yytext); } {PARAMETER_TYPE} { printf("%s", yytext); } {KEYWORD} { printf("%s", yytext); } {CONSTANTS} { printf("%s", yytext); } {SPECIAL_FORM} { printf("%s", yytext); } {F_ARITHMETIC}|{F_NUM_COMPARISON}|{F_TRIGONOMETRIC}|{F_TRIGONOMETRIC}|{F_OTHER_MATH}|{F_LOGICAL}|{F_LISTS}|{F_OTHER} { printf("%s", yytext); } {M_ARITHMETIC}|{M_LOGICAL}|{M_CONDITIONAL}|{M_DECLARE} { printf("%s", yytext); } {GLOBAL_VAR}|{CONST_VAR} { printf("%s", yytext); } /* flex catches the longest possibility, so if some variable name contains a known word (function, macro, etc.), this will prevent it from highlighting */ [A-z]+ { printf("%s", yytext); } %%