예제 #1
0
 internal void Error79(LexSpan s)
 {
     Error(79, s);
     badCount++;
     if (badCount >= 3)
         yy_push_state(SKIP);
 }
예제 #2
0
 internal SemanticAction(Production production, int pos, LexSpan span)
 {
     this.production = production;
     this.pos = pos;
     this.codeSpan = span;
     commands = span.ToString();
 }
예제 #3
0
 internal void AddVisibility( LexSpan span ) {
     string result = span.ToString();
     if (result.Equals( "internal" ) || result.Equals( "public" ))
         visibility = result;
     else
         hdlr.ListError( span, 98 );
 }
예제 #4
0
 internal void AddCodeSpan( Destination dest, LexSpan span ) {
     if (!span.IsInitialized) return;
     switch (dest) {
         case Destination.codeIncl: CodeIncl.Add( span ); break;
         case Destination.scanProlog: Prolog.Add( span ); break;
         case Destination.scanEpilog: Epilog.Add( span ); break;
     }
 }
예제 #5
0
 internal void Error(int n, LexSpan s)
 {
     // Console.WriteLine(StateStack(YY_START));
     if (yyhdlr != null)
     {
         yyhdlr.ListError(s, n);
     }
 }
예제 #6
0
 internal void Error79(LexSpan s)
 {
     Error(79, s);
     badCount++;
     if (badCount >= 3)
     {
         yy_push_state(Scanner.SKIP);
     }
 }
예제 #7
0
        public TypeToken(LexSpan lex)
            : base(SyntaxKind.Type, lex)
        {
            TypeEnum t;

            if (Enum.TryParse(lex.text, true, out t))
            {
                Value = t;
            }
        }
예제 #8
0
        internal static void CheckSpan(int len, LexSpan span, ErrorHandler hdlr)
        {
            ActionScanner scnr = new ActionScanner();

            scnr.SetSource(span.ToString(), 1);
            scnr.length  = len;
            scnr.src     = span;
            scnr.handler = hdlr;
            scnr.lineNo  = span.startLine;
            scnr.colNo   = span.startColumn;
            scnr.yylex();
        }
예제 #9
0
 public override void yyerror(string format, params object[] args)
 {
     if (yyhdlr != null)
     {
         LexSpan span = TokenSpan();
         if (args == null || args.Length == 0)
         {
             yyhdlr.AddError(2, format, span);
         }
         else
         {
             yyhdlr.AddError(3, String.Format(CultureInfo.InvariantCulture, format, args), span);
         }
     }
 }
예제 #10
0
 public BracketToken(LexSpan lex)
     : base(lex.token == (int)Compiler.Tokens.lBrac ? SyntaxKind.OpenBracket : SyntaxKind.CloseBracket, lex)
 {
 }
예제 #11
0
 internal void ListError( ErrorHandler handler, LexSpan span ) {
     if (text == null)
         handler.ListError( span.FirstLineSubSpan( index, length ), errNo );
     else
         handler.ListError( span.FirstLineSubSpan( index, length ), errNo, text );
 }
