Skip to content
Simple programming language implemented for Linguistics class
Haskell
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.gitignore
DTKV_Conversion.hs
DTKV_Conversion_Test.hs
DTKV_Grammar.hs
DTKV_Implementation.hs
DTKV_Implementation_Test.hs
DTKV_Test.hs
Deduction.hs
README.md
Recognition.hs
Recognition_Test.hs

README.md

What's Included


  • Definition of Grammar: DTKV_Grammar.hs
  • CKY Parser: Recognition.hs
  • Conversion Code to Haskell: DTKV_Conversion.hs
  • Language Implementation: DTKV_Implementation.hs
  • Tests: *_Test.hs

DTKV Language


Grammar

Tokens

  • Statements: Assign, Declare, Call
  • Expressions: Call, Return
  • Blocks: For, While, End
  • Types: Int, Bool, String

Data types

  • Int
  • Bool
  • String

Built-in Functions

  • operators
    • comparison: >, <, ==
    • arithmetic: +, -, *, /, %
    • boolean: !, &&, ||
    • string: ++
  • functions
    • arithmetic: abs, neg
    • string: head, tail

Sample Syntax

Assign Int x 1000
Declare ProdOfDif Int Int n Int x Int y
    Assign Int u 0
    Assign Int diff Call Int - Int x Int y End
    For 1 End Int n End
      Assign Int u Call Int + Int u Int diff End
    End 
    Return Int u
Assign Int answer Call Int ProdOfDif 3 2 5 End
Return Int answer

Implementation


Grammar (High-Level)

  • Statement ::= Assignment Variable Expression | FnDeclaration Name Function | LoopBlock Loop | CondBlock Conditional
  • Expression ::= Data Atom | Var Variable | FnCall Variable [Expression]
  • Atom = IntAtom Int | BoolAtom Bool | StrAtom String | NullAtom
  • Function = Fn Type [Variable] [Statement] Expression
  • Loop = For Expression Expression [Statement] | While Expression [Statement]
  • Conditional = IfElse Expression [Statement] [Statement]

  • Type Synonyms

    • Name = String
    • Type = Integer | Boolean | Str | Null
    • Variable = (Name, Type)

ToDo


  • ambiguous parses
  • tests:
    • parse trees are actually correct?
    • conversion test cases; verifying that representations are correct
    • clean up overall test cases (implicit, but would prefer if explicit) and workflow
  • sugaring
  • collections - Collection [Atom]
  • 80 char width
  • program to take a .dtkv file and run it
  • making Recognition_Test line 65-74 == lines 76-80

Copyright © 2012 Daniel Tahara, Kartik Venkatraman

Something went wrong with that request. Please try again.