You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Tutorials and template project: https://github.com/sv-giampa/JointyC-Tutorials
13
+
14
+
## Introduction
13
15
14
16
JointyC is a Java library to write compilers. Its main target is to move
15
17
the attention of the developer from parsing to the semantic analysis and,
@@ -27,10 +29,70 @@ the JointyC Definition Language (JDL), used to define recursive-descent
27
29
parsers for context-free languages, that can be adorned with contextual
28
30
information during semantic analysis.
29
31
30
-
31
-
## 2. Software Engineering in the scope.
32
-
33
-
As anticipated, the most important target of JointyC is to simplify the
32
+
Follows a fast presentation of the library and more detailed introduction.
33
+
34
+
# A very fast presentation of the idea
35
+
After this very short description, really few things will be clear, but probably the power of JointyC will be one of these.
36
+
37
+
Execute three main steps to write a compiler with JointyC:
38
+
39
+
1) write your language specifics in the JointyC Definition Language:
40
+
```
41
+
//Language.jdl file
42
+
language: yourLanguage;
43
+
44
+
lexicon:{
45
+
myToken = /token1/$, "description of token";
46
+
mySecondToken = /token2/$, "description of the second token";
47
+
}
48
+
49
+
grammar:{
50
+
axiom = nonTerminal $myToken;
51
+
nonTerminal = $mySecondToken;
52
+
}
53
+
```
54
+
55
+
2) write the interpreter of the language:
56
+
```
57
+
//MyInterpreter.java file
58
+
class MyInterpreter implements Interpreter{
59
+
60
+
@TerminalToken(type="yourLanguage.myToken") //bind the "firstToken" method to the "myToken" token
61
+
private String firstToken(){
62
+
return "myToken";
63
+
}
64
+
65
+
@TerminalToken(type="yourLanguage.mySecondToken") //bind the "secondToken" method to the "mySecondToken" token
66
+
private String secondToken(SyntaxTree tree){
67
+
return tree.token();
68
+
}
69
+
70
+
@NonTerminalToken(ruleHead="yourLanguage.axiom", ruleProduction = {"yourLanguage.nonTerminal", "$yourLanguage.myToken"}) //bind the "computeAxiom" method to the non-temrinal "axiom"
0 commit comments