Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

78 lines (65 sloc) 1.998 kb

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

Jump to Line
Something went wrong with that request. Please try again.