Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Irony.Parsing;
- namespace Irony.Samples.Strings
- {
- [Language("Strings", "1.0", "Strings 1.0 Grammar")]
- public class StringsGrammar : Irony.Parsing.Grammar
- {
- public StringsGrammar()
- {
- var napisCudzyslow = new StringLiteral("stringCudzyslow", "'", StringOptions.AllowsDoubledQuote);
- var napis = new RegexBasedTerminal("napis", @"\w+");
- var integer = new RegexBasedTerminal("integer", "[0-9]+");
- var obiekt = new RegexBasedTerminal("obiekt", @"^[a-zA-Z]\w+");
- var plus = ToTerm("+");
- var porownaj = ToTerm("porownaj");
- var wydziel = ToTerm("wydziel");
- var koniec = ToTerm(";");
- NonTerminal n = new NonTerminal("napis");
- NonTerminal funkcjaPorownaj = new NonTerminal("funkcjaPorownaj");
- NonTerminal funkcjaWydziel = new NonTerminal("funkcjaWydziel");
- funkcjaPorownaj.Rule = porownaj + "(" + n + "," + n + ")" + ";";
- funkcjaWydziel.Rule = obiekt + "." + wydziel + "(" + integer + "," + integer + ")" + ";" | obiekt + "." + wydziel + "(" + integer + ")" + ";";
- n.Rule = napisCudzyslow | napis;
- this.Root = funkcjaWydziel;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement