Skip to content

Commit

Permalink
feat(objectionary#2665): grammar + test + todo
Browse files Browse the repository at this point in the history
  • Loading branch information
maxonfjvipon committed Dec 4, 2023
1 parent 98c0d20 commit a094602
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion eo-parser/src/main/antlr4/org/eolang/parser/Program.g4
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ version
;

// Binding
as : COLON (NAME | RHO)
as : COLON (NAME | RHO | INT)
;

// Data
Expand Down
3 changes: 3 additions & 0 deletions eo-parser/src/main/java/org/eolang/parser/ParsingTrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
* Train of XSL shifts.
*
* @since 0.1
* @todo #2665:30min Check negative int bindings via xsl. It's possible now to make application
* with integer bindings like {@code x a:0 b:1}. Need to add xsl transformation that would check
* if such binding is negative and would add an error to "errors" section.
*/
public final class ParsingTrain extends TrEnvelope {

Expand Down
4 changes: 3 additions & 1 deletion eo-parser/src/main/java/org/eolang/parser/XeListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -951,8 +951,10 @@ public void exitVersion(final ProgramParser.VersionContext ctx) {
public void enterAs(final ProgramParser.AsContext ctx) {
this.objects.enter();
final String has;
if (ctx.RHO() == null) {
if (ctx.NAME() != null) {
has = ctx.NAME().getText();
} else if (ctx.INT() != null) {
has = ctx.INT().getText();
} else {
has = "^";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ tests:
- //o[@base='string']
- //o[@name='hello' and @const]
- //o[@as='i']
- //o[@as='1']
- //o[@as='0']
- //o[@base='&']
- //o[@base='.<']
- //o[@base='.five']
Expand Down Expand Up @@ -55,8 +57,8 @@ eo: |
"家"
f'
z'
(z 5):hey
z:hoi
(z 5):0
z:1
a.
b.
c.
Expand Down

0 comments on commit a094602

Please sign in to comment.