Skip to content
yassir RAMDANI edited this page Nov 27, 2020 · 1 revision

“SwiParse”/

A general-purpose parser generator library in Swift with ambiguity detection and conflicts resolution.

Introduction

In computer science, a parser is a program that reads a sequence of tokens (obtained from a lexer) and recognizes its semantic structure in the form of an abstract syntax tree (AST or parse tree) using the rules of a formal grammar.

SwiParse is a general-purpose parser generator which means that you can use it to build LR(1) parsers from any context-free grammar (in few lines of code). SwiParse also detects grammar ambiguity and provides mechanisms to define the rules' associativity and precedence.

SwiParse is fully compatible with SwiLex (learn more)

Features

  • Tokens defined simply using a SwiLexable enum (for terminals) and a SwiParsable enum (for non-terminals).
  • Simple grammar definition with syntactic sugar (overrided operators).
  • Supports reduction actions for rules.
  • Grammar ambiguity (conflicts) detection.
  • Associativity and precedence mechanisms (conflicts resolution).
  • Parsing errors detections.
  • Support conditional terminal tokens with custom modes and all the other SwiLex features.
  • Lexing Errors with line number and the issue's substring.
  • Fully compatible with all the SwiLex features.
  • Better debugging tools (graphviz visualisation...).
  • Better parsing errors.
  • Files as input.
  • Add detailed documentation with more examples.
  • Support Cocoapods and Carthage.