Skip to content

Commit

Permalink
Merge pull request #25 from 422404/feature/put-statement
Browse files Browse the repository at this point in the history
Add 'put' statement to print values without new line
  • Loading branch information
422404 committed Jun 10, 2021
2 parents 5f2e93c + 00cbe21 commit 1356a0e
Show file tree
Hide file tree
Showing 24 changed files with 726 additions and 499 deletions.
Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/syntax.doctree
Binary file not shown.
12 changes: 12 additions & 0 deletions docs/_build/html/_sources/syntax.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ Prints three lines::
9
true

To print values without new lines, you can use:

.. code-block::
put "hello"
put 42
Prints::

hello42

Actor behavior definition
-------------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/_build/html/searchindex.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions docs/_build/html/syntax.html
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,15 @@ <h2>Printing data<a class="headerlink" href="#printing-data" title="Permalink to
<span class="n">true</span>
</pre></div>
</div>
<p>To print values without new lines, you can use:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">put</span> <span class="s2">&quot;hello&quot;</span>
<span class="n">put</span> <span class="mi">42</span>
</pre></div>
</div>
<p>Prints:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">hello42</span>
</pre></div>
</div>
</div>
<div class="section" id="actor-behavior-definition">
<h2>Actor behavior definition<a class="headerlink" href="#actor-behavior-definition" title="Permalink to this headline"></a></h2>
Expand Down
12 changes: 12 additions & 0 deletions docs/syntax.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ Prints three lines::
9
true

To print values without new lines, you can use:

.. code-block::
put "hello"
put 42
Prints::

hello42

Actor behavior definition
-------------------------

Expand Down
5 changes: 5 additions & 0 deletions src/main/antlr/org/actorlang/antlr/gen/ActorLang.g4
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ If: 'if';
Else: 'else';
For: 'for';
In: 'in';
Put: 'put';

Identifier: [a-zA-Z_][a-zA-Z0-9_]*;

Expand Down Expand Up @@ -143,10 +144,13 @@ behaviorStmt:
| assignStmt
| ifStmt
| forStmt
| putStmt
;

displayStmt: Display expr;

putStmt: Put expr;

becomeStmt: Become parameterizedBehavior;

sendStmt: Send LBracket (expr (Comma expr)*)? RBracket To identifier;
Expand Down Expand Up @@ -181,6 +185,7 @@ toplevelStmt:
| sendStmt
| assignStmt
| forStmt
| putStmt
;

root: (toplevelStmt (Semi toplevelStmt)* Semi?)? EOF;
5 changes: 4 additions & 1 deletion src/main/java/org/actorlang/antlr/gen/ActorLang.interp

Large diffs are not rendered by default.

86 changes: 44 additions & 42 deletions src/main/java/org/actorlang/antlr/gen/ActorLang.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,31 @@ If=13
Else=14
For=15
In=16
Identifier=17
LParen=18
RParen=19
LBracket=20
RBracket=21
LCurly=22
RCurly=23
Comma=24
Semi=25
Assign=26
Eq=27
Neq=28
Lower=29
Leq=30
Greater=31
Geq=32
And=33
Or=34
Plus=35
Minus=36
Star=37
Slash=38
Percent=39
Not=40
Put=17
Identifier=18
LParen=19
RParen=20
LBracket=21
RBracket=22
LCurly=23
RCurly=24
Comma=25
Semi=26
Assign=27
Eq=28
Neq=29
Lower=30
Leq=31
Greater=32
Geq=33
And=34
Or=35
Plus=36
Minus=37
Star=38
Slash=39
Percent=40
Not=41
'..'=1
'true'=5
'false'=6
Expand All @@ -51,21 +52,22 @@ Not=40
'else'=14
'for'=15
'in'=16
'('=18
')'=19
'['=20
']'=21
'{'=22
'}'=23
','=24
';'=25
'=='=27
'<'=29
'>'=31
'&&'=33
'||'=34
'+'=35
'-'=36
'*'=37
'/'=38
'%'=39
'put'=17
'('=19
')'=20
'['=21
']'=22
'{'=23
'}'=24
','=25
';'=26
'=='=28
'<'=30
'>'=32
'&&'=34
'||'=35
'+'=36
'-'=37
'*'=38
'/'=39
'%'=40
12 changes: 12 additions & 0 deletions src/main/java/org/actorlang/antlr/gen/ActorLangBaseListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,18 @@ public class ActorLangBaseListener implements ActorLangListener {
* <p>The default implementation does nothing.</p>
*/
@Override public void exitDisplayStmt(ActorLangParser.DisplayStmtContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterPutStmt(ActorLangParser.PutStmtContext ctx) { }
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void exitPutStmt(ActorLangParser.PutStmtContext ctx) { }
/**
* {@inheritDoc}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ public class ActorLangBaseVisitor<T> extends AbstractParseTreeVisitor<T> impleme
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitDisplayStmt(ActorLangParser.DisplayStmtContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
* <p>The default implementation returns the result of calling
* {@link #visitChildren} on {@code ctx}.</p>
*/
@Override public T visitPutStmt(ActorLangParser.PutStmtContext ctx) { return visitChildren(ctx); }
/**
* {@inheritDoc}
*
Expand Down

0 comments on commit 1356a0e

Please sign in to comment.