Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
dbfcc35
Initial Commit
GoatSnail Feb 29, 2016
f89a16c
Wrote some token enums. the rest needs.
GoatSnail Feb 29, 2016
ee05f5d
- Hey I added tokens
Lasse777 Mar 1, 2016
9b2a1d5
Initialized Project
Paludan Mar 2, 2016
3f0f87d
test
GoatSnail Mar 2, 2016
262534f
added stuff
GoatSnail Mar 2, 2016
a3eed90
Added package
Paludan Mar 3, 2016
72e60dc
SOme scanner stuff from Watt book
Lasse777 Mar 3, 2016
062158e
Added package
Paludan Mar 3, 2016
9f81aaf
Added package
Paludan Mar 3, 2016
9d24b96
Added dummy TokenStream class
GoatSnail Mar 3, 2016
23ce2d4
Now i actually added it? o.O
GoatSnail Mar 3, 2016
371ca12
Removed folder, made stuff more clear
Paludan Mar 3, 2016
c8bfeee
Added constructors to Token, should be usable now
GoatSnail Mar 3, 2016
a619a36
Merge branch 'ObsidiScanner' of https://github.com/TobiasMorell/P4 in…
GoatSnail Mar 3, 2016
ce31e1e
Adding functions for ScannerCode.java
Paludan Mar 3, 2016
b7c3f21
Begun work on Tokentype
GoatSnail Mar 3, 2016
2baf9dc
Adding functions for ScannerCode.java
Paludan Mar 3, 2016
a57753e
Finally fixed the return typw
Paludan Mar 3, 2016
35425bb
Finally fixed the return typw
Paludan Mar 3, 2016
e9ce2ce
Started work on the parser
Vemirtar Mar 3, 2016
c25fe55
Added the base Node AST
Ohshi60 Mar 3, 2016
17a0042
Merge branch 'ObsidiScanner' of http://github.com/tobiasmorell/p4 int…
Ohshi60 Mar 3, 2016
37150e2
TokenPattern and a few tokens implemented
GoatSnail Mar 3, 2016
ac57ba9
Merge remote-tracking branch 'origin/ObsidiScanner' into ObsidiScanner
GoatSnail Mar 3, 2016
296c1dd
Some basic methods for checking characters
Lasse777 Mar 4, 2016
6ca029b
Redefined the AST structure -Michael
Ohshi60 Mar 4, 2016
e635fee
Last changes to handmade parser. Still far from completion
Vemirtar Mar 4, 2016
23e550b
Added filereader etc.
Paludan Mar 4, 2016
4d3f6ab
Added relevant comments
Paludan Mar 4, 2016
70a15cf
Token work set on hold.
GoatSnail Mar 4, 2016
188f88a
fix
GoatSnail Mar 4, 2016
31734f2
AST Base added
Paludan Mar 7, 2016
9cbf924
AST/ : Added some general nodes and outlined a Visitor pattern
Mar 9, 2016
2fab632
AST/ : Same description as before, some files were not committed.
Mar 9, 2016
2da775d
Added compiler
Paludan Mar 11, 2016
c10aea4
Added jflex and cup jar files
Paludan Mar 11, 2016
498618f
Updated grammar, fixed build.xml, added a testfile with a more comple…
Vemirtar Mar 11, 2016
fcd77a1
Added more of the AST node files
Ohshi60 Mar 14, 2016
e99dee1
compiler/ : Testing dangling else
Mar 14, 2016
5fffcc9
func calll
GoatSnail Mar 15, 2016
75b53e9
compiler/ : Updated the grammar - hopefully this works
Mar 15, 2016
9eb5274
New Grammer and such
Paludan Mar 15, 2016
0e62c01
compiler/ : Made some changes to the grammar, now able to parse heade…
Mar 16, 2016
cc875b5
Added literals
Paludan Mar 18, 2016
a7c8de5
Updated grammer, still errors though
Paludan Mar 21, 2016
4278f4f
pushing parser states
Paludan Mar 21, 2016
b0ce1aa
Pushing states
Paludan Mar 21, 2016
57e2ee9
Fixed Java file endings
GoatSnail Mar 21, 2016
7d08a17
Added AssignNode - Michael
Ohshi60 Mar 21, 2016
8ff8ac5
ANTLR/ : Added ANTLR folder - able to parse expressions
Mar 22, 2016
28b5246
AST/ : Added .gitignore
GoatSnail Mar 22, 2016
69f4f58
ANTLR : added gitignore
Mar 22, 2016
0a139d6
ANTLR : antlr4 specification of grammar - still some errors
Mar 22, 2016
4034179
ANTLR/ : Completed grammar, added bash files for run, build and clean
Mar 23, 2016
aaa78e6
ANTLR/ : Now actually added bash files
Mar 23, 2016
71ad766
ANTLR/ : Added ANTLR jar as a test
Mar 23, 2016
c454dfb
ANTLR/ : Final touches to ANTLR
Mar 29, 2016
9e591dc
ANTLR/ : Done implementing grammar - started implementing AST
Apr 1, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions ANTLR/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
*.class

