Esempio n. 1
0
 public Parser(RemarkList remarkList)
 {
     this.remarkList = remarkList;
     parsers         = new List <ParseElement>
     {
         ParseIdent,
         ParseInt,
         ParseChar,
         ParseText,
         ParseBool,
         ParseVarOrLet,
         ParseFn,
         ParseWhen,
         ParseLoop,
         ParseBreak,
         ParseContinue,
         ParseReturn,
         ParseThrow,
         ParseTry,
         ParseSequence,
         ParseSingleBraced,
         ParseArr,
         ParseNew,
         ParseImport
     };
 }
Esempio n. 2
0
        public TokenIterator(string filePath, IEnumerable <Token> tokens, RemarkList remarkList)
        {
            C.Nn(tokens);

            this.remarkList = remarkList;
            FilePath        = filePath;
            te      = tokens.GetEnumerator();
            Current = new Token(TokenType.None, "");
        }
Esempio n. 3
0
        internal Prog(TextWriter outputWriter, TextWriter errorWriter, bool checkTypes)
        {
            Interpreter = new Interpreter();
            RemarkList  = new RemarkList(this);

            OutputWriter  = outputWriter;
            OutputPrinter = new Printer(new PlainTextCodeWriter(outputWriter), false);

            ErrorWriter  = errorWriter;
            ErrorPrinter = new Printer(new PlainTextCodeWriter(errorWriter), true);

            CheckTypes = checkTypes;
        }
Esempio n. 4
0
        private static IReadOnlyList <string> getAllCodeFiles(string rootPath, RemarkList remarkList)
        {
            var files = new List <string>();

            if (Directory.Exists(rootPath))
            {
                files.AddRange(Directory.EnumerateFiles(rootPath, "*.ef", SearchOption.AllDirectories));
            }
            else if (File.Exists(rootPath))
            {
                if (!rootPath.EndsWith(".ef"))
                {
                    throw remarkList.OnlyEfFilesAreSupported(rootPath);
                }
                files.AddValue(rootPath);
            }
            else
            {
                throw remarkList.CouldNotLocateFileOrFolder(rootPath);
            }

            return(files.Distinct().ToList());
        }
Esempio n. 5
0
        private static QualifiedIdent getStartQualifiedName(List <ClassItem> modules, RemarkList remarkList)
        {
            var candidates = new List <List <string> >();

            findStart(modules, candidates, new List <string>());
            // todo print candidates if multiple
            if (candidates.Count != 1)
            {
                throw remarkList.CannotFindStartFunction();
            }
            var fn = candidates[0]
                     .Append("start")
                     .Select(section => (QualifiedIdent) new Ident(section, TokenType.Ident))
                     .Aggregate((a, b) => new MemberAccess(a, (Ident)b));

            return(fn);
        }
Esempio n. 6
0
 public static List <SequenceItem> AsSequenceItems(this IEnumerable <Element> elements, RemarkList remarkList)
 {
     return(ManyAs <SequenceItem>(elements, remarkList.ExpectedSequenceElement).ToList());
 }
Esempio n. 7
0
 public static List <ClassItem> AsClassItems(this IEnumerable <Element> elements, RemarkList remarkList)
 {
     return(ManyAs <ClassItem>(elements, remarkList.ExpectedClassElement).ToList());
 }