예제 #12
0
        // ============== The main tokenizer code =================

        int Scan()
        {
// User-specified prolog to scan()
LexSpan comStart = null;
    LexSpan errStart = null;
    LexSpan errEnd   = null;
    int braceNestingLevel = 0;
// End, user-specified prolog
            try {
                for (; ; )
                {
                    int next;              // next state to enter                   
#if BACKUP
                    Result rslt = Result.noMatch;
#endif // BACKUP
#if LEFTANCHORS
                    for (;;)
                    {
                        // Discard characters that do not start any pattern.
                        // Must check the left anchor condition after *every* GetCode!
                        state = ((cCol == 0) ? anchorState[currentScOrd] : currentStart);
                        if ((next = NextState()) != goStart) 
                            break; // LOOP EXIT HERE...
                        GetCode();
                    }
                    
#else // !LEFTANCHORS
                    state = currentStart;
                    while ((next = NextState()) == goStart)
                        // At this point, the current character has no
                        // transition from the current state.  We discard 
                        // the "no-match" char.   In traditional LEX such 
                        // characters are echoed to the console.
                        GetCode();
#endif // LEFTANCHORS                    
                    // At last, a valid transition ...    
                    MarkToken();
                    state = next;
                    GetCode();
                    
                    while ((next = NextState()) > eofNum) // Exit for goStart AND for eofNum
#if BACKUP
                        if (state <= maxAccept && next > maxAccept) // need to prepare backup data
                        {
                            // ctx is an object. The fields may be 
                            // mutated by the call to Recurse2.
                            // On return the data in ctx is the
                            // *latest* accept state that was found.
                            
                            rslt = Recurse2(ref ctx, next);
                            if (rslt == Result.noMatch) 
                                RestoreStateAndPos(ref ctx);
                            break;
                        }
                        else
#endif // BACKUP
                        {
                            state = next;
                            GetCode();
                        }
                    if (state <= maxAccept) 
                    {
                        MarkEnd();
#region ActionSwitch
#pragma warning disable 162, 1522
    switch (state)
    {
        case eofNum:
            switch (currentStart) {
                case 124:
yy_pop_state(); yyless(0);
                    break;
                case 61:
Error(53, comStart); /* This comment is unterminated */
                    break;
                case 134:
if (braceNestingLevel != 0)
                                  Error(55, TokenSpan()); 
                              yy_pop_state(); 
                              yyless(0); 
                              return (int)Token.codeEnd;
                    break;
            }
            if (yywrap())
                return (int)Token.EOF;
            break;
        case 1: // Recognized '{NotWh}',	Shortest string "/"
        case 2: // Recognized '{NotWh}',	Shortest string "*"
        case 3: // Recognized '{NotWh}',	Shortest string "^%"
        case 8: // Recognized '{NotWh}',	Shortest string "'"
        case 9: // Recognized '{NotWh}',	Shortest string "\""
        case 21: // Recognized '{NotWh}',	Shortest string "%"
        case 23: // In <TheRules> Recognized '{NotWh}',	Shortest string "^%"
        case 27: // In <TheRules> Recognized '{NotWh}',	Shortest string "\""
        case 33: // In <TheRules> Recognized '{NotWh}',	Shortest string "%"
        case 71: // In <CodeBlock> Recognized '{NotWh}',	Shortest string "'"
Error(57, TokenSpan());
            break;
        case 4: // Recognized '{OpChars}',	Shortest string "{"
return (int)(yytext[0]);
            break;
        case 5: // Recognized '{Ident}',	Shortest string "G"
return (int)Token.ident;
            break;
        case 6: // Recognized '{Number}',	Shortest string "8"
        case 7: // Recognized '{Number}',	Shortest string "0"
yylval.iVal = ParseDecimal(yytext); return (int)Token.number;
            break;
        case 10: // Recognized '{BadStr}/[\r\n]',	Shortest string "\"\r"
_yytrunc(1); 
Error(58, TokenSpan());
            break;
        case 11: // Recognized '{LitStr}',	Shortest string "\"\""
return (int)Token.litstring;
            break;
        case 12: // Recognized '{LitChr}',	Shortest string "'/'"
return (int)Token.litchar;
            break;
        case 13: // Recognized '{HexNumber}',	Shortest string "0x8"
yylval.iVal = ParseHexaDec(yytext); return (int)Token.number;
            break;
        case 14: // Recognized '%{NotWh}',	Shortest string "%/"
Error(50, TokenSpan());
            break;
        case 15: // Recognized '^%%',	Shortest string "^%%"
yy_clear_stack();
                              BEGIN(TheRules); 
                              yy_push_state(ShouldBeBlank); errStart = null;
                              return (int)Token.kwPCPC;
            break;
        case 16: // Recognized '^%\{',	Shortest string "^%{"
yy_push_state(Prolog); 
                              yy_push_state(ShouldBeBlank); errStart = null;
                              return (int)Token.kwLbrace;
            break;
        case 17: // Recognized '^%{Ident}',	Shortest string "^%G"
{
                                  Token kWord = GetKeyword(yytext); 
                                  if (kWord == Token.kwOutput || kWord == Token.kwImportTokens)
                                      BEGIN(GetPath);
                                  return (int)kWord;
                              }
            break;
        case 18: // Recognized '^%\}',	Shortest string "^%}"
return (int)Token.kwRbrace; /* But a syntax error! */
            break;
        case 19: // Recognized '{OneLineCmnt}',	Shortest string "//"
/* skip */
            break;
        case 20: // Recognized '{CmntStrt}',	Shortest string "/*"
        case 57: // In <GetPath> Recognized '{CmntStrt}',	Shortest string "/*"
yy_push_state(Comment); 
                              comStart = TokenSpan(); 
                              /* And no token returned */
            break;
        case 22: // Recognized '\%{Ident}',	Shortest string "%G"
{   // An error, but attempt recovery
                                  Token kWord = GetKeyword(yytext); 
                                  if (kWord != Token.errTok)
                                      Error(59, TokenSpan());
                                  if (kWord == Token.kwOutput || kWord == Token.kwImportTokens)
                                      BEGIN(GetPath);
                                  return (int)kWord;
                              }
            break;
        case 24: // In <TheRules> Recognized '\{',	Shortest string "{"
yy_push_state(Action); 
                        braceNestingLevel = 1; 
                        return (int)'{';
            break;
        case 25: // In <TheRules> Recognized '^{Ident}',	Shortest string "^G"
return (int)Token.anchoredSymbol;
            break;
        case 26: // In <TheRules> Recognized '\'',	Shortest string "'"
Error(58, TokenSpan());
            break;
        case 28: // In <TheRules> Recognized '{OpChars}',	Shortest string ","
return (int)(yytext[0]);
            break;
        case 29: // In <TheRules> Recognized '{LitStr}',	Shortest string "\"\""
return (int)Token.litstring;
            break;
        case 30: // In <TheRules> Recognized '{LitChr}',	Shortest string "'/'"
return (int)Token.litchar;
            break;
        case 31: // In <TheRules> Recognized '^%%',	Shortest string "^%%"
yy_clear_stack();
                        BEGIN(TheEpilog); 
                        yy_push_state(ShouldBeBlank); errStart = null;
                        return (int)Token.kwPCPC;
            break;
        case 32: // In <TheRules> Recognized '\%{Ident}',	Shortest string "%G"
return (int)GetKeyword(yytext);
            break;
        case 34: // In <TheRules> Recognized '{Ident}',	Shortest string "G"
return (int)Token.ident;
            break;
        case 35: // In <TheEpilog> Recognized '.',	Shortest string "/"
        case 36: // In <TheEpilog> Recognized '.',	Shortest string "\t"
        case 37: // In <TheEpilog> Recognized '.',	Shortest string "%"
        case 38: // In <TheEpilog> Recognized '.',	Shortest string "\""
        case 58: // In <Prolog> Recognized '.',	Shortest string "^%"
yy_push_state(CodeBlock); yyless(0); return (int)Token.codeStart;
            break;
        case 39: // In <TheEpilog> Recognized '{OneLineCmnt}',	Shortest string "//"
yy_push_state(CodeBlock);  
                              return (int)Token.codeStart;
            break;
        case 40: // In <TheEpilog> Recognized '{CmntStrt}',	Shortest string "/*"
yy_push_state(CodeBlock); 
                              yy_push_state(Comment); 
                              comStart = TokenSpan(); 
                              return (int)Token.codeStart;
            break;
        case 41: // In <GetPath> Recognized '{Eol}',	Shortest string ""
        case 44: // In <GetPath> Recognized '{Eol}',	Shortest string "\r"
BEGIN(0);
            break;
        case 42: // In <GetPath> Recognized '{NotWh}+',	Shortest string "/"
        case 43: // In <GetPath> Recognized '{NotWh}+',	Shortest string "*"
        case 45: // In <GetPath> Recognized '{NotWh}+',	Shortest string "\""
        case 46: // In <GetPath> Recognized '{NotWh}+',	Shortest string "@"
        case 48: // In <GetPath> Recognized '{NotWh}+',	Shortest string "@\""
        case 49: // In <GetPath> Recognized '{NotWh}+',	Shortest string "@\"\\"
        case 54: // In <GetPath> Recognized '{NotWh}+',	Shortest string "\"\\"
return (int)Token.filePath;
            break;
        case 47: // In <GetPath> Recognized '={NotWh}*',	Shortest string "="
yyless(1); return (int)'=';
            break;
        case 50: // In <GetPath> Recognized '{VrbStr}',	Shortest string "@\"\""
        case 51: // In <GetPath> Recognized '{VrbStr}',	Shortest string "@\"\\\""
        case 52: // In <GetPath> Recognized '{VrbStr}',	Shortest string "@\"\t\""
        case 53: // In <GetPath> Recognized '{VrbStr}',	Shortest string "@\"\t\\\""
return (int)Token.verbatim;
            break;
        case 55: // In <GetPath> Recognized '{LitStr}',	Shortest string "\"\""
        case 56: // In <GetPath> Recognized '{LitStr}',	Shortest string "\"\x20\""
return (int)Token.litstring;
            break;
        case 59: // In <Prolog> Recognized '^%\}',	Shortest string "^%}"
if (braceNestingLevel != 0) {
                                  Error(55, TokenSpan()); braceNestingLevel = 0;
                              }
                              else {
                                  yy_pop_state(); return (int)Token.kwRbrace; 
                              }
            break;
        case 60: // In <Action> Recognized '\}',	Shortest string "}"
yy_pop_state(); return (int)'}';
            break;
        case 61: // In <Comment> Recognized '{ABStar}',	Shortest string ""
        case 62: // In <Comment> Recognized '{ABStar}',	Shortest string "/"
        case 63: // In <Comment> Recognized '\*',	Shortest string "*"
        case 64: // In <Comment> Recognized '{ABStar}',	Shortest string "%"
        case 65: // In <Comment> Recognized '{ABStar}',	Shortest string "\""
        case 66: // In <Comment> Recognized '{ABStar}',	Shortest string "\"\\"
/* skip */
            break;
        case 67: // In <Comment> Recognized '{CmntEnd}',	Shortest string "*/"
yy_pop_state();
                         // If comment has obscured one or more EOL then ...  
                         if (YY_START == ShouldBeBlank) {
                             if (errStart != null) {
                                 Error(54, errStart.Merge(errEnd));
                                 errStart = null;
                             } else if (lNum > comStart.startLine) 
                                 yy_pop_state();
                         }
                         /* And no token returned */
            break;
        case 68: // In <CodeBlock> Recognized '\/',	Shortest string "/"
        case 69: // In <CodeBlock> Recognized '\%',	Shortest string "^%"
        case 73: // In <CodeBlock> Recognized '@',	Shortest string "@"
        case 75: // In <CodeBlock> Recognized '{VrbStr}',	Shortest string "@\"\\\""
        case 76: // In <CodeBlock> Recognized '{LitStr}',	Shortest string "\"\""
        case 77: // In <CodeBlock> Recognized '\%{CodeSkip}+',	Shortest string "\t"
        case 80: // In <CodeBlock> Recognized '\%',	Shortest string "%"
/* skip */
            break;
        case 70: // In <CodeBlock> Recognized '\{',	Shortest string "{"
braceNestingLevel++;
            break;
        case 72: // In <CodeBlock> Recognized '{BadStr}',	Shortest string "\""
Error(58, TokenSpan());
            break;
        case 74: // In <CodeBlock> Recognized '\}',	Shortest string "}"
if (braceNestingLevel == 0 && 
                                       yy_top_state() == Action) {
                                  yy_pop_state();
                                  yyless(0);
                                  return (int)Token.codeEnd;
                              }
                              else
                                  braceNestingLevel--;
            break;
        case 78: // In <CodeBlock> Recognized '^%%',	Shortest string "^%%"
for ( ; ; ) {
                                  yy_pop_state();
                                  switch (YY_START)
                                  {
                                    case INITIAL: 
                                        Error(60, TokenSpan()); 
                                        return (int)Token.kwPCPC;
                                    case TheRules: 
                                        Error(60, TokenSpan());
                                        return (int)Token.kwPCPC;
                                    default: break; 
                                  }
                              }
            break;
        case 79: // In <CodeBlock> Recognized '^%\}',	Shortest string "^%}"
if (yy_top_state() != Prolog) {
                                  Error(56, TokenSpan()); yy_clear_stack(); BEGIN(Prolog);
                              } else if (braceNestingLevel != 0) {
                                  Error(55, TokenSpan());
                              } else {
                                  yy_pop_state();
                              } 
                              yyless(0); return (int)Token.codeEnd;
            break;
        case 81: // In <ShouldBeBlank> Recognized '{Eol}',	Shortest string ""
        case 84: // In <ShouldBeBlank> Recognized '{Eol}',	Shortest string "\r"
if (errStart != null)
                                  Error(54, errStart.Merge(errEnd)); 
                              yy_pop_state();
            break;
        case 82: // In <ShouldBeBlank> Recognized '{NotWh}',	Shortest string "/"
        case 83: // In <ShouldBeBlank> Recognized '{NotWh}',	Shortest string "*"
        case 85: // In <ShouldBeBlank> Recognized '{NotWh}',	Shortest string "%"
        case 86: // In <ShouldBeBlank> Recognized '{NotWh}',	Shortest string "\""
{
                                LexSpan cSpan = TokenSpan(); /* Only white space goes here */
                                errEnd = cSpan;
                                if (errStart == null) errStart = cSpan;
                              }
            break;
        default:
            break;
    }
#pragma warning restore 162, 1522
#endregion
                    }
                }
            } // end try
            finally {
// User-specified epilog to scan()
yylloc = new LexSpan(tokLin, tokCol, tokELin, tokECol, tokPos, tokEPos, buffer);
// End, user-specified epilog
            } // end finally
        }
