Skip to content

Commit

Permalink
Use Symbol.for instead of Symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
raleksandar committed Mar 13, 2018
1 parent 3d34aaa commit 266539f
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 92 deletions.
6 changes: 3 additions & 3 deletions src/Compiler/Evaluator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export interface CompilerOptions {
};
}

export const ConstValue = Symbol('const');
export const AsyncValue = Symbol('async');
export const ValueLookup = Symbol('lookup');
export const ConstValue = Symbol.for('numenor:eval:const');
export const AsyncValue = Symbol.for('numenor:eval:async');
export const ValueLookup = Symbol.for('numenor:context:lookup');

export interface EvaluatorContext {
[name: string]: any;
Expand Down
132 changes: 66 additions & 66 deletions src/Lexer/TokenType.ts
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
export const Unknown = Symbol('Unknown');
export const Invalid = Symbol('Invalid');
export const EOF = Symbol('EndOfFile');
export const NumberLiteral = Symbol('NumericLiteral');
export const StringLiteral = Symbol('StringLiteral');
export const BooleanLiteral = Symbol('BooleanLiteral');
export const NullLiteral = Symbol('null');
export const UndefinedLiteral = Symbol('undefined');
export const Identifier = Symbol('Identifier');
export const Whitespace = Symbol('Whitespace');
export const LineTerminator = Symbol('LineTerminator');
export const LParen = Symbol('(');
export const RParen = Symbol(')');
export const LBrace = Symbol('{');
export const RBrace = Symbol('}');
export const LBracket = Symbol('[');
export const RBracket = Symbol(']');
export const Comma = Symbol(',');
export const Dot = Symbol('.');
export const Plus = Symbol('+');
export const PlusEq = Symbol('+=');
export const PlusPlus = Symbol('++');
export const Minus = Symbol('-');
export const MinusEq = Symbol('-=');
export const MinusMinus = Symbol('--');
export const Eq = Symbol('=');
export const EqEq = Symbol('==');
export const EqEqEq = Symbol('===');
export const Bang = Symbol('!');
export const BangEq = Symbol('!=');
export const BangEqEq = Symbol('!==');
export const Amp = Symbol('&');
export const AmpEq = Symbol('&=');
export const AmpAmp = Symbol('&&');
export const Pipe = Symbol('|');
export const PipeEq = Symbol('|=');
export const PipePipe = Symbol('||');
export const Caret = Symbol('^');
export const CaretEq = Symbol('^=');
export const Tilde = Symbol('~');
export const TildeEq = Symbol('~=');
export const Star = Symbol('*');
export const StarEq = Symbol('*=');
export const StarStar = Symbol('**');
export const StarStarEq = Symbol('**=');
export const Slash = Symbol('/');
export const SlashEq = Symbol('/=');
export const Percent = Symbol('%');
export const PercentEq = Symbol('%=');
export const Lt = Symbol('<');
export const LtEq = Symbol('<=');
export const LtLt = Symbol('<<');
export const LtLtEq = Symbol('<<=');
export const Gt = Symbol('>');
export const GtEq = Symbol('>=');
export const GtGt = Symbol('>>');
export const GtGtEq = Symbol('>>=');
export const GtGtGt = Symbol('>>>');
export const GtGtGtEq = Symbol('>>>=');
export const Question = Symbol('?');
export const QuestionDot = Symbol('?.');
export const QuestionQuestion = Symbol('??');
export const QuestionQuestionEq = Symbol('??=');
export const Colon = Symbol(':');
export const In = Symbol('in');
export const Await = Symbol('await');
export const Unknown = Symbol.for('numenor:tok:unknown');
export const Invalid = Symbol.for('numenor:tok:invalid');
export const EOF = Symbol.for('numenor:tok:eof');
export const NumberLiteral = Symbol.for('numenor:tok:number');
export const StringLiteral = Symbol.for('numenor:tok:string');
export const BooleanLiteral = Symbol.for('numenor:tok:bool');
export const NullLiteral = Symbol.for('numenor:tok:null');
export const UndefinedLiteral = Symbol.for('numenor:tok:undefined');
export const Identifier = Symbol.for('numenor:tok:ident');
export const Whitespace = Symbol.for('numenor:tok:space');
export const LineTerminator = Symbol.for('numenor:tok:eol');
export const LParen = Symbol.for('numenor:tok:(');
export const RParen = Symbol.for('numenor:tok:)');
export const LBrace = Symbol.for('numenor:tok:{');
export const RBrace = Symbol.for('numenor:tok:}');
export const LBracket = Symbol.for('numenor:tok:[');
export const RBracket = Symbol.for('numenor:tok:]');
export const Comma = Symbol.for('numenor:tok:,');
export const Dot = Symbol.for('numenor:tok:.');
export const Plus = Symbol.for('numenor:tok:+');
export const PlusEq = Symbol.for('numenor:tok:+=');
export const PlusPlus = Symbol.for('numenor:tok:++');
export const Minus = Symbol.for('numenor:tok:-');
export const MinusEq = Symbol.for('numenor:tok:-=');
export const MinusMinus = Symbol.for('numenor:tok:--');
export const Eq = Symbol.for('numenor:tok:=');
export const EqEq = Symbol.for('numenor:tok:==');
export const EqEqEq = Symbol.for('numenor:tok:===');
export const Bang = Symbol.for('numenor:tok:!');
export const BangEq = Symbol.for('numenor:tok:!=');
export const BangEqEq = Symbol.for('numenor:tok:!==');
export const Amp = Symbol.for('numenor:tok:&');
export const AmpEq = Symbol.for('numenor:tok:&=');
export const AmpAmp = Symbol.for('numenor:tok:&&');
export const Pipe = Symbol.for('numenor:tok:|');
export const PipeEq = Symbol.for('numenor:tok:|=');
export const PipePipe = Symbol.for('numenor:tok:||');
export const Caret = Symbol.for('numenor:tok:^');
export const CaretEq = Symbol.for('numenor:tok:^=');
export const Tilde = Symbol.for('numenor:tok:~');
export const TildeEq = Symbol.for('numenor:tok:~=');
export const Star = Symbol.for('numenor:tok:*');
export const StarEq = Symbol.for('numenor:tok:*=');
export const StarStar = Symbol.for('numenor:tok:**');
export const StarStarEq = Symbol.for('numenor:tok:**=');
export const Slash = Symbol.for('numenor:tok:/');
export const SlashEq = Symbol.for('numenor:tok:/=');
export const Percent = Symbol.for('numenor:tok:%');
export const PercentEq = Symbol.for('numenor:tok:%=');
export const Lt = Symbol.for('numenor:tok:<');
export const LtEq = Symbol.for('numenor:tok:<=');
export const LtLt = Symbol.for('numenor:tok:<<');
export const LtLtEq = Symbol.for('numenor:tok:<<=');
export const Gt = Symbol.for('numenor:tok:>');
export const GtEq = Symbol.for('numenor:tok:>=');
export const GtGt = Symbol.for('numenor:tok:>>');
export const GtGtEq = Symbol.for('numenor:tok:>>=');
export const GtGtGt = Symbol.for('numenor:tok:>>>');
export const GtGtGtEq = Symbol.for('numenor:tok:>>>=');
export const Question = Symbol.for('numenor:tok:?');
export const QuestionDot = Symbol.for('numenor:tok:?.');
export const QuestionQuestion = Symbol.for('numenor:tok:??');
export const QuestionQuestionEq = Symbol.for('numenor:tok:??=');
export const Colon = Symbol.for('numenor:tok::');
export const In = Symbol.for('numenor:tok:in');
export const Await = Symbol.for('numenor:tok:await');

export type Literal = typeof NumberLiteral
| typeof StringLiteral
Expand Down
42 changes: 21 additions & 21 deletions src/Parser/ExpressionType.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
export const Identifier = Symbol('IdentifierExpression');
export const StackPush = Symbol('StackPushExpression');
export const StackPop = Symbol('StackPopExpression');
export const StackRef = Symbol('StackRefExpression');
export const NumberLiteral = Symbol('NumberLiteralExpression');
export const StringLiteral = Symbol('StringLiteralExpression');
export const BooleanLiteral = Symbol('BooleanLiteralExpression');
export const NullLiteral = Symbol('NullLiteralExpression');
export const UndefinedLiteral = Symbol('UndefinedLiteralExpression');
export const Assignment = Symbol('AssignmentExpression');
export const ArrayLiteral = Symbol('ArrayLiteralExpression');
export const ObjectLiteral = Symbol('ObjectLiteralExpression');
export const Conditional = Symbol('ConditionalExpression');
export const BinaryOperation = Symbol('BinaryOperationExpression');
export const PrefixOperation = Symbol('PrefixOperationExpression');
export const PostfixOperation = Symbol('PostfixOperationExpression');
export const Call = Symbol('CallExpression');
export const Await = Symbol('AwaitExpression');
export const Sequence = Symbol('SequenceExpression');
export const MemberAccess = Symbol('MemberAccessExpression');
export const ComputedMemberAccess = Symbol('ComputedMemberAccessExpression');
export const Identifier = Symbol.for('numenor:expr:ident');
export const StackPush = Symbol.for('numenor:expr:stack_push');
export const StackPop = Symbol.for('numenor:expr:stack_pop');
export const StackRef = Symbol.for('numenor:expr:stack_ref');
export const NumberLiteral = Symbol.for('numenor:expr:number');
export const StringLiteral = Symbol.for('numenor:expr:string');
export const BooleanLiteral = Symbol.for('numenor:expr:bool');
export const NullLiteral = Symbol.for('numenor:expr:null');
export const UndefinedLiteral = Symbol.for('numenor:expr:undefined');
export const Assignment = Symbol.for('numenor:expr:assign');
export const ArrayLiteral = Symbol.for('numenor:expr:array');
export const ObjectLiteral = Symbol.for('numenor:expr:object');
export const Conditional = Symbol.for('numenor:expr:conditional');
export const BinaryOperation = Symbol.for('numenor:expr:binop');
export const PrefixOperation = Symbol.for('numenor:expr:prefix');
export const PostfixOperation = Symbol.for('numenor:expr:postfix');
export const Call = Symbol.for('numenor:expr:call');
export const Await = Symbol.for('numenor:expr:await');
export const Sequence = Symbol.for('numenor:expr:sequence');
export const MemberAccess = Symbol.for('numenor:expr:access');
export const ComputedMemberAccess = Symbol.for('numenor:expr:computed_access');

export type Value = typeof NumberLiteral
| typeof StringLiteral
Expand Down
4 changes: 2 additions & 2 deletions src/Parser/Parselet/BinaryOperator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { TokenType } from '../../Lexer';
import { UnknownToken } from '../Error';
import { Any as Precedence } from '../Precedence';

export const LeftAssociative = Symbol('LeftAssociative');
export const RightAssociative = Symbol('RightAssociative');
export const LeftAssociative = Symbol.for('numenor:assoc:left');
export const RightAssociative = Symbol.for('numenor:assoc:right');

export type Associativity = typeof LeftAssociative | typeof RightAssociative;

Expand Down

0 comments on commit 266539f

Please sign in to comment.