Skip to content
qwertie edited this page Aug 10, 2014 · 1 revision

A core part of Loyc is the concept of the "Loyc tree". If you are not familiar with Loyc trees, read this article: http://loyc-etc.blogspot.ca/2013/04/the-loyc-tree-and-prefix-notation-in-ec.html

Loyc.Syntax contains

  • CodeSymbols, a static class that defines the names of most built-in features of Enhanced C#. In the future, I hope we will define some kind of "standard imperative language" that will use many of the same symbol names as EC#. In that case, perhaps CodeSymbols will just contain the standard (lower-level) symbols and EC# will have its own class for EC#-specific features.
  • My Loyc tree implementation (Nodes folder).
    • LNode class represents a subtree of source code. Currently, all nodes are immutable.
    • Typically one uses LNodeFactory to create LNodes in C#.
  • Facilities for representing source code and source code locations (SourceFiles folder)
    • The design of this portion is unstable. You might see "leftover code" that isn't being used.
    • The ISourceFile interface and its subinterfaces represent a source file of characters (.NET chars).
    • EmptySourceFile, a dummy object that can be used as the "source file" for synthetic nodes
    • SourceRange, a structure that holds an ISourceFile reference and a range of indexes (two integers)
    • SourcePos, a position represented as a file name string, a line number, and a column number
      • The SourceRange.Begin and SourceRange.End properties create SourcePos objects on-the-fly
  • Facilities for implementing lexers a.k.a. scanners/tokenizers (Lexing folder):
    • Again, I'm not confident about the design and may change it.
    • ILexer, a suggested interface for lexers to implement
    • BaseLexer<TSource>, a suggested base class for implementing lexers using LLLPG
    • Token, a universal 4-word structure (3 ints and an object reference) for tokens in any language
    • TokenTree, a list of tokens plus an ISourceFile that is common to all the tokens
    • TokensToTree: a class that arranges tokens into a tree, grouping tokens by (), {} and [].
  • BaseParser<Token>, a base class designed for parsers generated by LLLPG
  • IntSet, a class for holding a collection of integers or characters, expressed as a series of integer ranges.
  • LES (Loyc Expression Syntax) support (Les folder, Loyc.Syntax.Les namespace)
    • LesLexer class - Tokenizes LES code
    • LesParser class - Parses LES code
    • TokenType enum - Types of tokens in LES
    • LesNodePrinter class - prints arbitrary syntax trees (currently very rudimentary)
    • LesPrecedence - contains documentation for the operators and the precedence rules
Clone this wiki locally