Parser combinators is a popular approach to parsing sequences generated by context-free grammars, which can be specialized data formats (e.g. JSON, YAML), markup languages like XML or HTML. At the same time, this approach is rarely used for parsing programming languages.The purpose of this paper is to study the application of parser combinators for programming languages processing, and more precisely for searching of syntax errors. The method that had been developed during this research was compared with an algorithm of syntax analysis of programming languages using parser-generators. Parser combinator takes less time on average to find a syntax error in the source code. Its average time complexity is linear with respect to the length of the input sequence, while the parser generator has an average quadratic complexity. Moreover, a parser combinator requires less memory than a parser generator.These results can be used for building intelligent code completion tools for fast syntax error detection.
展开▼