Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alihamidzadeh committed May 15, 2022
0 parents commit 864e405
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
11 changes: 11 additions & 0 deletions 1-Ans.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Binary file added L&M Project ANTLR-00-2.pdf
Binary file not shown.
53 changes: 53 additions & 0 deletions Project.g4
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
grammar Project;

//--------------------------------------------parser--------------------------------------------------------
start: imports* definationVar*;
imports: importLibrary | importFunction;
importLibrary: VALIDNAME '=' REQUIRE '<' VALIDNAME '>' SEMICOLON;
importFunction : VALIDNAME (',' VALIDNAME)* '=' FROM '<' VALIDNAME '>' (REQUIRE ' <' VALIDNAME '>' | '=>' '<' VALIDNAME '>') (',' FROM ' <' VALIDNAME '>' (REQUIRE '<' VALIDNAME '>' | '=>' '<' VALIDNAME '>' ))* SEMICOLON;
//Defination Var..........................
definationVar: ACCESSIBILITY? CONST? DATATYPE VALIDNAME ('=' INT|DOUBLE|STRING)? SEMICOLON;









//--------------------------------------------Lexer Rules--------------------------------------------------------


RETURN : 'return';
REQUIRE : 'require';
FROM : 'from';
CONST : 'const';
DATATYPE : 'int' | 'float' | 'double' | 'string' | 'char' | 'bool';
ACCESSIBILITY : 'private' | 'public';
SEMICOLON : ';';
OPEN_PARANTEZ : '(';
CLOSE_PARANTEZ : ')';
OPEN_AKOLAD : '{';
CLOSE_AKOLAD : '}';
OPEN_KROSHE : '[';
CLOSE_KROSHE : ']';
BOOL : 'True' | 'False';
PM : '+' | '-';
SCIENTIFICSYMBOL : (DIGIT | '0') '.' INT ('e' ('-' | '+')? INT)?;
STRING: '"' TEXT '"';
INT : DIGIT+;
DOUBLE : INT ('.' INT)?;
VALIDNAME : (LETTER | '$') (LETTER | DIGIT | '_' | '$')+;
fragment TEXT: (LETTER | ' ' | '\t')*;
fragment LOWERCASE : [a-z];
fragment UPPERCASE : [A-Z];
fragment LETTER : [a-zA-Z];
fragment DIGIT : [0-9];

// ----------------------------------------Skip Rules-----------------------------------------------------
WS : ( ' ' | '\n' | '\t' | '\r')+ -> skip;
SINGLELINECOMMENT: '//' .*? -> skip;
MULTILINECOMMENT: '/*' .*? '*/' -> skip;


4 changes: 4 additions & 0 deletions Q
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
آیا همچین چیزی داریم؟
lib1, lib2 = require math, require animal;


7 changes: 7 additions & 0 deletions testCases1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
lib1 = from<math> require <floor>;

lib = from <math> require <floor>;

func = require<math>;

public const int aa = 10;

0 comments on commit 864e405

Please sign in to comment.