예제 #13
0
        /// <summary>
        /// Add a user-specified character predicate to the 
        /// dictionary. The predicate is in some known assembly
        /// accessible to gplex.
        /// </summary>
        /// <param name="name">the gplex name of the predicate</param>
        /// <param name="aSpan">the simple filename of the assembly</param>
        /// <param name="mSpan">the qualified name of the method</param>
        internal void AddUserPredicate(
            string name,
            LexSpan aSpan,
            LexSpan mSpan ) {
            // maybe we need (1) type dotted name, (2) method name only?
            string mthName = mSpan.ToString();
            string asmName = aSpan.ToString();
            int offset = mthName.LastIndexOf( '.' );
            string clsName = mthName.Substring( 0, offset );
            string mthIdnt = mthName.Substring( offset + 1 );

            try {
                System.Reflection.Assembly asm = System.Reflection.Assembly.LoadFrom( asmName );
                System.Type[] types = asm.GetExportedTypes();
                foreach (Type type in types) {
                    if (type.FullName.Equals( clsName, StringComparison.OrdinalIgnoreCase ) ||
                        type.Name.Equals( clsName, StringComparison.OrdinalIgnoreCase )) {
                        QUT.Gplex.ICharTestFactory factory =
                            (ICharTestFactory)System.Activator.CreateInstance( type );

                        if (factory != null) {
                            CharTest test = factory.GetDelegate( mthIdnt );
                            if (test == null)
                                hdlr.ListError( mSpan, 97, mthIdnt );
                            else
                                AddUserPredicate( name, test );
                            return;
                        }
                    }
                }
                // Class not found error not reported until ALL
                // classes exported from the assembly have been checked.
                hdlr.ListError( mSpan, 96, clsName ); return;
            }
            catch (FileNotFoundException) { hdlr.ListError( aSpan, 94 ); }
            catch (FileLoadException) { hdlr.ListError( aSpan, 95 ); }
            catch (Exception x) { hdlr.AddError( x.Message, aSpan.Merge( mSpan ) ); throw; }
        }
예제 #14
0
 internal LexCategory( string nam, string vrb, LexSpan spn ) {
     vrbSpan = spn;
     verb = vrb;
     name = nam;
 }
예제 #15
0
 internal RuleDesc( LexSpan loc, LexSpan act, List<StartState> aList, bool bar ) {
     pSpan = loc;
     aSpan = act;
     pattern = pSpan.buffer.GetString( pSpan.startIndex, pSpan.endIndex );
     isBarAction = bar;
     list = aList;
     ord = next++;
 }
예제 #16
0
 public NotToken(LexSpan lex)
     : base(SyntaxKind.NotUnop, lex)
 {
 }
예제 #17
0
 public StopToken(LexSpan lex)
     : base(SyntaxKind.StopKeyword, lex)
 {
 }
예제 #18
0
 public CommaToken(LexSpan lex)
     : base(SyntaxKind.Comma, lex)
 {
 }
 public GlobalFunctionToken(LexSpan lex)
     : base(SyntaxKind.GlobalFunctionToken, lex)
 {
     FuncName = lex.text;
 }
예제 #20
0
 public ParenToken(LexSpan lex)
     : base(lex.token == (int)Compiler.Tokens.lPar ? SyntaxKind.OpenParen : SyntaxKind.CloseParen, lex)
 {
 }
예제 #21
0
 public ElseToken(LexSpan lex)
     : base(SyntaxKind.ElseKeyword, lex)
 {
 }
예제 #22
0
 public StringToken(LexSpan lex)
     : base(SyntaxKind.String, lex)
 {
     Value = lex.text;
 }
예제 #23
0
        // Modified code contributed by Emmo Emminghaus.
        private void InsertCodeSpan( LexSpan span ) {
            if (span != null) {
                string code = span.ToString();
                if (GPCG.Lines) {
                    Console.WriteLine( "#line {0} \"{1}\"", span.startLine, GPCG.LinesFilename ?? grammar.InputFilename );
                    for (int i = 0; i < span.startColumn; i++)
                        Console.Write( " " );
                }
                StringReader reader = new StringReader( code );
                string line;
                while ((line = reader.ReadLine()) != null)
                    Console.WriteLine( line );

                if (GPCG.Lines)
                    Console.WriteLine( "#line default" );
            }
        }
예제 #24
0
 public BraceToken(LexSpan lex)
     : base(lex.token == (int)Compiler.Tokens.lBrace ? SyntaxKind.OpenCurlyBrace : SyntaxKind.CloseCurlyBrace, lex)
 {
 }
예제 #25
0
 public ColonToken(LexSpan lex)
     : base(SyntaxKind.Colon, lex)
 {
 }
예제 #26
0
 public KeywordToken(SyntaxKind kind, LexSpan lex)
     : base(kind, lex)
 {
 }
예제 #27
0
        // ============== The main tokenizer code =================

        int Scan()
        {
            try {
                for (; ; )
                {
                    int next;              // next state to enter                   
#if BACKUP
                    Result rslt = Result.noMatch;
#endif // BACKUP
#if LEFTANCHORS
                    for (;;)
                    {
                        // Discard characters that do not start any pattern.
                        // Must check the left anchor condition after *every* GetCode!
                        state = ((cCol == 0) ? anchorState[currentScOrd] : currentStart);
                        if ((next = NextState()) != goStart) 
                            break; // LOOP EXIT HERE...
                        GetCode();
                    }
                    
#else // !LEFTANCHORS
                    state = currentStart;
                    while ((next = NextState()) == goStart)
                        // At this point, the current character has no
                        // transition from the current state.  We discard 
                        // the "no-match" char.   In traditional LEX such 
                        // characters are echoed to the console.
                        GetCode();
#endif // LEFTANCHORS                    
                    // At last, a valid transition ...    
                    MarkToken();
                    state = next;
                    GetCode();
                    
                    while ((next = NextState()) > eofNum) // Exit for goStart AND for eofNum
#if BACKUP
                        if (state <= maxAccept && next > maxAccept) // need to prepare backup data
                        {
                            // ctx is an object. The fields may be 
                            // mutated by the call to Recurse2.
                            // On return the data in ctx is the
                            // *latest* accept state that was found.
                            
                            rslt = Recurse2(ref ctx, next);
                            if (rslt == Result.noMatch) 
                                RestoreStateAndPos(ref ctx);
                            break;
                        }
                        else
#endif // BACKUP
                        {
                            state = next;
                            GetCode();
                        }
                    if (state <= maxAccept) 
                    {
                        MarkEnd();
#region ActionSwitch
#pragma warning disable 162
    switch (state)
    {
        case eofNum:
            switch (currentStart) {
                case 60:
Error(60, comStart);
                    break;
            }
            if (yywrap())
                return (int)Tokens.EOF;
            break;
        case 1: // Recognized '{Eol}',	Shortest string ""
        case 4: // Recognized '{Eol}',	Shortest string "\r"
ResetBadCount(); return (int)Tokens.EOL;
            break;
        case 2: // Recognized '{NotWh}',	Shortest string "^/"
        case 3: // Recognized '{NotWh}',	Shortest string "["
        case 6: // Recognized '{NotWh}',	Shortest string "^%"
        case 17: // Recognized '{NotWh}',	Shortest string "/"
        case 28: // In <RULES> Recognized '{NotWh}',	Shortest string "/"
        case 38: // In <UCODE> Recognized '{NotWh}',	Shortest string "\""
        case 45: // In <UCODE> Recognized '{NotWh}',	Shortest string "'"
        case 79: // In <REGEX> Recognized '{NotWh}',	Shortest string "["
        case 83: // In <REGEX> Recognized '{NotWh}',	Shortest string "\\"
        case 84: // In <REGEX> Recognized '{NotWh}',	Shortest string "\""
        case 89: // In <NMLST> Recognized '{NotWh}',	Shortest string "^%"
Error79(TokenSpan()); return (int)Tokens.repErr;
            break;
        case 5: // Recognized '^{Ident}',	Shortest string "^G"
yy_push_state(REGEX); 
                         yy_push_state(SPACE); 
                         return (int)Tokens.name;
            break;
        case 7: // Recognized '^%{Ident}',	Shortest string "^%G"
return (int)GetTagToken(yytext);
            break;
        case 8: // Recognized '^{Space}*%%',	Shortest string "^%%"
        case 68: // In <CMMNT> Recognized '^{Space}*%%',	Shortest string "^%%"
        case 85: // In <REGEX> Recognized '^{Space}*%%',	Shortest string "^%%"
if (yytext.Length > 2)
                             Error(90, TokenSpan());
                         while (scStack.Count > 0) 
                             yy_pop_state();
                         if (YY_START == 0)
                             BEGIN(RULES);
                         else
                             BEGIN(UCODE); 
                         yy_push_state(XPEOL); 
                         return (int)Tokens.PCPC;
            break;
        case 9: // Recognized '^%\{',	Shortest string "^%{"
yy_push_state(UCODE); yy_push_state(XPEOL); return (int)Tokens.lPcBrace;
            break;
        case 10: // Recognized '^%\}',	Shortest string "^%}"
return (int)Tokens.rPcBrace; /* error! */
            break;
        case 11: // Recognized '^{Space}+/{NotWh}',	Shortest string "^\t/"
        case 12: // Recognized '^{Space}+/{NotWh}',	Shortest string "^\t%"
_yytrunc(1); 
yy_push_state(INDNT); return (int)Tokens.lxIndent;
            break;
        case 13: // Recognized '{OneLineCmnt}',	Shortest string "//"
return (int)Tokens.csCommentL;
            break;
        case 14: // Recognized '^{CmntStrt}{ABStar}\**',	Shortest string "^/*"
        case 15: // Recognized '^{CmntStrt}{ABStar}\**',	Shortest string "^/**"
yy_push_state(CMMNT); 
                         comStart = TokenSpan(); 
                         return (int)Tokens.defCommentS;
            break;
        case 16: // Recognized '^{CmntStrt}{ABStar}\**{CmntEnd}',	Shortest string "^/**/"
return (int)Tokens.defCommentE;
            break;
        case 18: // In <SKIP> Recognized '{DotChr}+',	Shortest string "/"
        case 19: // In <SKIP> Recognized '{DotChr}+',	Shortest string "["
yy_pop_state();
            break;
        case 20: // In <RULES> Recognized '^{NotWh}',	Shortest string "^/"
        case 21: // In <RULES> Recognized '^{NotWh}',	Shortest string "^["
        case 22: // In <RULES> Recognized '^{NotWh}',	Shortest string "^%"
yy_push_state(REGEX); 
                       yyless(0);
            break;
        case 23: // In <RULES> Recognized '^<',	Shortest string "^<"
yy_push_state(REGEX); 
                       yy_push_state(NMLST); 
                       return (int)Tokens.lCond;
            break;
        case 24: // In <RULES> Recognized '^"<<EOF>>"',	Shortest string "^<<EOF>>"
yy_push_state(SMACT); 
                       yy_push_state(SPACE); 
                       return (int)Tokens.pattern;
            break;
        case 25: // In <RULES> Recognized '{CmntStrt}{ABStar}\**',	Shortest string "/*"
        case 26: // In <RULES> Recognized '{CmntStrt}{ABStar}\**',	Shortest string "/**"
yy_push_state(CMMNT);
                       comStart = TokenSpan(); 
                       return (int)Tokens.csCommentS;
            break;
        case 27: // In <RULES> Recognized '{CmntStrt}{ABStar}\**{CmntEnd}',	Shortest string "/**/"
return (int)Tokens.csCommentE;
            break;
        case 29: // In <UCODE> Recognized '{CShOps}',	Shortest string "/"
        case 33: // In <UCODE> Recognized '{CShOps}',	Shortest string "^%"
        case 37: // In <UCODE> Recognized '{CShOps}',	Shortest string ">"
        case 40: // In <UCODE> Recognized '{CShOps}',	Shortest string "#"
        case 41: // In <UCODE> Recognized '{CShOps}',	Shortest string "+"
        case 42: // In <UCODE> Recognized '{CShOps}',	Shortest string "-"
        case 43: // In <UCODE> Recognized '{CShOps}',	Shortest string "%"
        case 44: // In <UCODE> Recognized '{CShOps}',	Shortest string "<"
        case 53: // In <BCODE> Recognized '{CShOps}',	Shortest string "^%"
return (int)Tokens.csOp;
            break;
        case 30: // In <UCODE> Recognized '\[',	Shortest string "["
return (int)Tokens.csLBrac;
            break;
        case 31: // In <UCODE> Recognized '{Ident}',	Shortest string "G"
return (int)GetIdToken(yytext);
            break;
        case 32: // In <UCODE> Recognized '{Number}',	Shortest string "8"
return (int)Tokens.csNumber;
            break;
        case 34: // In <UCODE> Recognized '\{',	Shortest string "{"
return (int)Tokens.csLBrace;
            break;
        case 35: // In <UCODE> Recognized '\}',	Shortest string "}"
return (int)Tokens.csRBrace;
            break;
        case 36: // In <UCODE> Recognized ',',	Shortest string ","
return (int)Tokens.comma;
            break;
        case 39: // In <UCODE> Recognized '\]',	Shortest string "]"
return (int)Tokens.csRBrac;
            break;
        case 46: // In <UCODE> Recognized ';',	Shortest string ";"
return (int)Tokens.semi;
            break;
        case 47: // In <UCODE> Recognized '\.',	Shortest string "."
return (int)Tokens.csDot;
            break;
        case 48: // In <UCODE> Recognized '\(',	Shortest string "("
return (int)Tokens.csLPar;
            break;
        case 49: // In <UCODE> Recognized '\)',	Shortest string ")"
return (int)Tokens.csRPar;
            break;
        case 50: // In <UCODE> Recognized '{LitChr}',	Shortest string "'/'"
return (int)Tokens.csLitchr;
            break;
        case 51: // In <UCODE> Recognized '{LitStr}',	Shortest string "\"\""
return (int)Tokens.csLitstr;
            break;
        case 52: // In <UCODE> Recognized '^%\}',	Shortest string "^%}"
yy_pop_state(); yy_push_state(XPEOL); return (int)Tokens.rPcBrace;
            break;
        case 54: // In <BCODE> Recognized '\{',	Shortest string "{"
depth++; return (int)Tokens.csLBrace;
            break;
        case 55: // In <BCODE> Recognized '\}',	Shortest string "}"
if (depth > 0) { depth--; return (int)Tokens.csRBrace; }
                            else           { yy_pop_state(); return (int)Tokens.lxRBrace; }
            break;
        case 56: // In <LCODE> Recognized '{Eol}',	Shortest string ""
        case 57: // In <LCODE> Recognized '{Eol}',	Shortest string "\r"
yy_pop_state(); ResetBadCount(); return (int)Tokens.EOL;
            break;
        case 58: // In <INDNT> Recognized '^{NotWh}{DotChr}*',	Shortest string "^/"
        case 59: // In <INDNT> Recognized '^{NotWh}{DotChr}*',	Shortest string "^["
yy_pop_state(); yyless(0); return (int)Tokens.lxEndIndent;
            break;
        case 60: // In <CMMNT> Recognized '{ABStar}\**',	Shortest string ""
        case 61: // In <CMMNT> Recognized '{ABStar}\**',	Shortest string "^"
        case 62: // In <CMMNT> Recognized '{ABStar}\**',	Shortest string "/"
        case 63: // In <CMMNT> Recognized '{ABStar}\**',	Shortest string "["
        case 64: // In <CMMNT> Recognized '{ABStar}\**',	Shortest string "^\t"
        case 65: // In <CMMNT> Recognized '{ABStar}\**',	Shortest string "^%"
        case 66: // In <CMMNT> Recognized '{ABStar}\**',	Shortest string "*"
return (int)Tokens.csCommentS;
            break;
        case 67: // In <CMMNT> Recognized '{ABStar}\**{CmntEnd}',	Shortest string "*/"
yy_pop_state(); return (int)Tokens.csCommentE;
            break;
        case 69: // In <SMACT> Recognized '{Eol}',	Shortest string ""
        case 72: // In <SMACT> Recognized '{Eol}',	Shortest string "\r"
yy_pop_state(); 
                       Error(89, TokenSpan()); 
                       return (int)Tokens.csOp;
            break;
        case 70: // In <SMACT> Recognized '{NotWh}',	Shortest string "/"
        case 71: // In <SMACT> Recognized '{NotWh}',	Shortest string "["
        case 73: // In <SMACT> Recognized '{NotWh}',	Shortest string "^%"
yy_pop_state(); 
                       yy_push_state(LCODE); 
                       yyless(0);
            break;
        case 74: // In <SMACT> Recognized '\{',	Shortest string "{"
yy_pop_state(); 
                       yy_push_state(BCODE); 
                       depth = 0; 
                       return (int)Tokens.lxLBrace;
            break;
        case 75: // In <SMACT> Recognized '\|',	Shortest string "|"
yy_pop_state(); return (int)Tokens.lxBar;
            break;
        case 76: // In <XPEOL> Recognized '{NotWh}{DotChr}*',	Shortest string "/"
        case 77: // In <XPEOL> Recognized '{NotWh}{DotChr}*',	Shortest string "["
Error(80, TokenSpan()); return (int)Tokens.repErr;
            break;
        case 78: // In <REGEX> Recognized '{Regex}+',	Shortest string "/"
        case 80: // In <REGEX> Recognized '{Regex}+',	Shortest string "G"
        case 81: // In <REGEX> Recognized '{Regex}+',	Shortest string "^%"
yy_pop_state();
                       switch (YY_START) {
                           case INITIAL:
                               yy_push_state(XPEOL); break;
                           case RULES:
                           case PRGRP:
                               yy_push_state(SMACT);
                               yy_push_state(SPACE); break;
                       } 
                       return (int)Tokens.pattern;
            break;
        case 82: // In <REGEX> Recognized '\{',	Shortest string "{"
yy_pop_state();
                       if (YY_START == RULES || YY_START == PRGRP) {
                           yy_push_state(PRGRP);
                           yy_push_state(XPEOL);
                           return (int)Tokens.lxLBrace;
                       } else {
                           Error79(TokenSpan());
                           return (int)Tokens.repErr;
                       }
            break;
        case 86: // In <NMLST> Recognized '{Space}+',	Shortest string "^\t"
        case 93: // In <NMLST> Recognized '{Space}+',	Shortest string "\t"
/* skip */
            break;
        case 87: // In <NMLST> Recognized '{Ident}',	Shortest string "G"
return (int)Tokens.name;
            break;
        case 88: // In <NMLST> Recognized '{Number}',	Shortest string "8"
return (int)Tokens.csNumber;
            break;
        case 90: // In <NMLST> Recognized '\*',	Shortest string "*"
return (int)Tokens.csStar;
            break;
        case 91: // In <NMLST> Recognized ',',	Shortest string ","
return (int)Tokens.comma;
            break;
        case 92: // In <NMLST> Recognized '>',	Shortest string ">"
yy_pop_state(); 
                       return (int)Tokens.rCond;
            break;
        case 94: // In <SPACE> Recognized '{Eol}',	Shortest string ""
        case 98: // In <SPACE> Recognized '{Eol}',	Shortest string "\r"
yy_pop_state(); Error(78, TokenSpan()); return (int)Tokens.EOL;
            break;
        case 95: // In <SPACE> Recognized '{NotWh}+',	Shortest string "/"
        case 96: // In <SPACE> Recognized '{NotWh}+',	Shortest string "["
Error(78, TokenSpan()); return (int)Tokens.repErr;
            break;
        case 97: // In <SPACE> Recognized '{Space}+',	Shortest string "^\t"
        case 99: // In <SPACE> Recognized '{Space}+',	Shortest string "\t"
yy_pop_state();
            break;
        case 100: // In <VRBTM> Recognized '{DotChr}+',	Shortest string "/"
        case 101: // In <VRBTM> Recognized '{DotChr}+',	Shortest string "["
yy_pop_state(); return (int)Tokens.verbatim;
            break;
        case 102: // In <VRBTM> Recognized '{Space}+',	Shortest string "\t"
/* skip */
            break;
        case 103: // In <PRGRP> Recognized '{NotWh}',	Shortest string "/"
        case 104: // In <PRGRP> Recognized '{NotWh}',	Shortest string "["
        case 106: // In <PRGRP> Recognized '{NotWh}',	Shortest string "^%"
yy_push_state(REGEX); yyless(0);
            break;
        case 105: // In <PRGRP> Recognized '^{Space}+',	Shortest string "^\t"
/* skip */
            break;
        case 107: // In <PRGRP> Recognized '\}',	Shortest string "}"
yy_pop_state();
                       yy_push_state(XPEOL);
                       return (int)Tokens.lxRBrace;
            break;
        case 108: // In <PRGRP> Recognized '\<',	Shortest string "<"
yy_push_state(REGEX); 
                       yy_push_state(NMLST); 
                       return (int)Tokens.lCond;
            break;
        case 109: // In <PRGRP> Recognized '"<<EOF>>"',	Shortest string "<<EOF>>"
yy_push_state(SMACT); 
                       yy_push_state(SPACE); 
                       return (int)Tokens.pattern;
            break;
        default:
            break;
    }
#pragma warning restore 162
#endregion
                    }
                }
            } // end try
            finally {
// User-specified epilog to scan()
/* Epilog from LEX file */
	yylloc = new LexSpan(tokLin, tokCol, tokELin, tokECol, tokPos, tokEPos, buffer);
// End, user-specified epilog
            } // end finally
        }
예제 #28
0
internal static void CheckSpan(int len, LexSpan span, ErrorHandler hdlr)
    {
        ActionScanner scnr = new ActionScanner();
        scnr.SetSource(span.ToString(), 1);
        scnr.length = len;
        scnr.src = span;
        scnr.handler = hdlr;
        scnr.lineNo = span.startLine;
        scnr.colNo = span.startColumn;
        scnr.yylex();
    }
예제 #29
0
 internal void AddLexCatPredicate( string name, LexSpan span ) {
     LexCategory cat;
     if (!lexCategories.TryGetValue( name, out cat ))
         hdlr.ListError( span, 55, name );
     else if (cat.regX.op != RegOp.charClass)
         hdlr.ListError( span, 71, name );
     else if (!cat.HasPredicate) {
         cat.HasPredicate = true;
         lexCatsWithPredicates.Add( cat );
         // Add a dummy exclusive start state for the predicate
         AddDummyStartState( cat.PredDummyName );
     }
 }
예제 #30
0
 public ReturnToken(LexSpan lex)
     : base(SyntaxKind.ReturnKeyword, lex)
 {
 }
예제 #31
0
 internal void AddSpan( LexSpan l ) { locs.Add( l ); }
예제 #32
0
 public EndToken(LexSpan lex)
     : base(SyntaxKind.EndKeyword, lex)
 {
 }
예제 #33
0
 internal ReParser( string str, LexSpan spn, AAST parent ) {
     if (parent.task.Unicode)
         CharacterUtilities.SetUnicode();
     symCard = parent.task.HostSymCardinality;
     pat = str;
     span = spn;
     InitReParser();
     this.parent = parent;
     //
     //  This is ugly, but we cannot manipulate
     //  RangeLists unless the alphabet upper bound
     //  is known to the code of class Partition.
     //
     CharRange.Init( parent.task.TargetSymCardinality );
 }
예제 #34
0
 public IfToken(LexSpan lex)
     : base(SyntaxKind.IfKeyword, lex)
 {
 }
예제 #35
0
 public WhileToken(LexSpan lex)
     : base(SyntaxKind.WhileKeyword, lex)
 {
 }
예제 #36
0
 public EolToken(LexSpan lex)
     : base(SyntaxKind.EolToken, lex)
 {
 }
예제 #37
0
 internal bool AddLexCategory( string name, string verb, LexSpan spn ) {
     if (lexCategories.ContainsKey( name ))
         return false;
     else {
         LexCategory cls = new LexCategory( name, verb, spn );
         lexCategories.Add( name, cls );
         cls.ParseRE( this );
         return true;
     }
 }
예제 #38
0
 public SubToken(LexSpan lex)
     : base(SyntaxKind.SubKeyword, lex)
 {
 }
