Module: Mulang::Tokens

Defined in:
lib/mulang/tokens.rb

Constant Summary collapse

TOKENS =
{
  Common: {
    keyword_False: 'false',
    keyword_Null: 'null',
    keyword_True: 'true',
    keyword_For: 'for',
    keyword_If: 'if',
    keyword_Return: 'return',
    keyword_While: 'while',
    operator_And: '&&',
    operator_Divide: '/',
    operator_Equal: '==',
    operator_GreaterOrEqualThan: '>=',
    operator_GreaterThan: '>',
    operator_LessOrEqualThan: '<=',
    operator_LessThan: '<',
    operator_Minus: '-',
    operator_Multiply: '*',
    operator_Negation: '!',
    operator_NotEqual: '!=',
    operator_Slice: 'slice',
    operator_GetAt: '[]',
    operator_SetAt: '[]=',
    operator_Or: '||',
    operator_Plus: '+',
    operator_Modulo: '%',
    operator_BitwiseOr: '|',
    operator_BitwiseAnd: '&',
    operator_BitwiseXor: '^',
    operator_BitwiseLeftShift: '<<',
    operator_BitwiseRightShift: '>>'
  },
  C: {
    keyword_False: 'FALSE',
    keyword_Null: 'NULL',
    keyword_True: 'TRUE',
    keyword_For: 'for',
    keyword_If: 'if',
    keyword_Return: 'return',
    keyword_While: 'while',
    keyword_Switch: 'switch',
    operator_And: '&&',
    operator_Divide: '/',
    operator_Equal: '==',
    operator_GreaterOrEqualThan: '>=',
    operator_GreaterThan: '>',
    operator_LessOrEqualThan: '<=',
    operator_LessThan: '<',
    operator_Minus: '-',
    operator_Multiply: '*',
    operator_Negation: '!',
    operator_NotEqual: '!=',
    operator_Or: '||',
    operator_Plus: '+',
    operator_Modulo: '%',
    operator_BitwiseOr: '|',
    operator_BitwiseAnd: '&',
    operator_BitwiseXor: '^',
    operator_BitwiseLeftShift: '<<',
    operator_BitwiseRightShift: '>>'
  },
  Haskell: {
    keyword_False: 'False',
    keyword_True: 'True',
    keyword_If: 'if',
    keyword_TypeAlias: 'type',
    operator_And: '&&',
    operator_Divide: '/',
    operator_Equal: '==',
    operator_GreaterOrEqualThan: '>=',
    operator_GreaterThan: '>',
    operator_LessOrEqualThan: '<=',
    operator_LessThan: '<',
    operator_Minus: '-',
    operator_Multiply: '*',
    operator_Negation: 'not',
    operator_NotEqual: '/=',
    operator_Or: '||',
    operator_Plus: '+',
    operator_Modulo: 'mod',
    operator_Otherwise: 'otherwise',
    operator_BackwardComposition: '.'
  },
  Java: {
    keyword_False: 'false',
    keyword_Null: 'null',
    keyword_True: 'true',
    keyword_For: 'for',
    keyword_If: 'if',
    keyword_Return: 'return',
    keyword_While: 'while',
    keyword_Class: 'class',
    keyword_ForEach: 'for',
    keyword_Interface: 'interface',
    keyword_Switch: 'switch',
    keyword_Self: 'this',
    operator_And: '&&',
    operator_Divide: '/',
    operator_Equal: 'equal',
    operator_GreaterOrEqualThan: '>=',
    operator_GreaterThan: '>',
    operator_LessOrEqualThan: '<=',
    operator_LessThan: '<',
    operator_Minus: '-',
    operator_Multiply: '*',
    operator_Negation: '!',
    operator_NotEqual: '!=',
    operator_Slice: 'slice',
    operator_GetAt: '[]',
    operator_SetAt: '[]=',
    operator_Or: '||',
    operator_Plus: '+',
    operator_Modulo: '%',
    operator_BitwiseOr: '|',
    operator_BitwiseAnd: '&',
    operator_BitwiseXor: '^',
    operator_BitwiseLeftShift: '<<',
    operator_BitwiseRightShift: '>>',
    operator_Hash: 'hashCode',
    operator_Same: '==',
    operator_NotSame: '!='
  },
  JavaScript: {
    keyword_False: 'false',
    keyword_Null: 'null',
    keyword_True: 'true',
    keyword_For: 'for',
    keyword_If: 'if',
    keyword_Return: 'return',
    keyword_While: 'while',
    keyword_Self: 'this',
    keyword_ForEach: 'for..of',
    operator_And: '&&',
    operator_Divide: '/',
    operator_Equal: '===',
    operator_GreaterOrEqualThan: '>=',
    operator_GreaterThan: '>',
    operator_LessOrEqualThan: '<=',
    operator_LessThan: '<',
    operator_Minus: '-',
    operator_Multiply: '*',
    operator_Negation: '!',
    operator_NotEqual: '!==',
    operator_Slice: 'slice',
    operator_GetAt: '[]',
    operator_SetAt: '[]=',
    operator_Or: '||',
    operator_Plus: '+',
    operator_Modulo: '%',
    operator_BitwiseOr: '|',
    operator_BitwiseAnd: '&',
    operator_BitwiseXor: '^',
    operator_BitwiseLeftShift: '<<',
    operator_BitwiseRightShift: '>>',
    operator_Size: 'length',
    operator_Similar: '==',
    operator_NotSimilar: '!=',
    operator_Push: 'push'
  },
  Python: {
    keyword_False: 'False',
    keyword_Null: 'None',
    keyword_True: 'True',
    keyword_For: 'for',
    keyword_If: 'if',
    keyword_Return: 'return',
    keyword_While: 'while',
    keyword_Self: 'self',
    keyword_ForEach: 'for..in',
    operator_And: 'and',
    operator_Divide: '/',
    operator_Equal: '==',
    operator_GreaterOrEqualThan: '>=',
    operator_GreaterThan: '>',
    operator_LessOrEqualThan: '<=',
    operator_LessThan: '<',
    operator_Minus: '-',
    operator_Multiply: '*',
    operator_Negation: 'not',
    operator_NotEqual: '!=',
    operator_Slice: '[:]',
    operator_GetAt: '[]',
    operator_SetAt: '[]=',
    operator_Or: 'or',
    operator_Plus: '+',
    operator_Modulo: '%',
    operator_BitwiseOr: '|',
    operator_BitwiseAnd: '&',
    operator_BitwiseXor: '^',
    operator_BitwiseLeftShift: '<<',
    operator_BitwiseRightShift: '>>',
    operator_Hash: 'hash',
    operator_Size: 'len'
  },
  Ruby: {
    keyword_False: 'false',
    keyword_Null: 'null',
    keyword_True: 'true',
    keyword_For: 'for',
    keyword_If: 'if',
    keyword_Return: 'return',
    keyword_While: 'while',
    keyword_Class: 'class',
    keyword_ForEach: 'for',
    keyword_Include: 'include',
    keyword_Switch: 'case',
    keyword_Self: 'self',
    operator_And: '&&',
    operator_Divide: '/',
    operator_Equal: '==',
    operator_GreaterOrEqualThan: '>=',
    operator_GreaterThan: '>',
    operator_LessOrEqualThan: '<=',
    operator_LessThan: '<',
    operator_Minus: '-',
    operator_Multiply: '*',
    operator_Negation: '!',
    operator_NotEqual: '!=',
    operator_Slice: 'slice',
    operator_GetAt: '[]',
    operator_SetAt: '[]=',
    operator_Or: '||',
    operator_Plus: '+',
    operator_Modulo: '%',
    operator_BitwiseOr: '|',
    operator_BitwiseAnd: '&',
    operator_BitwiseXor: '^',
    operator_BitwiseLeftShift: '<<',
    operator_BitwiseRightShift: '>>',
    operator_Size: 'length',
    operator_Hash: 'hash',
    operator_ForwardComposition: '>>',
    operator_BackwardComposition: '<<'
  },
  Php: {
    keyword_False: 'false',
    keyword_Null: 'null',
    keyword_True: 'true',
    keyword_For: 'for',
    keyword_If: 'if',
    keyword_Return: 'return',
    keyword_While: 'while',
    keyword_Self: 'this',
    operator_And: '&&',
    operator_Divide: '/',
    operator_Equal: '==',
    operator_GreaterOrEqualThan: '>=',
    operator_GreaterThan: '>',
    operator_LessOrEqualThan: '<=',
    operator_LessThan: '<',
    operator_Minus: '-',
    operator_Multiply: '*',
    operator_Negation: '!',
    operator_NotEqual: '!=',
    operator_Slice: 'slice',
    operator_GetAt: '[]',
    operator_SetAt: '[]=',
    operator_Or: '||',
    operator_Plus: '+',
    operator_Modulo: '%',
    operator_BitwiseOr: '|',
    operator_BitwiseAnd: '&',
    operator_BitwiseXor: '^',
    operator_BitwiseLeftShift: '<<',
    operator_BitwiseRightShift: '>>'
  },
  Prolog: {
    keyword_Fail: 'fail',
    keyword_Findall: 'findall',
    keyword_Forall: 'forall',
    keyword_Not: 'not',
    keyword_Is: 'is',
    operator_Divide: '/',
    operator_GreaterOrEqualThan: '>=',
    operator_GreaterThan: '>',
    operator_LessOrEqualThan: '=<',
    operator_LessThan: '<',
    operator_Minus: '-',
    operator_Multiply: '*',
    operator_NotEqual: '/=',
    operator_Plus: '+'
  }
}.freeze
POLYFILLS =
{
  Common: {
    keyword_EntryPoint: 'program',
    keyword_ForEach: 'foreach',
    keyword_Repeat: 'repeat',
    keyword_Switch: 'switch',
    keyword_Yield: 'yield',
    operator_Hash: 'hash',
    operator_BackwardComposition: '.',
    operator_ForwardComposition: '>>'
  }
}.freeze
DEFAULT_TOKENS =
TOKENS[:Common].merge(POLYFILLS[:Common]).freeze