Skip to content

tickct/MUZL

Repository files navigation

Morgan Peters
Sean Gray

CS 440 - Languages and Translators

How to run:

To run our analyzer you can either use the tests.py to run checks on the code.
 Or you can call our lexer on a string to get the results from that string.

Report:

You have to submit a report of lexical analyzer
that states different tokens of your programming language.
Such as operators, identifier, keywords.
Define regular expressions of all tokens

Tokens:

    Operators:
    'LOGIC', # Or And Xor
    'EQUALS', 'PLUS', 'MINUS', 'TIMES', 'DIVIDE', 'POW',
    'LTHAN', 'LETHAN', 'GTHAN','GETHAN','ETO',

    Identifier:
    'TYPE', 'VAR', 'ID'
    'ARROW', 'MATCHBREAK', 'EOL',
    'COMMA', 'LBRACKET', 'RBRACKET',
    'LPAREN', 'RPAREN', 'COLON',

    Keywords:
    IF, RULE, START, MATCH, INT, FLOAT, CHAR, STRING, BOOL, HEX

    #data types
    'INT', 'FLOAT', 'CHAR', 'STRING', 'BOOL', 'HEX'


Regular expressions:
    MATCHBREAK = r'\|'
    COMMA = r'\,'
    LBRACKET = r'\['
    RBRACKET = r'\]'
    LETHAN = r'\<='
    LTHAN = r'\<'
    GETHAN = r'\>='
    GTHAN = r'\>'
    PLUS = r'\+'
    ARROW = r'->'
    MINUS = r'-'
    TIMES = r'\*'
    DIVIDE = r'/'
    POW = r'\^'
    ETO = r'=='
    EQUALS = r'='
    LPAREN = r'\('
    RPAREN = r'\)'
    COLON = r':'
    STRING = r'(").+(")'
    HEX = r'0x(\d|[a-f]|[A-F])+\s'
    INT = r'-*\d+'
    FLOAT = r'-?\d+\.d*(e-?\d+)?'
    CHAR = r'(\')\S(\')'
    BOOL = r'(True|False)'
    COMMENT = r'\#.+'
    EOL = r'!+'
    RESERVED = r'[a-zA-Z_][a-zA-Z_0-9]*'


------------------------------------------------------------------------
Part 2 - Lexical Analyzer
 data types -> int, float, char, string, array, bool
 logic -> and, or, xor, not
 forking -> () if conditional yes and no
 comparisons -> == | => | =< | > | < |
     match x
         [x] = x|
         [x:xs] = x+xs!
 assignment -> =
 functions -> rule
 math -> +, -, %, /, *, ^ (fractional powers),
 End line -> !
 examples:

 person type = name: string, age: int!

 name rule ( arg1 type; arg2 type ) -> type = (X + Y)

  fact rule (x:[int])-> int =
    match x
    [x] = x|
    [x:xs] = x + factx!

  start x = fact(x)

 .........................................................................

    PLY language site. Python LEX
    http://www.dabeaz.com/ply/

About

Mutator Programming Lanuguage for Puzzle Solving

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages