Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/edadma/indentation-lexical
A lexical component that can be used to build a parser for a language that has "indentation syntax" or "off-side rule syntax"
https://github.com/edadma/indentation-lexical
Last synced: 14 days ago
JSON representation
A lexical component that can be used to build a parser for a language that has "indentation syntax" or "off-side rule syntax"
- Host: GitHub
- URL: https://github.com/edadma/indentation-lexical
- Owner: edadma
- License: isc
- Created: 2014-05-02T01:47:07.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2020-04-06T20:59:55.000Z (almost 5 years ago)
- Last Synced: 2024-11-19T10:12:50.745Z (3 months ago)
- Language: Scala
- Size: 40 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Indentation Lexical
This is a lexical component that can be used instead of `StdLexical` to build a parser for a language that has "indentation syntax" or "off-side rule syntax".
Refer to `ToyParser.scala` in the project as an example of how to add this to your parser. There is nothing special about the "toy" language that has been included: it doesn't even have loop constructs or a way to define functions. It was just created to demonstrate how to use `class IndentationLexical`.
In `ToyParser.scala`, the main source lines of interest are
def parse( r: Reader[Char] ) = phrase( source )( lexical.read(r) )
import lexical.{Newline, Indent, Dedent}
Although `IndentationLexical` extends `StdLexical`, you do not create an instance of `Scanner` as you would normally. `IndentationLexical` has it's own scanner.