예제 #39
0
 public ScanObj(int t, int val, LexSpan loc)
 {
     this.token = t; this.yylval = val; this.yylloc = loc;
 }
예제 #40
0
 public AndToken(LexSpan lex)
     : base(SyntaxKind.AndBinop, lex)
 {
 }
예제 #41
0
 public BooleanToken(LexSpan lex, bool value)
     : base(value ? SyntaxKind.TrueKeyValue : SyntaxKind.FalseKeyValue, lex)
 {
     Value = value;
 }
예제 #42
0
        internal Terminal LookupOrDefineTerminal(Token token, string name, string alias, LexSpan span)
        {
            bool     isIdent = (token == Token.ident);
            Terminal result  = null;

            // Canonicalize escaped char-literals
            if (!isIdent)
            {
                name = CharacterUtilities.CanonicalizeCharacterLiteral(name, 1);
            }
            else if (alias != null)
            {
                alias = CharacterUtilities.CanonicalizeAlias(alias);
            }
            // Check if already present in dictionary
            if (!terminals.ContainsKey(name))      // terminal not already known
            {
                result          = new Terminal(isIdent, name, alias);
                terminals[name] = result;
                if (alias != null)
                {
                    CheckAndSetAlias(alias, result, span);
                }
            }
            else
            {
                result = terminals[name];
                if (alias != null)
                {
                    CheckAlias(alias, result, span);
                }
            }
            return(result);
        }
예제 #43
0
 public DotToken(LexSpan lex)
     : base(SyntaxKind.Dot, lex)
 {
 }
예제 #44
0
 public LiteralToken(SyntaxKind kind, LexSpan lex)
     : base(kind, lex)
 {
 }
예제 #45
0
 private void Error(int n, LexSpan s)
 {
     if (yyhdlr != null) yyhdlr.ListError(s, n);
 }
예제 #46
0
 internal ReParser(string str, LexSpan spn, AAST parent)
 {
     if (parent.task.Unicode)
         CharacterUtilities.SetUnicode();
     symCard = parent.task.HostSymCardinality;
     pat = str;
     span = spn;
     InitReParser();
     this.parent = parent;
 }
예제 #47
0
 public OrToken(LexSpan lex)
     : base(SyntaxKind.OrBinop, lex)
 {
 }
예제 #48
0
 public InvalidToken(LexSpan lex)
     : base(SyntaxKind.InvalidKeyValue, lex)
 {
 }
예제 #49
0
 internal void Error(int n, LexSpan s)
 {
     // Console.WriteLine(StateStack(YY_START));
     if (yyhdlr != null) yyhdlr.ListError(s, n);
 }
예제 #50
0
        private void InsertCodeSpan(LexSpan span)
        {
            if (span != null)
            {
                int lNum = span.startLine;
                string code = span.ToString();
                string format = null;
                if (GPCG.Lines)
                  format = String.Format(CultureInfo.InvariantCulture, "#line {{0}} \"{0}\"", GPCG.LinesFilename ?? grammar.InputFilename);

                StringReader reader = new StringReader(code);
                while (true)
                {
                    string line = reader.ReadLine();
                    if (line == null)
                        break;
                    if (format != null)
                        Console.WriteLine(format, lNum++);
                    Console.WriteLine(line);
                }
            }
        }