.idea/
out/

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
265 changes: 265 additions & 0 deletions ANTLR/src/Test/ObsidiCode.g4
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
grammar ObsidiCode;

//Fragment rules for lexer
fragment NameStartChar
: 'A'..'Z' | 'a'..'z';
fragment NameChar
: NameStartChar
| '0'..'9'
| '_'
;
fragment Num
: '0'..'9';

//Regex for the scanner:
Identifier
: NameStartChar NameChar*;

NumLit
: Num+ ('.'Num+)?;
CoordLit
: '('Num+',' Num+','Num+')';
StringLit
: '"'~('"')*'"';

WS
: [\t\r' ']+ -> skip;

//Comments
COMMENT
: '/*' .*? '*/' -> skip
;
EOLCOMMENT
: '//' .*? '\n' -> skip
;

prog
: roboDcl loads roboBodyDcl;
//Types and literals:
literal
: NumLit
| 'TRUE'
| 'FALSE'
| CoordLit
| StringLit
;
typeName
: Identifier
| typeName '.' Identifier
;

type
: referenceType
| primitiveType
;
primitiveType
: 'NUM'
| 'BOOL'
;
referenceType
: 'STRING'
| 'COORD'
| 'LIST'
;

loads
: loads 'LOAD' '(' StringLit ')' '\n'
| //lambda
;

//Declarations
roboDcl
: Identifier':''\n'
;
roboBodyDcl
: roboBodyDcl memberDcl
| memberDcl
;

memberDcl
: fieldDcl
| methodDcl
| '\n'
;

fieldDcl
: type variableDclList '\n';
variableDclList
: variableDcl
| variableDclList ',' variableDcl
;
variableDcl
: variableInitializer
| Identifier '=' listInitializer
;
variableInitializer
: assignmentExpression
| Identifier
;
listInitializer
: litList 'END' Identifier
| //lambda
;
litList
: litList ',' primary
| primary
;

//method stuff
methodDcl
: methodHeader methodBody
| hearDcl
;
methodHeader
: type methodDeclarator
| 'VOID' methodDeclarator
;
methodDeclarator
: Identifier '(' formalParams ')' '\n'
;
methodBody
: block 'END' Identifier
;
hearDcl
: 'HEAR' Identifier '(' formalParams ')' '\n' block 'END HEAR'
;

//Statements
block
: blockStmtList
| //lambda
;
blockStmtList
: blockStmtList statement '\n'
| statement '\n'
;
statement
: type variableDclList
| stmtNoSub
| ifStmt
| loopStmt
;
stmtNoSub
: //lambda
| signalStmt
| exprStmt
| 'BREAK'
| 'RETURN' expression
;
signalStmt
: 'SIGNAL' Identifier '(' argsList ')'
;
exprStmt
: assignmentExpression
| methodInvocation
;

methodInvocation
: typeName '(' formalArgs ')'
;

ifStmt
: 'IF' '(' expression ')' '\n' block 'END IF' elseIfOpt elseOpt
;
elseIfOpt
: elseIfOpt '\n' 'ELSE IF' '(' expression ')' '\n' block 'END ELSEIF'
| //lambda
;
elseOpt
: '\n' 'ELSE' '\n' block 'END ELSE'
| //lambda
;

loopStmt
: repeatStmt
| foreverStmt
;
repeatStmt
: 'REPEAT UNTIL' '(' expression ')' '\n' block 'END REPEAT'
;
foreverStmt
: 'FOREVER' '\n' block 'END FOREVER'
;

