compiler-construction

Scanner NoSuchElementException

烈酒焚心 提交于 2021-02-05 11:13:15
问题 I made a program that asks for 3 integers to output type of triangle. Everything runs and compiled successfully, however, it seems the part where it asks the user to see if they want to loop it again, the online compiler outputs the error: Exception in thread "main" java.util.NoSuchElementException at java.util.Scanner.throwFor(Scanner.java:838) at java.util.Scanner.next(Scanner.java:1347) at Assignment5.main(Assignment5.java:56) import java.util.Scanner; public class Assignment5 { public

What does it mean when my compiler tells me I'm using unsafe or unchecked operations?

有些话、适合烂在心里 提交于 2021-02-05 09:38:47
问题 My program compiles fine, but my console spits out the following: ----jGRASP exec: javac -g CreditGraphics.java Note: CreditGraphics.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. ----jGRASP: operation complete. First, what makes an operation unsafe? And how can a process be "unchecked"? What does "Recompile with -Xlint" mean? I'm using jGrasp and I'm not sure if that's a button or some sort of command? I want to see the details. It doesn't

Scanner (Lexing keywords with ANTLR)

倾然丶 夕夏残阳落幕 提交于 2021-02-04 21:28:29
问题 I have been working on writing a scanner for my program and most of the tutorials online include a parser along with the scanner. It doesn't seem possible to write a lexer without writing a parser at the same time. I am only trying to generate tokens, not interpret them. I want to recognize INT tokens, float tokens, and some tokens like "begin" and "end" I am confused about how to match keywords. I unsuccessfully tried the following: KEYWORD : KEY1 | KEY2; KEY1 : {input.LT(1).getText().equals

Scanner (Lexing keywords with ANTLR)

守給你的承諾、 提交于 2021-02-04 21:27:49
问题 I have been working on writing a scanner for my program and most of the tutorials online include a parser along with the scanner. It doesn't seem possible to write a lexer without writing a parser at the same time. I am only trying to generate tokens, not interpret them. I want to recognize INT tokens, float tokens, and some tokens like "begin" and "end" I am confused about how to match keywords. I unsuccessfully tried the following: KEYWORD : KEY1 | KEY2; KEY1 : {input.LT(1).getText().equals

why does compiler store variables in register?

房东的猫 提交于 2021-02-04 19:42:05
问题 Hi I have been reading this kind of stuff in various docs register Tells the compiler to store the variable being declared in a CPU register. In standard C dialects, keyword register uses the following syntax: register data-definition; The register type modifier tells the compiler to store the variable being declared in a >CPU register (if possible), to optimize access. For example, register int i; Note that TIGCC will automatically store often used variables in CPU registers when the

How do I interpret the columns of the CPU window's disassembly pane?

十年热恋 提交于 2021-02-04 16:19:41
问题 There is a tool called the CPU window, which I get pressing Ctrl + Alt + C , that shows the disassembly of my code. A green arrow to the left of the memory address indicates the location of the current execution point, then there is the memory addresses, but what does the second column mean, and why does the compiler sometimes jump more than one address after an instruction? For example: |first column|second column|assembly| 004520F4 55 push ebp //continuous 004520F5 8BEC mov ebp, esp //jumps

How do I interpret the columns of the CPU window's disassembly pane?

放肆的年华 提交于 2021-02-04 16:19:25
问题 There is a tool called the CPU window, which I get pressing Ctrl + Alt + C , that shows the disassembly of my code. A green arrow to the left of the memory address indicates the location of the current execution point, then there is the memory addresses, but what does the second column mean, and why does the compiler sometimes jump more than one address after an instruction? For example: |first column|second column|assembly| 004520F4 55 push ebp //continuous 004520F5 8BEC mov ebp, esp //jumps

Converting a function to use tail recursion — a formal study

帅比萌擦擦* 提交于 2021-02-04 13:23:30
问题 Has anyone written a formal paper describing a method to (automatically) convert functions to be tail recursive? I am looking for a university-level formal treatment including the limitations (types of functions that can be converted), procedures for conversion, and, if possible, proofs of correctness? Examples in Haskell would be a bonus. 回答1: a method to (automatically) convert functions to be tail recursive? So there are two parts to this: recognizing that a given recursive function can be

Converting a function to use tail recursion — a formal study

浪尽此生 提交于 2021-02-04 13:23:05
问题 Has anyone written a formal paper describing a method to (automatically) convert functions to be tail recursive? I am looking for a university-level formal treatment including the limitations (types of functions that can be converted), procedures for conversion, and, if possible, proofs of correctness? Examples in Haskell would be a bonus. 回答1: a method to (automatically) convert functions to be tail recursive? So there are two parts to this: recognizing that a given recursive function can be

Does anyone have a working B compiler? [closed]

老子叫甜甜 提交于 2021-02-04 09:59:10
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . Improve this question Does anyone know where I could get a good B compiler? I have searched for a B compiler for some time now, but have been having some difficulty finding anything complete for a Windows or Linux system. Here is an example of B: main( ) { auto a, b, c, sum; a = 1; b =