Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何查看字符串的第一个字符是否为&引用;(以“开始”开头的字符串) 静态布尔isLiteralTexto(字符串lexema){ 字符串letra=[34]; 字符串字符=”; int estado=1; 对于(int i=0;i_Java_Compiler Errors_Lexer - Fatal编程技术网

Java 如何查看字符串的第一个字符是否为&引用;(以“开始”开头的字符串) 静态布尔isLiteralTexto(字符串lexema){ 字符串letra=[34]; 字符串字符=”; int estado=1; 对于(int i=0;i

Java 如何查看字符串的第一个字符是否为&引用;(以“开始”开头的字符串) 静态布尔isLiteralTexto(字符串lexema){ 字符串letra=[34]; 字符串字符=”; int estado=1; 对于(int i=0;i,java,compiler-errors,lexer,Java,Compiler Errors,Lexer,我不知道怎么做,你能帮我吗? 我在做一个词法分析器和一个语法分析器你可以用下面的代码段来检查: if(lexema.indexOf(“”==0)使用标准java:yourstring.startsWith(“”;if(lexema.startsWith(“”)或if(lexema.charAt(0)==“”)你能更详细地描述你的问题吗?你想做什么?为什么?你尝试了什么?为什么不奏效?你得到了什么错误?lexema.charAt(0)==''?我在做一个自己语言的编译器,是一个有很多类的项目,所以

我不知道怎么做,你能帮我吗?
我在做一个词法分析器和一个语法分析器

你可以用下面的代码段来检查:
if(lexema.indexOf(“”==0)

使用标准java:yourstring.startsWith(“”;

if(lexema.startsWith(“”)
if(lexema.charAt(0)==“”)
你能更详细地描述你的问题吗?你想做什么?为什么?你尝试了什么?为什么不奏效?你得到了什么错误?
lexema.charAt(0)==''
?我在做一个自己语言的编译器,是一个有很多类的项目,所以我必须识别一个文本文本…我们称之为代码行的东西,比如这个“hi”,所以我想检查我文件的第一行,识别第一个字符是否是“”,也就是说这是一个文本
static boolean isLiteralTexto(String lexema) {
           String letra = [34];
            String caracter = "";
            int estado = 1;
            for (int i = 0; i < lexema.length(); i++) {
                caracter = lexema.charAt(i) + "";
                switch (estado) {
                case 1:
                    if (caracter.matches(letra))
                        estado = 2;
                                    System.out.println("HOLA");
                    else
                        estado = 3;
                    break;