//Args and params
formalArgs
: argsList
| //lambda
;
argsList
: argsList ',' expression
| expression
;
formalParams
: paramsList
| //lambda
;
paramsList
: paramsList ',' param
| param
;
param
: type Identifier
;

//Expression part
expression
: assignmentExpression;

assignmentExpression
: conditionalExpression
| assignment;
assignment
: leftHandSide '=' expression;
leftHandSide
: typeName listOpt;
listOpt
: '[' expression ']'
| //lambda
;conditionalExpression
: conditionOrExpression;
conditionOrExpression
: conditionAndExpression
| conditionOrExpression 'OR' conditionAndExpression;
conditionAndExpression
: xOrExpression
| conditionAndExpression 'AND' xOrExpression;
xOrExpression
: equalityExpression
| xOrExpression 'XOR' equalityExpression;
equalityExpression
: relationalExpression
| equalityExpression equalityExpressionEnd;
equalityExpressionEnd
: 'IS' relationalExpression
| 'NOT' relationalExpression;
relationalExpression
: additiveExpression
| relationalExpression relationalExpressionEnd;
relationalExpressionEnd
: 'LESS_THAN' additiveExpression
| 'GREATER_THAN' additiveExpression
| 'LESS_THAN_EQUAL' additiveExpression
| 'GREATER_THAN_EQUAL' additiveExpression;
additiveExpression
: multiExpr
| additiveExpression additiveExpressionEnd;
additiveExpressionEnd
: '+' multiExpr
| '-' multiExpr;
multiExpr
: unaryExpr
| multiExpr multiExprEnd;
multiExprEnd
: '*' unaryExpr
| '/' unaryExpr;
unaryExpr
: '+' unaryExpr
| '-' unaryExpr
| primary;
primary
: literal
| '(' expression ')'
| typeName listOpt
| methodInvocation
;
Binary file added ANTLR/src/Test/antlr-4.5-complete.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions ANTLR/src/Test/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
export CLASSPATH=".:antlr-4.5-complete.jar:$CLASSPATH"

echo building the parser via ANTLR4...
java -Xmx500M -cp "antlr-4.5-complete.jar:$CLASSPATH" org.antlr.v4.Tool -package ObsidiCode.g4
echo compiling paser...
javac ObsidiCode*.java
7 changes: 7 additions & 0 deletions ANTLR/src/Test/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
echo cleaning binaries
rm *.class
echo cleaning java files
rm ObsidiCode*.java
echo cleaning tokens
rm *.tokens
5 changes: 5 additions & 0 deletions ANTLR/src/Test/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash/
export CLASSPATH=".:antlr-4.5-complete.jar:$CLASSPATH"

echo starting up...
java org.antlr.v4.runtime.misc.TestRig ObsidiCode prog -gui $1
31 changes: 31 additions & 0 deletions ANTLR/src/Test/test_decl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Test_robo:
LOAD("Attack-bot")
LOAD("Bow-bot")

BOOL works = true

//This be le tests con many!
/*Whattup maite!?*/

VOID Start()
NUM c = 10
a = b + c
SIGNAL guardian (a, b)
END Start

NUM TestNumMethod(NUM x, STRING s)
RETURN s + x
END TestNumMethod

VOID AnotherTestMethod(BOOL atHome)
FOREVER
COORD currentPos = (1,23,45)

IF(currentPos.x GREATER_THAN 10)
BREAK
END IF
ELSE IF (atHome)
//Something to find chest mayby
END ELSEIF
END FOREVER
END AnotherTestMethod
13 changes: 13 additions & 0 deletions AST/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*.class
.idea/

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added AST/ASTLee/production/org/AST/Main.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added AST/ASTLee/production/org/Visitors/Visitor.class
Binary file not shown.
20 changes: 20 additions & 0 deletions AST/ASTLee/src/java/org/AST/GeneralNodes/BinaryNode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.AST.GeneralNodes;

import org.Visitors.Visitor;

/**
* Created by Nete on 08-03-2016.
*/
public abstract class BinaryNode extends Node {
protected Node rightChild;

public Node GetRightChild()
{
return rightChild;
}

public BinaryNode (Node leftChild, Node rightChild){
this._leftmostChild = leftChild;
this.rightChild = rightChild;
}
}
Loading