Skip to content

Commit

Permalink
focal
Browse files Browse the repository at this point in the history
  • Loading branch information
teverett committed Oct 24, 2020
1 parent b322fad commit 24730a2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
6 changes: 6 additions & 0 deletions focal/examples/example1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
01.03 ASK "A1",A1,"OMEGA",W,"T0",T0,"DAMPING FACTOR",DAMPINGFACTOR
01.15 DO 7.24
01.16 DO 8
01.01 COMMENT: THE SUMER GAME, BY RICHARD MERRILL
01.01 FOR X=1,10; TYPE X,!
01.02 FOR X=0,10,100; DO 2
01.05 GOTO 1.01
Expand All @@ -17,3 +18,8 @@
01.20 QUIT
02.20 IF (25-25) 2.4,2.3,2.4
03.01 IF (X) 3.1,3.02,3.1
22.80 ASK "ANSWER YES OR NO ? ",AN
22.86 SET X=2;RETURN
22.88 SET X=1;RETURN
01.30 SET PI=3.14156
01.60 SET INTEREST=PRINCIPAL*(RATE/100)*TERM
24 changes: 19 additions & 5 deletions focal/focal.g4
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ command
| goto_
| if_
| type
| return_
| write_
| comment
;

ask
Expand All @@ -79,7 +82,7 @@ quit
;

set
: ('SET' | 'S') VARIABLE '=' expression
: ('SET' | 'S') VARIABLE '=' expression (';' command)?
;

goto_
Expand All @@ -102,6 +105,18 @@ typeexpression
| ('%' INTEGER '.' INTEGER)
;

return_
: 'RETURN'
;

write_
: 'WRITE' (grpnum | linenum)?
;

comment
: COMMENT
;

expression
: primary (PLUSMIN primary)*
;
Expand Down Expand Up @@ -178,11 +193,10 @@ BUILTIN
STRING_LITERAL
: '"' .*? '"'
;
//COMMENT

// : 'COMMENT' ~ [\r\n]* -> skip

// ;
COMMENT
: 'COMMENT' ~ [\r\n]*
;

WS
: [ \r\n\t]+ -> skip
Expand Down
4 changes: 2 additions & 2 deletions focal/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<artifactId>antlr4test-maven-plugin</artifactId>
<version>${antlr4test-maven-plugin.version}</version>
<configuration>
<verbose>true</verbose>
<showTree>true</showTree>
<verbose>false</verbose>
<showTree>false</showTree>
<entryPoint>prog</entryPoint>
<grammarName>focal</grammarName>
<packageName></packageName>
Expand Down

0 comments on commit 24730a2

Please sign in to comment.