forked from korsakov/ohcount
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OTWO-3077 Expand Grace lang test cases
- Loading branch information
Showing
5 changed files
with
102 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Sample Grace code | ||
|
||
import "parsers-test" as parsers | ||
|
||
class exports { | ||
def program = rule {codeSequence ~ rep(ws) ~ end} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// Sample Grace code | ||
print "OK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,46 @@ | ||
grace lcomment // Sample Grace code | ||
grace lcode print "OK" | ||
grace comment ////////////////////////////////////////////////// | ||
grace comment // Sample Grace code | ||
grace blank | ||
grace code import "parsers-test" as parsers | ||
grace blank | ||
grace code class exports { | ||
grace code inherit parsers.exports | ||
grace comment //BEGINGRAMMAR | ||
grace comment // top level | ||
grace code def program = rule {codeSequence ~ rep(ws) ~ end} | ||
grace code def codeSequence = rule { repdel((declaration | statement | empty), semicolon) } | ||
grace code def hashLine = rule { (symbol "#") ~ rep(anyChar | space) ~ (newLine | end) } | ||
grace blank | ||
grace comment // def comment = | ||
grace blank | ||
grace comment //def oldClassDeclaration = rule { classId ~ identifier ~ lBrace ~ | ||
grace comment // opt(genericFormals ~ blockFormals ~ arrow) ~ codeSequence ~ rBrace } | ||
grace blank | ||
grace code def typeOpExpression = rule { rep1sep(basicTypeExpression, typeOp) } | ||
grace blank | ||
grace code def typeOpExpression = rule { | ||
grace code var otherOperator | ||
grace code basicTypeExpression ~ opt(ws) ~ | ||
grace code opt( guard(typeOp, { s -> otherOperator:= s; | ||
grace code true }) ~ rep1sep(basicTypeExpression ~ opt(ws), | ||
grace code guard(typeOp, { s -> s == otherOperator }) | ||
grace code ) | ||
grace code ) | ||
grace code } | ||
grace blank | ||
grace comment // "literals" | ||
grace code def literal = rule { stringLiteral | selfLiteral | blockLiteral | numberLiteral | objectLiteral | lineupLiteral | typeLiteral } | ||
grace blank | ||
grace comment // terminals | ||
grace code def backslash = token "\\" // doesn't belong here, doesn't work if left below! | ||
grace blank | ||
grace code def colon = rule {both(symbol ":", not(assign))} | ||
grace code def newLine = symbol "\n" | ||
grace code def lParen = symbol "(" | ||
grace code def rParen = symbol ")" | ||
grace blank | ||
grace code def reservedOp = rule {assign | equals | dot | arrow | colon | semicolon} // this is not quite right | ||
grace blank | ||
grace comment //ENDGRAMMAR | ||
grace code } | ||
grace blank |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,46 @@ | ||
////////////////////////////////////////////////// | ||
// Sample Grace code | ||
print "OK" | ||
|
||
import "parsers-test" as parsers | ||
|
||
class exports { | ||
inherit parsers.exports | ||
//BEGINGRAMMAR | ||
// top level | ||
def program = rule {codeSequence ~ rep(ws) ~ end} | ||
def codeSequence = rule { repdel((declaration | statement | empty), semicolon) } | ||
def hashLine = rule { (symbol "#") ~ rep(anyChar | space) ~ (newLine | end) } | ||
|
||
// def comment = | ||
|
||
//def oldClassDeclaration = rule { classId ~ identifier ~ lBrace ~ | ||
// opt(genericFormals ~ blockFormals ~ arrow) ~ codeSequence ~ rBrace } | ||
|
||
def typeOpExpression = rule { rep1sep(basicTypeExpression, typeOp) } | ||
|
||
def typeOpExpression = rule { | ||
var otherOperator | ||
basicTypeExpression ~ opt(ws) ~ | ||
opt( guard(typeOp, { s -> otherOperator:= s; | ||
true }) ~ rep1sep(basicTypeExpression ~ opt(ws), | ||
guard(typeOp, { s -> s == otherOperator }) | ||
) | ||
) | ||
} | ||
|
||
// "literals" | ||
def literal = rule { stringLiteral | selfLiteral | blockLiteral | numberLiteral | objectLiteral | lineupLiteral | typeLiteral } | ||
|
||
// terminals | ||
def backslash = token "\\" // doesn't belong here, doesn't work if left below! | ||
|
||
def colon = rule {both(symbol ":", not(assign))} | ||
def newLine = symbol "\n" | ||
def lParen = symbol "(" | ||
def rParen = symbol ")" | ||
|
||
def reservedOp = rule {assign | equals | dot | arrow | colon | semicolon} // this is not quite right | ||
|
||
//ENDGRAMMAR | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters