Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/update categories to Rascal grammar #2083

Merged
merged 9 commits into from
Dec 9, 2024
56 changes: 28 additions & 28 deletions src/org/rascalmpl/library/lang/rascal/syntax/Rascal.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ lexical BooleanLiteral
| "false" ;

syntax Literal
= integer: IntegerLiteral integerLiteral
| regExp: RegExpLiteral regExpLiteral
| \real: RealLiteral realLiteral
= @category="number" integer: IntegerLiteral integerLiteral
| @category="regexp" regExp: RegExpLiteral regExpLiteral
| @category="number" \real: RealLiteral realLiteral
| boolean: BooleanLiteral booleanLiteral
| string: StringLiteral stringLiteral
| dateTime: DateTimeLiteral dateTimeLiteral
| location: LocationLiteral locationLiteral
| rational: RationalLiteral rationalLiteral
| @category="string" location: LocationLiteral locationLiteral
| @category="number" rational: RationalLiteral rationalLiteral
;

syntax Expression = concrete: Concrete concrete;
Expand All @@ -36,13 +36,13 @@ lexical Concrete
= typed: "(" LAYOUTLIST l1 Sym symbol LAYOUTLIST l2 ")" LAYOUTLIST l3 "`" ConcretePart* parts "`";

lexical ConcretePart
= @category="MetaSkipped" text : ![`\<\>\\\n]+ !>> ![`\<\>\\\n]
= @category="string" text : ![`\<\>\\\n]+ !>> ![`\<\>\\\n]
| newline: "\n" [\ \t \u00A0 \u1680 \u2000-\u200A \u202F \u205F \u3000]* "\'"
| @category="MetaVariable" hole : ConcreteHole hole
| @category="MetaSkipped" lt: "\\\<"
| @category="MetaSkipped" gt: "\\\>"
| @category="MetaSkipped" bq: "\\`"
| @category="MetaSkipped" bs: "\\\\"
| @category="string" hole : ConcreteHole hole
| @category="string" lt: "\\\<"
| @category="string" gt: "\\\>"
| @category="string" bq: "\\`"
| @category="string" bs: "\\\\"
;

syntax ConcreteHole
Expand Down Expand Up @@ -308,10 +308,10 @@ syntax StringTemplate
| \while : "while" "(" Expression condition ")" "{" Statement* preStats StringMiddle body Statement* postStats "}" ;

lexical PreStringChars
= @category="Constant" [\"] StringCharacter* [\<] ;
= @category="string" [\"] StringCharacter* [\<] ;

lexical CaseInsensitiveStringConstant
= @category="Constant" "\'" StringCharacter* chars "\'" ;
= @category="string" "\'" StringCharacter* chars "\'" ;

lexical Backslash
= [\\] !>> [/ \< \> \\] ;
Expand Down Expand Up @@ -373,7 +373,7 @@ syntax Assignable
| annotation : Assignable receiver "@" Name annotation ;

lexical StringConstant
= @category="Constant" "\"" StringCharacter* chars "\"" ;
= @category="string" "\"" StringCharacter* chars "\"" ;



Expand Down Expand Up @@ -404,7 +404,7 @@ lexical JustTime
;

lexical MidStringChars
= @category="Constant" [\>] StringCharacter* [\<] ;
= @category="string" [\>] StringCharacter* [\<] ;

lexical ProtocolChars
= [|] URLChars "://" !>> [\t-\n \r \ \u00A0 \u1680 \u2000-\u200A \u202F \u205F \u3000];
Expand Down Expand Up @@ -445,7 +445,7 @@ lexical RegExp
| [\\] [/ \< \> \\]
| "\<" Name ":" NamedRegExp* "\>"
| Backslash
// | @category="MetaVariable" [\<] Expression expression [\>] TODO: find out why this production existed
// | @category="variable" [\<] Expression expression [\>] TODO: find out why this production existed
;


Expand Down Expand Up @@ -536,9 +536,9 @@ start syntax EvalCommand
;

lexical Output
= @category="Result" resultOutput: "⇨" ![\n\r]* [\n]
| @category="StdOut" stdoutOutput: ^ "≫" ![\n\r]* [\n]
| @category="StdErr" stderrOutput: ^ "⚠" ![\n\r]* [\n]
= @category="string" resultOutput: "⇨" ![\n\r]* [\n]
| @category="string" stdoutOutput: ^ "≫" ![\n\r]* [\n]
| @category="string" stderrOutput: ^ "⚠" ![\n\r]* [\n]
;

start syntax Command
Expand Down Expand Up @@ -573,8 +573,8 @@ syntax StringLiteral
| nonInterpolated: StringConstant constant ;

lexical Comment
= @category="Comment" "/*" (![*] | [*] !>> [/])* "*/"
| @category="Comment" "//" ![\n]* !>> [\ \t\r \u00A0 \u1680 \u2000-\u200A \u202F \u205F \u3000] $ // the restriction helps with parsing speed
= @category="comment" "/*" (![*] | [*] !>> [/])* "*/"
| @category="comment" "//" ![\n]* !>> [\ \t\r \u00A0 \u1680 \u2000-\u200A \u202F \u205F \u3000] $ // the restriction helps with parsing speed
;


Expand Down Expand Up @@ -789,7 +789,7 @@ syntax Toplevel
= givenVisibility: Declaration declaration ;

lexical PostStringChars
= @category="Constant" [\>] StringCharacter* [\"] ;
= @category="string" [\>] StringCharacter* [\"] ;

lexical HexIntegerLiteral
= [0] [X x] [0-9 A-F a-f]+ !>> [0-9 A-Z _ a-z] ;
Expand Down Expand Up @@ -823,9 +823,9 @@ syntax BasicType
;

lexical Char
= @category="Constant" "\\" [\ \" \' \- \< \> \[ \\ \] b f n r t]
| @category="Constant" ![\ \" \' \- \< \> \[ \\ \]]
| @category="Constant" UnicodeEscape
= @category="string" "\\" [\ \" \' \- \< \> \[ \\ \] b f n r t]
| @category="string" ![\ \" \' \- \< \> \[ \\ \]]
| @category="string" UnicodeEscape
;

syntax Prod
Expand Down Expand Up @@ -879,9 +879,9 @@ syntax Pattern
;

syntax Tag
= @Folded @category="Comment" \default : "@" Name name TagString contents
| @Folded @category="Comment" empty : "@" Name name
| @Folded @category="Comment" expression: "@" Name name "=" Expression expression !>> "@";
= @Folded @category="comment" \default : "@" Name name TagString contents
| @Folded @category="comment" empty : "@" Name name
| @Folded @category="comment" expression: "@" Name name "=" Expression expression !>> "@";

syntax ModuleActuals
= \default: "[" {Type ","}+ types "]" ;
Loading