diff --git a/parser/parser-fplo/FploInputParser.py b/parser/parser-fplo/FploInputParser.py index 2a1949df893ed4eba25b86ab1d6eda27dd958f29..666a4b6e9e96a5e6255b5c86bec9ea8a0f5f02a3 100755 --- a/parser/parser-fplo/FploInputParser.py +++ b/parser/parser-fplo/FploInputParser.py @@ -46,6 +46,21 @@ cRE_literal = re.compile( ]) + r')' ) +KEYWORDS_LIST = [ + 'section', + 'struct', +] +KEYWORDS = { KEYWORDS_LIST[i]: i for i in range(len(KEYWORDS_LIST)) } + +DATATYPES_LIST = [ + 'char', + 'int', + 'real', + 'logical', + 'flag', +] +DATATYPES = { DATATYPES_LIST[i]: i for i in range(len(DATATYPES_LIST)) } + class FploInputParser(object): """Parser for C-like FPLO input """ @@ -124,7 +139,17 @@ class FploInputParser(object): # match identifier or keyword m = cRE_kw_ident.match(line, pos_in_line) if m is not None: - self.annotate(m.group(), ANSI.FG_BRIGHT_GREEN) + subtype = KEYWORDS.get(m.group(1), None) + if subtype is not None: + self.annotate(m.group(), ANSI.FG_YELLOW) + self.statement.append(m.group(1)) + return m.end() + subtype = DATATYPES.get(m.group(1), None) + if subtype is not None: + self.annotate(m.group(), ANSI.FG_GREEN) + self.statement.append(m.group(1)) + return m.end() + self.annotate(m.group(), ANSI.FG_BRIGHT_CYAN) self.statement.append(m.group(1)) return m.end() # match subscript of previous identifier