C# Class Loyc.Syntax.Les.Les2PrecedenceMap

This class's main job is to maintain a table of Precedence values for LES operators. When you ask about a new operator, its precedence is chosen by this class and cached for future reference.
Mostrar archivo Open project: qwertie/LoycCore Class Usage Examples

Protected Properties

Property Type Description
PredefinedInfixPrecedence Precedence>.Map
PredefinedPrefixPrecedence Precedence>.Map
PredefinedSuffixPrecedence Precedence>.Map
_precedenceMap Pair,Precedence>[]

Public Methods

Method Description
Find ( OperatorShape shape, object op, bool cacheWordOp = true, bool les3InfixOp = false ) : Precedence

Gets the precedence in LES of a prefix, suffix, or infix operator.

IsExtendedOperator ( string name, string expectPrefix = "'" ) : bool

Returns true if the given Symbol can ever be used as an "extended" binary operator in LESv3.

A binary operator's length must be between 2 and 255, its name must start with an apostrophe, and each remaining character must be punctuation marks from natural operators and/or characters from the set {'#', '_', 'a'..'z', 'A'..'Z', '0'..'9', '$'}.

IsNaturalOperator ( string name ) : bool

Returns true if the given Symbol can be printed as an operator without escaping it in LESv2.

The parser should read something like +/* as an operator with three characters, rather than "+" and a comment, but the printer is more conservative, so this function returns false in such a case.

IsOpChar ( char c ) : bool

Returns true if this character is one of those that operators are normally made out of in LES.

IsOpCharEx ( char c ) : bool

Returns true if this character is one of those that can appear in "extended" LESv3 operators that start with an apostrophe.

IsSuffixOperatorName ( Symbol name, Symbol &bareName ) : bool

Decides whether the name appears to represent a suffix operator of the form sufOP or OP\.

Les2PrecedenceMap ( ) : System
Reset ( ) : void

Forgets previously encountered operators to save memory.

ToSuffixOpName ( object symbol ) : Symbol

Given a normal operator symbol like (Symbol)"'++", gets the suffix form of the name, such as (Symbol)"'++suf".

op must be a Symbol, but the parameter has type object to avoid casting Token.Value in the parser.

Protected Methods

Method Description
FindPrecedence ( MMap table, object symbol, Precedence @default, bool cacheWordOp, bool les3InfixOp = false ) : Precedence
this ( OperatorShape s ) : Pair,Precedence>

Private Methods

Method Description
GetOpChars ( ) : BitArray
GetOpCharsEx ( ) : BitArray
IsOperator ( string name, BitArray opChars, bool rejectComment, string expectPrefix ) : bool

Method Details

Find() public method

Gets the precedence in LES of a prefix, suffix, or infix operator.
public Find ( OperatorShape shape, object op, bool cacheWordOp = true, bool les3InfixOp = false ) : Precedence
shape OperatorShape Specifies which precedence table and rules to use /// (Prefix, Suffix or Infix). Note: when this is Suffix, "suf" must not be /// part of the name in op (see )
op object Parsed form of the operator. op must be a Symbol, but /// the parameter has type object to avoid casting Token.Value in the parser.
cacheWordOp bool
les3InfixOp bool
return Precedence

FindPrecedence() protected method

protected FindPrecedence ( MMap table, object symbol, Precedence @default, bool cacheWordOp, bool les3InfixOp = false ) : Precedence
table MMap
symbol object
@default Precedence
cacheWordOp bool
les3InfixOp bool
return Precedence

IsExtendedOperator() public static method

Returns true if the given Symbol can ever be used as an "extended" binary operator in LESv3.
A binary operator's length must be between 2 and 255, its name must start with an apostrophe, and each remaining character must be punctuation marks from natural operators and/or characters from the set {'#', '_', 'a'..'z', 'A'..'Z', '0'..'9', '$'}.
public static IsExtendedOperator ( string name, string expectPrefix = "'" ) : bool
name string
expectPrefix string
return bool

IsNaturalOperator() public static method

Returns true if the given Symbol can be printed as an operator without escaping it in LESv2.
The parser should read something like +/* as an operator with three characters, rather than "+" and a comment, but the printer is more conservative, so this function returns false in such a case.
public static IsNaturalOperator ( string name ) : bool
name string
return bool

IsOpChar() public static method

Returns true if this character is one of those that operators are normally made out of in LES.
public static IsOpChar ( char c ) : bool
c char
return bool

IsOpCharEx() public static method

Returns true if this character is one of those that can appear in "extended" LESv3 operators that start with an apostrophe.
public static IsOpCharEx ( char c ) : bool
c char
return bool

IsSuffixOperatorName() public static method

Decides whether the name appears to represent a suffix operator of the form sufOP or OP\.
public static IsSuffixOperatorName ( Symbol name, Symbol &bareName ) : bool
name Symbol Potential operator name to evaluate.
bareName Symbol If the name ends with "suf", this is the same /// name without "suf", otherwise it is set to name itself. This /// output is calculated even if the function returns false. /// IsNaturalOperator(bareName) is true if the function returns true.
return bool

Les2PrecedenceMap() public method

public Les2PrecedenceMap ( ) : System
return System

Reset() public method

Forgets previously encountered operators to save memory.
public Reset ( ) : void
return void

ToSuffixOpName() public method

Given a normal operator symbol like (Symbol)"'++", gets the suffix form of the name, such as (Symbol)"'++suf".
op must be a Symbol, but the parameter has type object to avoid casting Token.Value in the parser.
public ToSuffixOpName ( object symbol ) : Symbol
symbol object
return Symbol

this() protected method

protected this ( OperatorShape s ) : Pair,Precedence>
s OperatorShape
return Pair,Precedence>

Property Details

PredefinedInfixPrecedence protected_oe static_oe property

protected static Map PredefinedInfixPrecedence
return Precedence>.Map

PredefinedPrefixPrecedence protected_oe static_oe property

protected static Map PredefinedPrefixPrecedence
return Precedence>.Map

PredefinedSuffixPrecedence protected_oe static_oe property

protected static Map PredefinedSuffixPrecedence
return Precedence>.Map

_precedenceMap protected_oe property

protected Pair,Precedence>[] _precedenceMap
return Pair,Precedence>[]